Update POCO library.

This commit is contained in:
Sandu Liviu Catalin committed 2023-03-23 20:19:11 +02:00
1 parent 8d15f4b6e9
commit 233fc103f9
2521 files changed
+257092 -72789

No files matched your search

+6 -6
View File
@@ -20,8 +20,8 @@ class CppUnit_API CppUnitException: public std::exception
/// descriptive strings through its what() method
{
public:
CppUnitException(const std::string& message = "",
long lineNumber = CPPUNIT_UNKNOWNLINENUMBER,
CppUnitException(const std::string& message = "",
long lineNumber = CPPUNIT_UNKNOWNLINENUMBER,
const std::string& fileName = CPPUNIT_UNKNOWNFILENAME);
CppUnitException(const std::string& message,
long lineNumber,
@@ -110,26 +110,26 @@ inline const char* CppUnitException::what() const throw ()
inline long CppUnitException::lineNumber() const
{
return _lineNumber;
return _lineNumber;
}
inline long CppUnitException::data1LineNumber() const
{
return _data1lineNumber;
return _data1lineNumber;
}
inline long CppUnitException::data2LineNumber() const
{
return _data2lineNumber;
return _data2lineNumber;
}
// The file in which the error occurred
inline const std::string& CppUnitException::fileName() const
{
return _fileName;
return _fileName;
}
+4 -4
View File
@@ -45,11 +45,11 @@ namespace CppUnit {
*
* see TestSuite
*/
template <class ClassUnderTest>
template <class ClassUnderTest>
class Orthodox: public TestCase
{
public:
Orthodox(): TestCase("Orthodox")
Orthodox(): TestCase("Orthodox")
{
}
@@ -60,7 +60,7 @@ protected:
// Run an orthodoxy test
template <class ClassUnderTest>
template <class ClassUnderTest>
void Orthodox<ClassUnderTest>::runTest()
{
// make sure we have a default constructor
@@ -90,7 +90,7 @@ void Orthodox<ClassUnderTest>::runTest()
// Exercise a call
template <class ClassUnderTest>
template <class ClassUnderTest>
ClassUnderTest Orthodox<ClassUnderTest>::call(ClassUnderTest object)
{
return object;
+6 -7
View File
@@ -10,14 +10,13 @@
#include "CppUnit/CppUnit.h"
#include "CppUnit/Guards.h"
#include "CppUnit/TestDecorator.h"
#include "CppUnit/TestResult.h"
namespace CppUnit {
class Test;
class TestResult;
/*
* A decorator that runs a test repeatedly.
@@ -29,13 +28,13 @@ class CppUnit_API RepeatedTest: public TestDecorator
REFERENCEOBJECT (RepeatedTest)
public:
RepeatedTest(Test* test, int timesRepeat): TestDecorator (test), _timesRepeat (timesRepeat)
RepeatedTest(Test* test, int timesRepeat): TestDecorator (test), _timesRepeat (timesRepeat)
{
}
int countTestCases();
std::string toString();
void run(TestResult *result);
void run(TestResult* result, const Test::Callback& callback = nullptr);
private:
const int _timesRepeat;
@@ -43,7 +42,7 @@ private:
// Counts the number of test cases that will be run by this test.
inline RepeatedTest::countTestCases ()
inline int RepeatedTest::countTestCases()
{
return TestDecorator::countTestCases() * _timesRepeat;
}
@@ -57,9 +56,9 @@ inline std::string RepeatedTest::toString()
// Runs a repeated test
inline void RepeatedTest::run(TestResult *result)
inline void RepeatedTest::run(TestResult *result, const Test::Callback& callback)
{
for (int n = 0; n < _timesRepeat; n++)
for (int n = 0; n < _timesRepeat; n++)
{
if (result->shouldStop())
break;
+7 -4
View File
@@ -10,6 +10,7 @@
#include "CppUnit/CppUnit.h"
#include <string>
#include <vector>
#include <functional>
namespace CppUnit {
@@ -33,8 +34,10 @@ public:
};
public:
using Callback = std::function<std::string(const std::exception&)>;
virtual ~Test() = 0;
virtual void run(TestResult* result) = 0;
virtual void run(TestResult* result, const Callback& callback = nullptr) = 0;
virtual int countTestCases() const = 0;
virtual std::string toString() const = 0;
virtual Test::Type getType() const = 0;
@@ -43,7 +46,7 @@ public:
const std::vector<std::string>& setup() const;
private:
std::vector<std::string> _setup;
std::vector<std::string> _setup;
};
@@ -53,7 +56,7 @@ inline Test::~Test()
// Runs a test and collects its result in a TestResult instance.
inline void Test::run(TestResult *result)
inline void Test::run(TestResult* result, const Callback& callback)
{
}
@@ -61,7 +64,7 @@ inline void Test::run(TestResult *result)
// Counts the number of test cases that will be run by this test.
inline int Test::countTestCases() const
{
return 0;
return 0;
}
+1 -1
View File
@@ -42,7 +42,7 @@ namespace CppUnit {
* }
*
* You can use a TestCaller to bind any test method on a TestCase
* class, as long as it returns accepts void and returns void.
* class, as long as it accepts void and returns void.
*
* See TestCase
*/
+24 -6
View File
@@ -90,7 +90,7 @@ public:
TestCase(const std::string& Name, Test::Type testType = Test::Normal);
~TestCase();
virtual void run(TestResult* result);
virtual void run(TestResult* result, const Test::Callback& callback = nullptr);
virtual TestResult* run();
virtual int countTestCases() const;
virtual std::string toString() const;
@@ -124,10 +124,17 @@ protected:
long data2LineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
void assertEquals(long expected,
long actual,
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>
void assertEquals(T1 expected,
T2 actual,
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME)
{
if (expected != actual)
assertImplementation(false, notEqualsMessage(expected, actual), lineNumber, fileName);
}
void assertEquals(double expected,
double actual,
@@ -140,13 +147,24 @@ protected:
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
void assertEquals(const char* expected,
const std::string& actual,
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
void assertEquals(const void* expected,
const void* actual,
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
std::string notEqualsMessage(long expected, long actual);
std::string notEqualsMessage(double expected, double actual);
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>
std::string notEqualsMessage(T1 expected, T2 actual)
{
return "expected: " + std::to_string(expected) + " but was: " + std::to_string(actual);
}
std::string notEqualsMessage(const void* expected, const void* actual);
std::string notEqualsMessage(const std::string& expected, const std::string& actual);
+1 -1
View File
@@ -35,7 +35,7 @@ public:
int countTestCases() const;
void run(TestResult* result);
void run(TestResult* result, const Test::Callback& callback = nullptr);
std::string toString() const;
+1 -1
View File
@@ -57,7 +57,7 @@ inline TestFailure::TestFailure(Test* failedTest, CppUnitException* thrownExcept
// Deletes the owned exception.
inline TestFailure::~TestFailure()
{
{
delete _thrownException;
}
+16 -16
View File
@@ -67,7 +67,7 @@ public:
SynchronizationObject()
{
}
virtual ~SynchronizationObject()
{
}
@@ -75,7 +75,7 @@ public:
virtual void lock()
{
}
virtual void unlock()
{
}
@@ -112,7 +112,7 @@ protected:
// Construct a TestResult
inline TestResult::TestResult(): _syncObject(new SynchronizationObject())
{
_runTests = 0;
_runTests = 0;
_stop = false;
}
@@ -121,7 +121,7 @@ inline TestResult::TestResult(): _syncObject(new SynchronizationObject())
// caused the error
inline void TestResult::addError(Test* test, CppUnitException* e)
{
ExclusiveZone zone(_syncObject);
ExclusiveZone zone(_syncObject);
_errors.push_back(new TestFailure(test, e));
}
@@ -130,7 +130,7 @@ inline void TestResult::addError(Test* test, CppUnitException* e)
// caused the failure.
inline void TestResult::addFailure(Test* test, CppUnitException* e)
{
ExclusiveZone zone(_syncObject);
ExclusiveZone zone(_syncObject);
_failures.push_back(new TestFailure(test, e));
}
@@ -138,7 +138,7 @@ inline void TestResult::addFailure(Test* test, CppUnitException* e)
// Informs the result that a test will be started.
inline void TestResult::startTest(Test* test)
{
ExclusiveZone zone(_syncObject);
ExclusiveZone zone(_syncObject);
_runTests++;
}
@@ -153,7 +153,7 @@ inline void TestResult::endTest(Test* test)
// Gets the number of run tests.
inline int TestResult::runTests()
{
ExclusiveZone zone(_syncObject);
ExclusiveZone zone(_syncObject);
return _runTests;
}
@@ -161,7 +161,7 @@ inline int TestResult::runTests()
// Gets the number of detected errors.
inline int TestResult::testErrors()
{
ExclusiveZone zone(_syncObject);
ExclusiveZone zone(_syncObject);
return (int) _errors.size();
}
@@ -169,7 +169,7 @@ inline int TestResult::testErrors()
// Gets the number of detected failures.
inline int TestResult::testFailures()
{
ExclusiveZone zone(_syncObject);
ExclusiveZone zone(_syncObject);
return (int) _failures.size();
}
@@ -177,15 +177,15 @@ inline int TestResult::testFailures()
// Returns whether the entire test was successful or not.
inline bool TestResult::wasSuccessful()
{
ExclusiveZone zone(_syncObject);
return _failures.size() == 0 && _errors.size () == 0;
ExclusiveZone zone(_syncObject);
return _failures.size() == 0 && _errors.size () == 0;
}
// Returns a std::vector of the errors.
inline std::vector<TestFailure*>& TestResult::errors()
{
ExclusiveZone zone(_syncObject);
ExclusiveZone zone(_syncObject);
return _errors;
}
@@ -193,7 +193,7 @@ inline std::vector<TestFailure*>& TestResult::errors()
// Returns a std::vector of the failures.
inline std::vector<TestFailure*>& TestResult::failures()
{
ExclusiveZone zone(_syncObject);
ExclusiveZone zone(_syncObject);
return _failures;
}
@@ -201,7 +201,7 @@ inline std::vector<TestFailure*>& TestResult::failures()
// Returns whether testing should be stopped
inline bool TestResult::shouldStop()
{
ExclusiveZone zone(_syncObject);
ExclusiveZone zone(_syncObject);
return _stop;
}
@@ -209,7 +209,7 @@ inline bool TestResult::shouldStop()
// Stop testing
inline void TestResult::stop()
{
ExclusiveZone zone(_syncObject);
ExclusiveZone zone(_syncObject);
_stop = true;
}
@@ -218,7 +218,7 @@ inline void TestResult::stop()
// TestResult assumes ownership of the object
inline void TestResult::setSynchronizationObject(SynchronizationObject* syncObject)
{
delete _syncObject;
delete _syncObject;
_syncObject = syncObject;
}
+15 -5
View File
@@ -8,20 +8,19 @@
#include "CppUnit/CppUnit.h"
#include "CppUnit/Test.h"
#include <vector>
#include <string>
#include <ostream>
#if defined(POCO_VXWORKS)
#include <cstdarg>
#endif
#include "Poco/Exception.h"
namespace CppUnit {
class Test;
/*
* A command line based tool to run tests.
* TestRunner expects as its only argument the name of a TestCase class.
@@ -46,7 +45,7 @@ public:
TestRunner(std::ostream& ostr);
~TestRunner();
bool run(const std::vector<std::string>& args);
bool run(const std::vector<std::string>& args, const Test::Callback& callback = nullptr);
void addTest(const std::string& name, Test* test);
protected:
@@ -85,6 +84,16 @@ private:
return runner.run(args) ? 0 : 1; \
}
#else
#define CppUnitPocoExceptionText(exc) \
CppUnit::Test::Callback exc = [] (const std::exception& ex) \
{ \
std::string text; \
const Poco::Exception* pEx = dynamic_cast<const Poco::Exception*>(&ex); \
if (pEx) text = pEx->displayText(); \
else text = ex.what(); \
return text; \
}
#define CppUnitMain(testCase) \
int main(int ac, char **av) \
{ \
@@ -93,7 +102,8 @@ private:
args.push_back(std::string(av[i])); \
CppUnit::TestRunner runner; \
runner.addTest(#testCase, testCase::suite()); \
return runner.run(args) ? 0 : 1; \
CppUnitPocoExceptionText(exc); \
return runner.run(args, exc) ? 0 : 1; \
}
#endif
+5 -5
View File
@@ -24,17 +24,17 @@ class CppUnit_API TestSetup: public TestDecorator
REFERENCEOBJECT (TestSetup)
public:
TestSetup(Test* test): TestDecorator(test)
TestSetup(Test* test): TestDecorator(test)
{
}
void run(TestResult* result);
protected:
void setUp()
void setUp()
{
}
void tearDown()
{
}
@@ -44,7 +44,7 @@ protected:
inline void TestSetup::run(TestResult* result)
{
setUp();
TestDecorator::run(result);
TestDecorator::run(result);
tearDown();
}
+3 -3
View File
@@ -41,14 +41,14 @@ public:
TestSuite(const std::string& name = "");
~TestSuite();
void run(TestResult* result);
void run(TestResult* result, const Test::Callback& callback = nullptr);
int countTestCases() const;
void addTest(Test* test);
std::string toString() const;
Test::Type getType() const;
virtual void deleteContents();
const std::vector<Test*> tests() const;
private:
@@ -80,7 +80,7 @@ inline void TestSuite::addTest(Test* test)
// Returns a std::string representation of the test suite.
inline std::string TestSuite::toString() const
{
return "suite " + _name;
return "suite " + _name;
}
// Returns the type of the test, see Test::Type
+1 -1
View File
@@ -31,7 +31,7 @@ public:
virtual void printErrors(std::ostream& stream);
virtual void printFailures(std::ostream& stream);
virtual void printHeader(std::ostream& stream);
protected:
std::string shortName(const std::string& testName);
void setup();
+10 -10
View File
@@ -32,26 +32,26 @@ inline std::string estring(std::string& expandedString)
// Create a std::string from an int
inline std::string estring(int number)
{
char buffer[50];
std::snprintf(buffer, sizeof(buffer), "%d", number);
return std::string (buffer);
char buffer[50];
std::snprintf(buffer, sizeof(buffer), "%d", number);
return std::string (buffer);
}
// Create a string from a long
inline std::string estring(long number)
{
char buffer[50];
std::snprintf(buffer, sizeof(buffer), "%ld", number);
return std::string (buffer);
char buffer[50];
std::snprintf(buffer, sizeof(buffer), "%ld", number);
return std::string (buffer);
}
// Create a std::string from a double
inline std::string estring(double number)
{
char buffer[50];
std::snprintf(buffer, sizeof(buffer), "%lf", number);
char buffer[50];
std::snprintf(buffer, sizeof(buffer), "%lf", number);
return std::string(buffer);
}
@@ -59,8 +59,8 @@ inline std::string estring(double number)
// Create a std::string from a double
inline std::string estring(const void* ptr)
{
char buffer[50];
std::snprintf(buffer, sizeof(buffer), "%p", ptr);
char buffer[50];
std::snprintf(buffer, sizeof(buffer), "%p", ptr);
return std::string(buffer);
}
-11
View File
@@ -1,11 +0,0 @@
//
// CppUnit.h
//
#ifndef Poco_CppUnit_CppUnit_INCLUDED
#define Poco_CppUnit_CppUnit_INCLUDED
#include "CppUnit/CppUnit.h"
#endif // Poco_CppUnit_CppUnit_INCLUDED
@@ -1,11 +0,0 @@
//
// CppUnitException.h
//
#ifndef Poco_CppUnit_CppUnitException_INCLUDED
#define Poco_CppUnit_CppUnitException_INCLUDED
#include "CppUnit/CppUnitException.h"
#endif // Poco_CppUnit_CppUnitException_INCLUDED
-11
View File
@@ -1,11 +0,0 @@
//
// Guards.h
//
#ifndef Poco_CppUnit_Guards_INCLUDED
#define Poco_CppUnit_Guards_INCLUDED
#include "CppUnit/Guards.h"
#endif // Poco_CppUnit_Guards_INCLUDED
-11
View File
@@ -1,11 +0,0 @@
//
// Orthodox.h
//
#ifndef Poco_CppUnit_Orthodox_INCLUDED
#define Poco_CppUnit__INCLUDED
#include "CppUnit/Orthodox.h"
#endif // Poco_CppUnit_Orthodox_INCLUDED
-11
View File
@@ -1,11 +0,0 @@
//
// RepeatedTest.h
//
#ifndef Poco_CppUnit_RepeatedTest_INCLUDED
#define Poco_CppUnit_RepeatedTest_INCLUDED
#include "CppUnit/RepeatedTest.h"
#endif // Poco_CppUnit_RepeatedTest_INCLUDED
-12
View File
@@ -1,12 +0,0 @@
//
// Test.h
//
#ifndef Poco_CppUnit_Test_INCLUDED
#define Poco_CppUnit_Test_INCLUDED
#include "CppUnit/Test.h"
#endif // Poco_CppUnit_Test_INCLUDED
-11
View File
@@ -1,11 +0,0 @@
//
// TestCaller.h
//
#ifndef Poco_CppUnit_TestCaller_INCLUDED
#define Poco_CppUnit_TestCaller_INCLUDED
#include "CppUnit/TestCaller.h"
#endif // Poco_CppUnit_TestCaller_INCLUDED
-11
View File
@@ -1,11 +0,0 @@
//
// TestCase.h
//
#ifndef Poco_CppUnit_TestCase_INCLUDED
#define Poco_CppUnit_TestCase_INCLUDED
#include "CppUnit/TestCase.h"
#endif // Poco_CppUnit_TestCase_INCLUDED
@@ -1,11 +0,0 @@
//
// TestDecorator.h
//
#ifndef Poco_CppUnit_TestDecorator_INCLUDED
#define Poco_CppUnit_TestDecorator_INCLUDED
#include "CppUnit/TestDecorator.h"
#endif // Poco_CppUnit_TestDecorator_INCLUDED
-13
View File
@@ -1,13 +0,0 @@
//
// TestFailure.h
//
#ifndef Poco_CppUnit_TestFailure_INCLUDED
#define Poco_CppUnit_TestFailure_INCLUDED
#include "CppUnit/TestFailure.h"
#endif // Poco_CppUnit_TestFailure_INCLUDED
-11
View File
@@ -1,11 +0,0 @@
//
// TestResult.h
//
#ifndef Poco_CppUnit_TestResult_INCLUDED
#define Poco_CppUnit_TestResult_INCLUDED
#include "CppUnit/TestResult.h"
#endif // Poco_CppUnit_TestResult_INCLUDED
-11
View File
@@ -1,11 +0,0 @@
//
// TestRunner.h
//
#ifndef Poco_CppUnit_TestRunner_INCLUDED
#define Poco_CppUnit_TestRunner_INCLUDED
#include "CppUnit/TestRunner.h"
#endif // Poco_CppUnit_TestRunner_INCLUDED
-11
View File
@@ -1,11 +0,0 @@
//
// TestSetup.h
//
#ifndef Poco_CppUnit_TestSetup_INCLUDED
#define Poco_CppUnit_TestSetup_INCLUDED
#include "CppUnit/TestSetup.h"
#endif // Poco_CppUnit_TestSetup_INCLUDED
-11
View File
@@ -1,11 +0,0 @@
//
// TestSuite.h
//
#ifndef Poco_CppUnit_TestSuite_INCLUDED
#define Poco_CppUnit_TestSuite_INCLUDED
#include "CppUnit/TestSuite.h"
#endif // Poco_CppUnit_TestSuite_INCLUDED
@@ -1,11 +0,0 @@
//
// TextTestResult.h
//
#ifndef Poco_CppUnit_TextTestResult_INCLUDED
#define Poco_CppUnit_TextTestResult_INCLUDED
#include "CppUnit/TextTestResult.h"
#endif // Poco_CppUnit_TextTestResult_INCLUDED
-11
View File
@@ -1,11 +0,0 @@
//
// estring.h
//
#ifndef Poco_CppUnit_estring_INCLUDED
#define Poco_CppUnit_estring_INCLUDED
#include "CppUnit/estring.h"
#endif // Poco_CppUnit_estring_INCLUDED