Skip to content

Commit

Permalink
enh: resolve unit test and few other warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
matejk committed May 8, 2024
1 parent 065f9a0 commit ad72b25
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 76 deletions.
6 changes: 2 additions & 4 deletions CppUnit/include/CppUnit/Test.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,11 @@ class CppUnit_API Test
};


inline Test::~Test()
{
}
inline Test::~Test() = default;


// Runs a test and collects its result in a TestResult instance.
inline void Test::run(TestResult* result, const Callback& callback)
inline void Test::run(TestResult*, const Callback&)
{
}

Expand Down
8 changes: 4 additions & 4 deletions CppUnit/include/CppUnit/TestCaller.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class TestCaller: public TestCase
{
REFERENCEOBJECT (TestCaller)

typedef void (Fixture::*TestMethod)();
using TestMethod = void (Fixture::*)();

public:
TestCaller(const std::string& name, TestMethod test, Test::Type testType = Test::Normal):
Expand All @@ -62,19 +62,19 @@ class TestCaller: public TestCase
}

protected:
void runTest()
void runTest() override
{
(_fixture.get()->*_test)();
}

void setUp()
void setUp() override
{
if (!setup().empty())
_fixture.get()->addSetup(setup());
_fixture.get()->setUp();
}

void tearDown()
void tearDown() override
{
_fixture.get()->tearDown();
}
Expand Down
27 changes: 13 additions & 14 deletions CppUnit/include/CppUnit/TestCase.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "CppUnit/TestResult.h"
#include "CppUnit/CppUnitException.h"
#include <string>
#include <utility>
#include <vector>
#include <typeinfo>

Expand Down Expand Up @@ -88,14 +89,14 @@ class CppUnit_API TestCase: public Test
REFERENCEOBJECT (TestCase)

public:
TestCase(const std::string& Name, Test::Type testType = Test::Normal);
~TestCase();
TestCase(const std::string& name, Test::Type testType = Test::Normal);
~TestCase() override;

virtual void run(TestResult* result, const Test::Callback& callback = nullptr);
void run(TestResult* result, const Test::Callback& callback = nullptr) override;
virtual TestResult* run();
virtual int countTestCases() const;
virtual std::string toString() const;
virtual Test::Type getType() const;
int countTestCases() const override;
std::string toString() const override;
Test::Type getType() const override;
void setType(Test::Type testType);
const std::string& name() const;

Expand Down Expand Up @@ -126,8 +127,8 @@ class CppUnit_API TestCase: public Test
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);

template <typename T1, typename T2,
typename = typename std::enable_if<std::is_arithmetic<T1>::value, T1>::type,
typename = typename std::enable_if<std::is_arithmetic<T2>::value, T2>::type>
typename = std::enable_if_t<std::is_arithmetic_v<T1>, T1>,
typename = std::enable_if_t<std::is_arithmetic_v<T2>, T2>>
void assertEquals(T1 expected,
T2 actual,
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
Expand Down Expand Up @@ -159,8 +160,8 @@ class CppUnit_API TestCase: public Test
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);

