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