Fix warnings from -Weffc++
This commit is contained in:
parent
829a768e82
commit
8b429bac9a
@ -5,7 +5,7 @@
|
||||
google/gmock: 4
|
||||
google/gtest: 11
|
||||
messmer/cmake: 3
|
||||
messmer/spdlog: 0
|
||||
messmer/spdlog: 1
|
||||
|
||||
[parent]
|
||||
messmer/cpp-utils: 4
|
||||
|
@ -11,6 +11,7 @@ namespace cpputils {
|
||||
|
||||
class Console {
|
||||
public:
|
||||
virtual ~Console() {}
|
||||
virtual unsigned int ask(const std::string &question, const std::vector<std::string> &options) = 0;
|
||||
virtual bool askYesNo(const std::string &question) = 0;
|
||||
virtual void print(const std::string &output) = 0;
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include <streambuf>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include "../macros.h"
|
||||
|
||||
//TODO Add test cases
|
||||
|
||||
@ -67,7 +68,9 @@ namespace cpputils {
|
||||
|
||||
public:
|
||||
pipestream(string_size_t out_size = 16, string_size_t in_size = 64)
|
||||
: d_out(std::max(string_size_t(1), out_size), ' ')
|
||||
: d_mutex()
|
||||
, d_condition()
|
||||
, d_out(std::max(string_size_t(1), out_size), ' ')
|
||||
, d_in(std::max(string_size_t(1), in_size), ' ')
|
||||
, d_tmp(std::max(string_size_t(1), in_size), ' ')
|
||||
, d_current(&this->d_tmp[0])
|
||||
@ -144,6 +147,8 @@ namespace cpputils {
|
||||
}
|
||||
return traits_type::eof();
|
||||
}
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(pipestream);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ namespace cpputils {
|
||||
DISALLOW_COPY_AND_ASSIGN(RandomDataBuffer);
|
||||
};
|
||||
|
||||
inline RandomDataBuffer::RandomDataBuffer() : _data(0) {
|
||||
inline RandomDataBuffer::RandomDataBuffer() : _usedUntil(0), _data(0) {
|
||||
}
|
||||
|
||||
inline size_t RandomDataBuffer::size() const {
|
||||
@ -37,12 +37,14 @@ namespace cpputils {
|
||||
_usedUntil += numBytes;
|
||||
}
|
||||
|
||||
inline void RandomDataBuffer::add(Data data) {
|
||||
inline void RandomDataBuffer::add(Data newData) {
|
||||
// Concatenate old and new random data
|
||||
Data newdata(_data.size() + data.size());
|
||||
std::memcpy(newdata.data(), _data.data(), _data.size());
|
||||
std::memcpy(newdata.dataOffset(_data.size()), data.data(), data.size());
|
||||
_data = std::move(newdata);
|
||||
size_t oldSize = size();
|
||||
Data combined(oldSize + newData.size());
|
||||
get(combined.data(), oldSize);
|
||||
std::memcpy(combined.dataOffset(oldSize), newData.data(), newData.size());
|
||||
_data = std::move(combined);
|
||||
_usedUntil = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ namespace cpputils {
|
||||
DISALLOW_COPY_AND_ASSIGN(ThreadsafeRandomDataBuffer);
|
||||
};
|
||||
|
||||
inline ThreadsafeRandomDataBuffer::ThreadsafeRandomDataBuffer() {
|
||||
inline ThreadsafeRandomDataBuffer::ThreadsafeRandomDataBuffer(): _buffer(), _mutex(), _dataAddedCv(), _dataGottenCv() {
|
||||
}
|
||||
|
||||
inline size_t ThreadsafeRandomDataBuffer::size() const {
|
||||
|
@ -380,6 +380,8 @@ public:
|
||||
|
||||
private:
|
||||
const DestructorCallback *_destructorCallback;
|
||||
|
||||
ClassWithDestructorCallback &operator=(const ClassWithDestructorCallback &rhs) = delete;
|
||||
};
|
||||
class OnlyMoveableClassWithDestructorCallback {
|
||||
public:
|
||||
|
@ -33,6 +33,8 @@ private:
|
||||
|
||||
class LoggingTest: public ::testing::Test {
|
||||
public:
|
||||
LoggingTest(): mockLogger() {}
|
||||
|
||||
std::string captureStderr(std::function<void()> func) {
|
||||
testing::internal::CaptureStderr();
|
||||
func();
|
||||
|
@ -36,6 +36,7 @@ public:
|
||||
|
||||
private:
|
||||
const DestructorCallback *_destructorCallback;
|
||||
DISALLOW_COPY_AND_ASSIGN(Child);
|
||||
};
|
||||
|
||||
class Child2 : public Parent {};
|
||||
@ -129,6 +130,8 @@ TEST(UniquePtr_DynamicPointerMoveTest, ChildToParentCast) {
|
||||
|
||||
class UniqueRef_DynamicPointerMoveDestructorTest: public ::testing::Test {
|
||||
public:
|
||||
UniqueRef_DynamicPointerMoveDestructorTest(): childDestructorCallback() {}
|
||||
|
||||
DestructorCallback childDestructorCallback;
|
||||
unique_ref<Child> createChild() {
|
||||
return make_unique_ref<Child>(&childDestructorCallback);
|
||||
@ -140,6 +143,8 @@ public:
|
||||
|
||||
class UniquePtr_DynamicPointerMoveDestructorTest: public ::testing::Test {
|
||||
public:
|
||||
UniquePtr_DynamicPointerMoveDestructorTest(): childDestructorCallback() {}
|
||||
|
||||
DestructorCallback childDestructorCallback;
|
||||
unique_ptr<Child> createChild() {
|
||||
return make_unique<Child>(&childDestructorCallback);
|
||||
|
@ -14,6 +14,7 @@ public:
|
||||
virtual ~TestObject() {
|
||||
_destructorListener();
|
||||
}
|
||||
|
||||
private:
|
||||
function<void()> _destructorListener;
|
||||
};
|
||||
@ -42,10 +43,13 @@ public:
|
||||
private:
|
||||
bool _isDestructed;
|
||||
TestObject *_testObject;
|
||||
DISALLOW_COPY_AND_ASSIGN(TestObjectHolder);
|
||||
};
|
||||
|
||||
class OptionalOwnershipPointerTest: public Test {
|
||||
public:
|
||||
OptionalOwnershipPointerTest(): obj(), obj2() {}
|
||||
|
||||
TestObjectHolder obj;
|
||||
TestObjectHolder obj2;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user