template <typename T1, typename T2,
typename = typename std::enable_if<std::is_arithmetic<T1>::value, T1>::type,
typename = typename std::enable_if<std::is_arithmetic<T2>::value, T2>::type>
typename = std::enable_if_t<std::is_arithmetic_v<T1>, T1>,
typename = std::enable_if_t<std::is_arithmetic_v<T2>, T2>>
std::string notEqualsMessage(T1 expected, T2 actual)
{
return "expected: " + std::to_string(expected) + " but was: " + std::to_string(actual);
Expand Down Expand Up @@ -203,9 +204,7 @@ inline TestCase::TestCase(const std::string& name, Test::Type testType)


// Destructs a test case
inline TestCase::~TestCase()
{
}
inline TestCase::~TestCase() = default;


// Returns a count of all the tests executed
Expand All @@ -229,7 +228,7 @@ inline void TestCase::setUp()


// A hook for fixture set up with command line arguments
inline void TestCase::setUp(const std::vector<std::string>& setup)
inline void TestCase::setUp(const std::vector<std::string>&)
{
}

Expand Down
8 changes: 4 additions & 4 deletions CppUnit/include/CppUnit/TestDecorator.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ class CppUnit_API TestDecorator: public Test
public:
TestDecorator(Test* test);

virtual ~TestDecorator();
~TestDecorator() override;

int countTestCases() const;
int countTestCases() const override;

void run(TestResult* result, const Test::Callback& callback = nullptr);
void run(TestResult* result, const Test::Callback& callback = nullptr) override;

std::string toString() const;
std::string toString() const override;

protected:
Test* _test;
Expand Down
12 changes: 4 additions & 8 deletions CppUnit/include/CppUnit/TestResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,9 @@ class CppUnit_API TestResult
class SynchronizationObject
{
public:
SynchronizationObject()
{
}
SynchronizationObject() = default;

virtual ~SynchronizationObject()
{
}
virtual ~SynchronizationObject() = default;

virtual void lock()
{
Expand Down Expand Up @@ -138,15 +134,15 @@ inline void TestResult::addFailure(Test* test, CppUnitException* e)


// Informs the result that a test will be started.
inline void TestResult::startTest(Test* test)
inline void TestResult::startTest(Test*)
{
ExclusiveZone zone(_syncObject);
_runTests++;
}


// Informs the result that a test was completed.
inline void TestResult::endTest(Test* test)
inline void TestResult::endTest(Test*)
{
ExclusiveZone zone(_syncObject);
}
Expand Down
4 changes: 2 additions & 2 deletions CppUnit/include/CppUnit/TestRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ namespace CppUnit {
*/
class CppUnit_API TestRunner
{
typedef std::pair<std::string, Test*> Mapping;
typedef std::vector<Mapping> Mappings;
using Mapping = std::pair<std::string, Test *>;
using Mappings = std::vector<Mapping>;

public:
TestRunner();
Expand Down
10 changes: 5 additions & 5 deletions CppUnit/include/CppUnit/TestSuite.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ class CppUnit_API TestSuite: public Test

public:
TestSuite(const std::string& name = "");
~TestSuite();
~TestSuite() override;

void run(TestResult* result, const Test::Callback& callback = nullptr);
int countTestCases() const;
void run(TestResult* result, const Test::Callback& callback = nullptr) override;
int countTestCases() const override;
void addTest(Test* test);
std::string toString() const;
Test::Type getType() const;
std::string toString() const override;
Test::Type getType() const override;

virtual void deleteContents();

Expand Down
6 changes: 3 additions & 3 deletions CppUnit/include/CppUnit/TextTestResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class CppUnit_API TextTestResult: public TestResult
TextTestResult(std::ostream& ostr);
TextTestResult(std::ostream& ostr, const std::string& ignore);

virtual void addError(Test* test, CppUnitException* e);
virtual void addFailure(Test* test, CppUnitException* e);
virtual void startTest(Test* test);
void addError(Test* test, CppUnitException* e) override;
void addFailure(Test* test, CppUnitException* e) override;
void startTest(Test* test) override;
virtual void print(std::ostream& stream);
virtual void printErrors(std::ostream& stream);
virtual void printFailures(std::ostream& stream);
Expand Down
52 changes: 25 additions & 27 deletions Foundation/include/Poco/Dynamic/Pair.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,8 @@ class Pair
{
}

virtual ~Pair()
virtual ~Pair() = default;
/// Destroys the Pair.
{
}

Pair& swap(Pair& other) noexcept
/// Swaps the content of the two Pairs.
Expand Down Expand Up @@ -122,62 +120,62 @@ class VarHolderImpl<Pair<std::string>>: public VarHolder
return typeid(Pair<std::string>);
}

void convert(Int8& val) const
void convert(Int8&) const
{
throw BadCastException("Cannot cast Pair type to Int8");
}

void convert(Int16& val) const
void convert(Int16&) const
{
throw BadCastException("Cannot cast Pair type to Int16");
}

void convert(Int32& val) const
void convert(Int32&) const
{
throw BadCastException("Cannot cast Pair type to Int32");
}

void convert(Int64& val) const
void convert(Int64&) const
{
throw BadCastException("Cannot cast Pair type to Int64");
}

void convert(UInt8& val) const
void convert(UInt8&) const
{
throw BadCastException("Cannot cast Pair type to UInt8");
}

void convert(UInt16& val) const
void convert(UInt16&) const
{
throw BadCastException("Cannot cast Pair type to UInt16");
}

void convert(UInt32& val) const
void convert(UInt32&) const
{
throw BadCastException("Cannot cast Pair type to UInt32");
}

void convert(UInt64& val) const
void convert(UInt64&) const
{
throw BadCastException("Cannot cast Pair type to UInt64");
}

void convert(bool& val) const
void convert(bool&) const
{
throw BadCastException("Cannot cast Pair type to bool");
}

void convert(float& val) const
void convert(float&) const
{
throw BadCastException("Cannot cast Pair type to float");
}

void convert(double& val) const
void convert(double&) const
{
throw BadCastException("Cannot cast Pair type to double");
}

void convert(char& val) const
void convert(char&) const
{
throw BadCastException("Cannot cast Pair type to char");
}
Expand Down Expand Up @@ -271,62 +269,62 @@ class VarHolderImpl<Pair<int>>: public VarHolder
return typeid(Pair<int>);
}

void convert(Int8& val) const
void convert(Int8&) const
{
throw BadCastException("Cannot cast Pair type to Int8");
}

void convert(Int16& val) const
void convert(Int16&) const
{
throw BadCastException("Cannot cast Pair type to Int16");
}

void convert(Int32& val) const
void convert(Int32&) const
{
throw BadCastException("Cannot cast Pair type to Int32");
}

void convert(Int64& val) const
void convert(Int64&) const
{
throw BadCastException("Cannot cast Pair type to Int64");
}

void convert(UInt8& val) const
void convert(UInt8&) const
{
throw BadCastException("Cannot cast Pair type to UInt8");
}

void convert(UInt16& val) const
void convert(UInt16&) const
{
throw BadCastException("Cannot cast Pair type to UInt16");
}

void convert(UInt32& val) const
void convert(UInt32&) const
{
throw BadCastException("Cannot cast Pair type to UInt32");
}

void convert(UInt64& val) const
void convert(UInt64&) const
{
throw BadCastException("Cannot cast Pair type to UInt64");
}

void convert(bool& val) const
void convert(bool&) const
{
throw BadCastException("Cannot cast Pair type to bool");
}

void convert(float& val) const
void convert(float&) const
{
throw BadCastException("Cannot cast Pair type to float");
}

void convert(double& val) const
void convert(double&) const
{
throw BadCastException("Cannot cast Pair type to double");
}

void convert(char& val) const
void convert(char&) const
{
throw BadCastException("Cannot cast Pair type to char");
}
Expand Down
6 changes: 3 additions & 3 deletions Foundation/src/EventLogChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ std::wstring EventLogChannel::findLibrary(const wchar_t* name)
if (dll)
{
const DWORD maxPathLen = MAX_PATH + 1;
wchar_t name[maxPathLen];
int n = GetModuleFileNameW(dll, name, maxPathLen);
if (n > 0) path = name;
wchar_t moduleName[maxPathLen];
int n = GetModuleFileNameW(dll, moduleName, maxPathLen);
if (n > 0) path = moduleName;
FreeLibrary(dll);
}
return path;
Expand Down
2 changes: 1 addition & 1 deletion Foundation/src/ThreadPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ class ThreadPoolSingletonHolder
if (!_pPool)
{
_pPool = new ThreadPool("default");
if (POCO_THREAD_STACK_SIZE > 0)
if constexpr (POCO_THREAD_STACK_SIZE > 0)
_pPool->setStackSize(POCO_THREAD_STACK_SIZE);
}
return _pPool;
Expand Down
Loading

0 comments on commit ad72b25

Please sign in to comment.