mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-06 08:41:11 +01:00
enh: resolve unit test and few other warnings.
This commit is contained in:
parent
065f9a0ff9
commit
ad72b25ace
@ -50,13 +50,11 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline Test::~Test()
|
inline Test::~Test() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Runs a test and collects its result in a TestResult instance.
|
// 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&)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ class TestCaller: public TestCase
|
|||||||
{
|
{
|
||||||
REFERENCEOBJECT (TestCaller)
|
REFERENCEOBJECT (TestCaller)
|
||||||
|
|
||||||
typedef void (Fixture::*TestMethod)();
|
using TestMethod = void (Fixture::*)();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TestCaller(const std::string& name, TestMethod test, Test::Type testType = Test::Normal):
|
TestCaller(const std::string& name, TestMethod test, Test::Type testType = Test::Normal):
|
||||||
@ -62,19 +62,19 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void runTest()
|
void runTest() override
|
||||||
{
|
{
|
||||||
(_fixture.get()->*_test)();
|
(_fixture.get()->*_test)();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setUp()
|
void setUp() override
|
||||||
{
|
{
|
||||||
if (!setup().empty())
|
if (!setup().empty())
|
||||||
_fixture.get()->addSetup(setup());
|
_fixture.get()->addSetup(setup());
|
||||||
_fixture.get()->setUp();
|
_fixture.get()->setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
void tearDown()
|
void tearDown() override
|
||||||
{
|
{
|
||||||
_fixture.get()->tearDown();
|
_fixture.get()->tearDown();
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "CppUnit/TestResult.h"
|
#include "CppUnit/TestResult.h"
|
||||||
#include "CppUnit/CppUnitException.h"
|
#include "CppUnit/CppUnitException.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
|
|
||||||
@ -88,14 +89,14 @@ class CppUnit_API TestCase: public Test
|
|||||||
REFERENCEOBJECT (TestCase)
|
REFERENCEOBJECT (TestCase)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TestCase(const std::string& Name, Test::Type testType = Test::Normal);
|
TestCase(const std::string& name, Test::Type testType = Test::Normal);
|
||||||
~TestCase();
|
~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 TestResult* run();
|
||||||
virtual int countTestCases() const;
|
int countTestCases() const override;
|
||||||
virtual std::string toString() const;
|
std::string toString() const override;
|
||||||
virtual Test::Type getType() const;
|
Test::Type getType() const override;
|
||||||
void setType(Test::Type testType);
|
void setType(Test::Type testType);
|
||||||
const std::string& name() const;
|
const std::string& name() const;
|
||||||
|
|
||||||
@ -126,8 +127,8 @@ protected:
|
|||||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||||
|
|
||||||
template <typename T1, typename T2,
|
template <typename T1, typename T2,
|
||||||
typename = typename std::enable_if<std::is_arithmetic<T1>::value, T1>::type,
|
typename = std::enable_if_t<std::is_arithmetic_v<T1>, T1>,
|
||||||
typename = typename std::enable_if<std::is_arithmetic<T2>::value, T2>::type>
|
typename = std::enable_if_t<std::is_arithmetic_v<T2>, T2>>
|
||||||
void assertEquals(T1 expected,
|
void assertEquals(T1 expected,
|
||||||
T2 actual,
|
T2 actual,
|
||||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||||
@ -159,8 +160,8 @@ protected:
|
|||||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||||
|
|
||||||
template <typename T1, typename T2,
|
template <typename T1, typename T2,
|
||||||
typename = typename std::enable_if<std::is_arithmetic<T1>::value, T1>::type,
|
typename = std::enable_if_t<std::is_arithmetic_v<T1>, T1>,
|
||||||
typename = typename std::enable_if<std::is_arithmetic<T2>::value, T2>::type>
|
typename = std::enable_if_t<std::is_arithmetic_v<T2>, T2>>
|
||||||
std::string notEqualsMessage(T1 expected, T2 actual)
|
std::string notEqualsMessage(T1 expected, T2 actual)
|
||||||
{
|
{
|
||||||
return "expected: " + std::to_string(expected) + " but was: " + std::to_string(actual);
|
return "expected: " + std::to_string(expected) + " but was: " + std::to_string(actual);
|
||||||
@ -203,9 +204,7 @@ inline TestCase::TestCase(const std::string& name, Test::Type testType)
|
|||||||
|
|
||||||
|
|
||||||
// Destructs a test case
|
// Destructs a test case
|
||||||
inline TestCase::~TestCase()
|
inline TestCase::~TestCase() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Returns a count of all the tests executed
|
// Returns a count of all the tests executed
|
||||||
@ -229,7 +228,7 @@ inline void TestCase::setUp()
|
|||||||
|
|
||||||
|
|
||||||
// A hook for fixture set up with command line arguments
|
// 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>&)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,13 +31,13 @@ class CppUnit_API TestDecorator: public Test
|
|||||||
public:
|
public:
|
||||||
TestDecorator(Test* test);
|
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:
|
protected:
|
||||||
Test* _test;
|
Test* _test;
|
||||||
|
@ -64,13 +64,9 @@ public:
|
|||||||
class SynchronizationObject
|
class SynchronizationObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SynchronizationObject()
|
SynchronizationObject() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~SynchronizationObject()
|
virtual ~SynchronizationObject() = default;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void lock()
|
virtual void lock()
|
||||||
{
|
{
|
||||||
@ -138,7 +134,7 @@ inline void TestResult::addFailure(Test* test, CppUnitException* e)
|
|||||||
|
|
||||||
|
|
||||||
// Informs the result that a test will be started.
|
// Informs the result that a test will be started.
|
||||||
inline void TestResult::startTest(Test* test)
|
inline void TestResult::startTest(Test*)
|
||||||
{
|
{
|
||||||
ExclusiveZone zone(_syncObject);
|
ExclusiveZone zone(_syncObject);
|
||||||
_runTests++;
|
_runTests++;
|
||||||
@ -146,7 +142,7 @@ inline void TestResult::startTest(Test* test)
|
|||||||
|
|
||||||
|
|
||||||
// Informs the result that a test was completed.
|
// Informs the result that a test was completed.
|
||||||
inline void TestResult::endTest(Test* test)
|
inline void TestResult::endTest(Test*)
|
||||||
{
|
{
|
||||||
ExclusiveZone zone(_syncObject);
|
ExclusiveZone zone(_syncObject);
|
||||||
}
|
}
|
||||||
|
@ -37,8 +37,8 @@ namespace CppUnit {
|
|||||||
*/
|
*/
|
||||||
class CppUnit_API TestRunner
|
class CppUnit_API TestRunner
|
||||||
{
|
{
|
||||||
typedef std::pair<std::string, Test*> Mapping;
|
using Mapping = std::pair<std::string, Test *>;
|
||||||
typedef std::vector<Mapping> Mappings;
|
using Mappings = std::vector<Mapping>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TestRunner();
|
TestRunner();
|
||||||
|
@ -39,13 +39,13 @@ class CppUnit_API TestSuite: public Test
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
TestSuite(const std::string& name = "");
|
TestSuite(const std::string& name = "");
|
||||||
~TestSuite();
|
~TestSuite() override;
|
||||||
|
|
||||||
void run(TestResult* result, const Test::Callback& callback = nullptr);
|
void run(TestResult* result, const Test::Callback& callback = nullptr) override;
|
||||||
int countTestCases() const;
|
int countTestCases() const override;
|
||||||
void addTest(Test* test);
|
void addTest(Test* test);
|
||||||
std::string toString() const;
|
std::string toString() const override;
|
||||||
Test::Type getType() const;
|
Test::Type getType() const override;
|
||||||
|
|
||||||
virtual void deleteContents();
|
virtual void deleteContents();
|
||||||
|
|
||||||
|
@ -24,9 +24,9 @@ public:
|
|||||||
TextTestResult(std::ostream& ostr);
|
TextTestResult(std::ostream& ostr);
|
||||||
TextTestResult(std::ostream& ostr, const std::string& ignore);
|
TextTestResult(std::ostream& ostr, const std::string& ignore);
|
||||||
|
|
||||||
virtual void addError(Test* test, CppUnitException* e);
|
void addError(Test* test, CppUnitException* e) override;
|
||||||
virtual void addFailure(Test* test, CppUnitException* e);
|
void addFailure(Test* test, CppUnitException* e) override;
|
||||||
virtual void startTest(Test* test);
|
void startTest(Test* test) override;
|
||||||
virtual void print(std::ostream& stream);
|
virtual void print(std::ostream& stream);
|
||||||
virtual void printErrors(std::ostream& stream);
|
virtual void printErrors(std::ostream& stream);
|
||||||
virtual void printFailures(std::ostream& stream);
|
virtual void printFailures(std::ostream& stream);
|
||||||
|
@ -62,10 +62,8 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~Pair()
|
virtual ~Pair() = default;
|
||||||
/// Destroys the Pair.
|
/// Destroys the Pair.
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Pair& swap(Pair& other) noexcept
|
Pair& swap(Pair& other) noexcept
|
||||||
/// Swaps the content of the two Pairs.
|
/// Swaps the content of the two Pairs.
|
||||||
@ -122,62 +120,62 @@ public:
|
|||||||
return typeid(Pair<std::string>);
|
return typeid(Pair<std::string>);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Int8& val) const
|
void convert(Int8&) const
|
||||||
{
|
{
|
||||||
throw BadCastException("Cannot cast Pair type to Int8");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
throw BadCastException("Cannot cast Pair type to char");
|
||||||
}
|
}
|
||||||
@ -271,62 +269,62 @@ public:
|
|||||||
return typeid(Pair<int>);
|
return typeid(Pair<int>);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Int8& val) const
|
void convert(Int8&) const
|
||||||
{
|
{
|
||||||
throw BadCastException("Cannot cast Pair type to Int8");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
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");
|
throw BadCastException("Cannot cast Pair type to char");
|
||||||
}
|
}
|
||||||
|
@ -234,9 +234,9 @@ std::wstring EventLogChannel::findLibrary(const wchar_t* name)
|
|||||||
if (dll)
|
if (dll)
|
||||||
{
|
{
|
||||||
const DWORD maxPathLen = MAX_PATH + 1;
|
const DWORD maxPathLen = MAX_PATH + 1;
|
||||||
wchar_t name[maxPathLen];
|
wchar_t moduleName[maxPathLen];
|
||||||
int n = GetModuleFileNameW(dll, name, maxPathLen);
|
int n = GetModuleFileNameW(dll, moduleName, maxPathLen);
|
||||||
if (n > 0) path = name;
|
if (n > 0) path = moduleName;
|
||||||
FreeLibrary(dll);
|
FreeLibrary(dll);
|
||||||
}
|
}
|
||||||
return path;
|
return path;
|
||||||
|
@ -485,7 +485,7 @@ public:
|
|||||||
if (!_pPool)
|
if (!_pPool)
|
||||||
{
|
{
|
||||||
_pPool = new ThreadPool("default");
|
_pPool = new ThreadPool("default");
|
||||||
if (POCO_THREAD_STACK_SIZE > 0)
|
if constexpr (POCO_THREAD_STACK_SIZE > 0)
|
||||||
_pPool->setStackSize(POCO_THREAD_STACK_SIZE);
|
_pPool->setStackSize(POCO_THREAD_STACK_SIZE);
|
||||||
}
|
}
|
||||||
return _pPool;
|
return _pPool;
|
||||||
|
@ -146,7 +146,7 @@ private:
|
|||||||
try { TU POCO_UNUSED i; i = dMin.convert<TU>(); fail("must fail"); }
|
try { TU POCO_UNUSED i; i = dMin.convert<TU>(); fail("must fail"); }
|
||||||
catch (Poco::RangeException&) {}
|
catch (Poco::RangeException&) {}
|
||||||
|
|
||||||
if(sizeof(TS) == sizeof(TU))
|
if constexpr (sizeof(TS) == sizeof(TU))
|
||||||
{
|
{
|
||||||
TU iMax = std::numeric_limits<TU>::max();
|
TU iMax = std::numeric_limits<TU>::max();
|
||||||
Poco::Dynamic::Var dMax = iMax;
|
Poco::Dynamic::Var dMax = iMax;
|
||||||
|
Loading…
Reference in New Issue
Block a user