mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-08-08 09:01:48 +02:00
Major plugin refactor and cleanup.
Switched to POCO library for unified platform/library interface. Deprecated the external module API. It was creating more problems than solving. Removed most built-in libraries in favor of system libraries for easier maintenance. Cleaned and secured code with help from static analyzers.
This commit is contained in:
89
vendor/POCO/CppUnit/include/CppUnit/CppUnit.h
vendored
Normal file
89
vendor/POCO/CppUnit/include/CppUnit/CppUnit.h
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
//
|
||||
// CppUnit.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_CppUnit_INCLUDED
|
||||
#define CppUnit_CppUnit_INCLUDED
|
||||
|
||||
//
|
||||
// Ensure that POCO_DLL is default unless POCO_STATIC is defined
|
||||
//
|
||||
#if defined(_WIN32) && defined(_DLL)
|
||||
#if !defined(POCO_DLL) && !defined(POCO_STATIC)
|
||||
#define POCO_DLL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// The following block is the standard way of creating macros which make exporting
|
||||
// from a DLL simpler. All files within this DLL are compiled with the CppUnit_EXPORTS
|
||||
// symbol defined on the command line. this symbol should not be defined on any project
|
||||
// that uses this DLL. This way any other project whose source files include this file see
|
||||
// CppUnit_API functions as being imported from a DLL, wheras this DLL sees symbols
|
||||
// defined with this macro as being exported.
|
||||
//
|
||||
#if defined(_WIN32) && defined(POCO_DLL)
|
||||
#if defined(CppUnit_EXPORTS)
|
||||
#define CppUnit_API __declspec(dllexport)
|
||||
#else
|
||||
#define CppUnit_API __declspec(dllimport)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(CppUnit_API)
|
||||
#if defined (__GNUC__) && (__GNUC__ >= 4)
|
||||
#define CppUnit_API __attribute__ ((visibility ("default")))
|
||||
#else
|
||||
#define CppUnit_API
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//
|
||||
// Automatically link Data library.
|
||||
//
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(POCO_DLL)
|
||||
#if defined(_DEBUG)
|
||||
#define POCO_LIB_SUFFIX "d.lib"
|
||||
#else
|
||||
#define POCO_LIB_SUFFIX ".lib"
|
||||
#endif
|
||||
#elif defined(_DLL)
|
||||
#if defined(_DEBUG)
|
||||
#define POCO_LIB_SUFFIX "mdd.lib"
|
||||
#else
|
||||
#define POCO_LIB_SUFFIX "md.lib"
|
||||
#endif
|
||||
#else
|
||||
#if defined(_DEBUG)
|
||||
#define POCO_LIB_SUFFIX "mtd.lib"
|
||||
#else
|
||||
#define POCO_LIB_SUFFIX "mt.lib"
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(_MSC_VER) && !defined(POCO_NO_AUTOMATIC_LIBS)
|
||||
#if !defined(CppUnit_EXPORTS)
|
||||
#pragma comment(lib, "CppUnit" POCO_LIB_SUFFIX)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
// Turn off some annoying warnings
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4786) // identifier truncation warning
|
||||
#pragma warning(disable:4503) // decorated name length exceeded - mainly a problem with STLPort
|
||||
#pragma warning(disable:4018) // signed/unsigned comparison
|
||||
#pragma warning(disable:4284) // return type for operator -> is not UDT
|
||||
#pragma warning(disable:4251) // ... needs to have dll-interface warning
|
||||
#pragma warning(disable:4273)
|
||||
#pragma warning(disable:4275) // ... non dll-interface class used as base for dll-interface class
|
||||
#endif
|
||||
|
||||
|
||||
#endif // CppUnit_CppUnit_INCLUDED
|
139
vendor/POCO/CppUnit/include/CppUnit/CppUnitException.h
vendored
Normal file
139
vendor/POCO/CppUnit/include/CppUnit/CppUnitException.h
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
//
|
||||
// CppUnitException.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_CppUnitException_INCLUDED
|
||||
#define CppUnit_CppUnitException_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include <exception>
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
class CppUnit_API CppUnitException: public std::exception
|
||||
/// CppUnitException is an exception that serves
|
||||
/// descriptive strings through its what() method
|
||||
{
|
||||
public:
|
||||
CppUnitException(const std::string& message = "",
|
||||
long lineNumber = CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CPPUNIT_UNKNOWNFILENAME);
|
||||
CppUnitException(const std::string& message,
|
||||
long lineNumber,
|
||||
long data1lineNumber,
|
||||
const std::string& fileName);
|
||||
CppUnitException(const std::string& message,
|
||||
long lineNumber,
|
||||
long data1lineNumber,
|
||||
long data2lineNumber,
|
||||
const std::string& fileName);
|
||||
CppUnitException(const CppUnitException& other);
|
||||
virtual ~CppUnitException() throw();
|
||||
|
||||
CppUnitException& operator = (const CppUnitException& other);
|
||||
|
||||
const char* what() const throw ();
|
||||
|
||||
long lineNumber() const;
|
||||
long data1LineNumber() const;
|
||||
long data2LineNumber() const;
|
||||
const std::string& fileName() const;
|
||||
|
||||
static const std::string CPPUNIT_UNKNOWNFILENAME;
|
||||
static const int CPPUNIT_UNKNOWNLINENUMBER;
|
||||
|
||||
private:
|
||||
std::string _message;
|
||||
long _lineNumber;
|
||||
long _data1lineNumber;
|
||||
long _data2lineNumber;
|
||||
std::string _fileName;
|
||||
};
|
||||
|
||||
|
||||
inline CppUnitException::CppUnitException(const CppUnitException& other): exception (other)
|
||||
{
|
||||
_message = other._message;
|
||||
_lineNumber = other._lineNumber;
|
||||
_data1lineNumber = other._data1lineNumber;
|
||||
_data2lineNumber = other._data2lineNumber;
|
||||
_fileName = other._fileName;
|
||||
}
|
||||
|
||||
|
||||
inline CppUnitException::CppUnitException (const std::string& message, long lineNumber, const std::string& fileName): _message(message), _lineNumber(lineNumber), _data1lineNumber(CPPUNIT_UNKNOWNLINENUMBER), _data2lineNumber(CPPUNIT_UNKNOWNLINENUMBER), _fileName(fileName)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
inline CppUnitException::CppUnitException (const std::string& message, long lineNumber, long data1lineNumber, const std::string& fileName): _message(message), _lineNumber(lineNumber), _data1lineNumber(data1lineNumber), _data2lineNumber(CPPUNIT_UNKNOWNLINENUMBER), _fileName(fileName)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
inline CppUnitException::CppUnitException (const std::string& message, long lineNumber, long data1lineNumber, long data2lineNumber, const std::string& fileName): _message(message), _lineNumber(lineNumber), _data1lineNumber(data1lineNumber), _data2lineNumber(data2lineNumber), _fileName(fileName)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
inline CppUnitException::~CppUnitException () throw()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
inline CppUnitException& CppUnitException::operator = (const CppUnitException& other)
|
||||
{
|
||||
exception::operator= (other);
|
||||
|
||||
if (&other != this)
|
||||
{
|
||||
_message = other._message;
|
||||
_lineNumber = other._lineNumber;
|
||||
_data1lineNumber = other._data1lineNumber;
|
||||
_data2lineNumber = other._data2lineNumber;
|
||||
_fileName = other._fileName;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline const char* CppUnitException::what() const throw ()
|
||||
{
|
||||
return _message.c_str();
|
||||
}
|
||||
|
||||
|
||||
inline long CppUnitException::lineNumber() const
|
||||
{
|
||||
return _lineNumber;
|
||||
}
|
||||
|
||||
|
||||
inline long CppUnitException::data1LineNumber() const
|
||||
{
|
||||
return _data1lineNumber;
|
||||
}
|
||||
|
||||
|
||||
inline long CppUnitException::data2LineNumber() const
|
||||
{
|
||||
return _data2lineNumber;
|
||||
}
|
||||
|
||||
|
||||
// The file in which the error occurred
|
||||
inline const std::string& CppUnitException::fileName() const
|
||||
{
|
||||
return _fileName;
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#endif // CppUnit_CppUnitException_INCLUDED
|
17
vendor/POCO/CppUnit/include/CppUnit/Guards.h
vendored
Normal file
17
vendor/POCO/CppUnit/include/CppUnit/Guards.h
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// Guards.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_Guards_INCLUDED
|
||||
#define CppUnit_Guards_INCLUDED
|
||||
|
||||
|
||||
// Prevent copy construction and assignment for a class
|
||||
#define REFERENCEOBJECT(className) \
|
||||
private: \
|
||||
className(const className& other); \
|
||||
className& operator = (const className& other);
|
||||
|
||||
|
||||
#endif // CppUnit_Guards_INCLUDED
|
103
vendor/POCO/CppUnit/include/CppUnit/Orthodox.h
vendored
Normal file
103
vendor/POCO/CppUnit/include/CppUnit/Orthodox.h
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
//
|
||||
// Orthodox.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_Orthodox_INCLUDED
|
||||
#define CppUnit_Orthodox_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
/*
|
||||
* Orthodox performs a simple set of tests on an arbitary
|
||||
* class to make sure that it supports at least the
|
||||
* following operations:
|
||||
*
|
||||
* default construction - constructor
|
||||
* equality/inequality - operator== && operator!=
|
||||
* assignment - operator=
|
||||
* negation - operator!
|
||||
* safe passage - copy construction
|
||||
*
|
||||
* If operations for each of these are not declared
|
||||
* the template will not instantiate. If it does
|
||||
* instantiate, tests are performed to make sure
|
||||
* that the operations have correct semantics.
|
||||
*
|
||||
* Adding an orthodox test to a suite is very
|
||||
* easy:
|
||||
*
|
||||
* public: Test *suite () {
|
||||
* TestSuite *suiteOfTests = new TestSuite;
|
||||
* suiteOfTests->addTest (new ComplexNumberTest ("testAdd");
|
||||
* suiteOfTests->addTest (new TestCaller<Orthodox<Complex> > ());
|
||||
* return suiteOfTests;
|
||||
* }
|
||||
*
|
||||
* Templated test cases be very useful when you are want to
|
||||
* make sure that a group of classes have the same form.
|
||||
*
|
||||
* see TestSuite
|
||||
*/
|
||||
template <class ClassUnderTest>
|
||||
class Orthodox: public TestCase
|
||||
{
|
||||
public:
|
||||
Orthodox(): TestCase("Orthodox")
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
ClassUnderTest call(ClassUnderTest object);
|
||||
void runTest ();
|
||||
};
|
||||
|
||||
|
||||
// Run an orthodoxy test
|
||||
template <class ClassUnderTest>
|
||||
void Orthodox<ClassUnderTest>::runTest()
|
||||
{
|
||||
// make sure we have a default constructor
|
||||
ClassUnderTest a, b, c;
|
||||
|
||||
// make sure we have an equality operator
|
||||
assert (a == b);
|
||||
|
||||
// check the inverse
|
||||
b.operator= (a.operator! ());
|
||||
assert (a != b);
|
||||
|
||||
// double inversion
|
||||
b = !!a;
|
||||
assert (a == b);
|
||||
|
||||
// invert again
|
||||
b = !a;
|
||||
|
||||
// check calls
|
||||
c = a;
|
||||
assert (c == call (a));
|
||||
|
||||
c = b;
|
||||
assert (c == call (b));
|
||||
}
|
||||
|
||||
|
||||
// Exercise a call
|
||||
template <class ClassUnderTest>
|
||||
ClassUnderTest Orthodox<ClassUnderTest>::call(ClassUnderTest object)
|
||||
{
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#endif // CppUnit_Orthodox_INCLUDED
|
75
vendor/POCO/CppUnit/include/CppUnit/RepeatedTest.h
vendored
Normal file
75
vendor/POCO/CppUnit/include/CppUnit/RepeatedTest.h
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
//
|
||||
// RepeatedTest.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_RepeatedTest_INCLUDED
|
||||
#define CppUnit_RepeatedTest_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include "CppUnit/Guards.h"
|
||||
#include "CppUnit/TestDecorator.h"
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
class Test;
|
||||
class TestResult;
|
||||
|
||||
|
||||
/*
|
||||
* A decorator that runs a test repeatedly.
|
||||
* Does not assume ownership of the test it decorates
|
||||
*
|
||||
*/
|
||||
class CppUnit_API RepeatedTest: public TestDecorator
|
||||
{
|
||||
REFERENCEOBJECT (RepeatedTest)
|
||||
|
||||
public:
|
||||
RepeatedTest(Test* test, int timesRepeat): TestDecorator (test), _timesRepeat (timesRepeat)
|
||||
{
|
||||
}
|
||||
|
||||
int countTestCases();
|
||||
std::string toString();
|
||||
void run(TestResult *result);
|
||||
|
||||
private:
|
||||
const int _timesRepeat;
|
||||
};
|
||||
|
||||
|
||||
// Counts the number of test cases that will be run by this test.
|
||||
inline RepeatedTest::countTestCases ()
|
||||
{
|
||||
return TestDecorator::countTestCases() * _timesRepeat;
|
||||
}
|
||||
|
||||
|
||||
// Returns the name of the test instance.
|
||||
inline std::string RepeatedTest::toString()
|
||||
{
|
||||
return TestDecorator::toString() + " (repeated)";
|
||||
}
|
||||
|
||||
|
||||
// Runs a repeated test
|
||||
inline void RepeatedTest::run(TestResult *result)
|
||||
{
|
||||
for (int n = 0; n < _timesRepeat; n++)
|
||||
{
|
||||
if (result->shouldStop())
|
||||
break;
|
||||
|
||||
TestDecorator::run(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#endif // CppUnit_RepeatedTest_INCLUDED
|
97
vendor/POCO/CppUnit/include/CppUnit/Test.h
vendored
Normal file
97
vendor/POCO/CppUnit/include/CppUnit/Test.h
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
//
|
||||
// Test.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_Test_INCLUDED
|
||||
#define CppUnit_Test_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
class TestResult;
|
||||
|
||||
|
||||
/*
|
||||
* A Test can be run and collect its results.
|
||||
* See TestResult.
|
||||
*
|
||||
*/
|
||||
class CppUnit_API Test
|
||||
{
|
||||
public:
|
||||
enum Type {
|
||||
Suite, // Only set on CppUnit::TestSuite
|
||||
Normal, // Default TestCase always run
|
||||
Long // Such TestCase will only be run if the `-long` command line argument is set
|
||||
};
|
||||
|
||||
public:
|
||||
virtual ~Test() = 0;
|
||||
virtual void run(TestResult* result) = 0;
|
||||
virtual int countTestCases() const = 0;
|
||||
virtual std::string toString() const = 0;
|
||||
virtual Test::Type getType() const = 0;
|
||||
|
||||
void addSetup(const std::vector<std::string>& setup);
|
||||
const std::vector<std::string>& setup() const;
|
||||
|
||||
private:
|
||||
std::vector<std::string> _setup;
|
||||
};
|
||||
|
||||
|
||||
inline Test::~Test()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Runs a test and collects its result in a TestResult instance.
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
// Returns the name of the test instance.
|
||||
inline std::string Test::toString() const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
// Returns the type of the test, see Test::Type
|
||||
inline Test::Type Test::getType() const
|
||||
{
|
||||
return Test::Normal;
|
||||
}
|
||||
|
||||
|
||||
inline void Test::addSetup(const std::vector<std::string>& setup)
|
||||
{
|
||||
_setup = setup;
|
||||
}
|
||||
|
||||
|
||||
inline const std::vector<std::string>& Test::setup() const
|
||||
{
|
||||
return _setup;
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#endif // CppUnit_Test_INCLUDED
|
103
vendor/POCO/CppUnit/include/CppUnit/TestCaller.h
vendored
Normal file
103
vendor/POCO/CppUnit/include/CppUnit/TestCaller.h
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
//
|
||||
// TestCaller.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_TestCaller_INCLUDED
|
||||
#define CppUnit_TestCaller_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include "Guards.h"
|
||||
#include "TestCase.h"
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
/*
|
||||
* A test caller provides access to a test case method
|
||||
* on a test case class. Test callers are useful when
|
||||
* you want to run an individual test or add it to a
|
||||
* suite.
|
||||
*
|
||||
* Here is an example:
|
||||
*
|
||||
* class MathTest : public TestCase {
|
||||
* ...
|
||||
* public:
|
||||
* void setUp ();
|
||||
* void tearDown ();
|
||||
*
|
||||
* void testAdd ();
|
||||
* void testSubtract ();
|
||||
* };
|
||||
*
|
||||
* Test *MathTest::suite () {
|
||||
* TestSuite *suite = new TestSuite;
|
||||
*
|
||||
* suite->addTest (new TestCaller<MathTest> ("testAdd", testAdd));
|
||||
* return suite;
|
||||
* }
|
||||
*
|
||||
* You can use a TestCaller to bind any test method on a TestCase
|
||||
* class, as long as it returns accepts void and returns void.
|
||||
*
|
||||
* See TestCase
|
||||
*/
|
||||
template <class Fixture>
|
||||
class TestCaller: public TestCase
|
||||
{
|
||||
REFERENCEOBJECT (TestCaller)
|
||||
|
||||
typedef void (Fixture::*TestMethod)();
|
||||
|
||||
public:
|
||||
TestCaller(const std::string& name, TestMethod test, Test::Type testType = Test::Normal):
|
||||
TestCase(name, testType),
|
||||
_test(test),
|
||||
_fixture(new Fixture(name))
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
void runTest()
|
||||
{
|
||||
(_fixture.get()->*_test)();
|
||||
}
|
||||
|
||||
void setUp()
|
||||
{
|
||||
if (!setup().empty())
|
||||
_fixture.get()->addSetup(setup());
|
||||
_fixture.get()->setUp();
|
||||
}
|
||||
|
||||
void tearDown()
|
||||
{
|
||||
_fixture.get()->tearDown();
|
||||
}
|
||||
|
||||
private:
|
||||
TestMethod _test;
|
||||
std::unique_ptr<Fixture> _fixture;
|
||||
};
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#define CppUnit_addTest(suite, cls, mth) \
|
||||
suite->addTest(new CppUnit::TestCaller<cls>(#mth, &cls::mth))
|
||||
|
||||
#define CppUnit_addLongTest(suite, cls, mth) \
|
||||
suite->addTest(new CppUnit::TestCaller<cls>(#mth, &cls::mth, CppUnit::Test::Long))
|
||||
|
||||
#define CppUnit_addQualifiedTest(suite, cls, mth) \
|
||||
suite->addTest(new CppUnit::TestCaller<cls>(#cls"::"#mth, &cls::mth))
|
||||
|
||||
#define CppUnit_addLongQualifiedTest(suite, cls, mth) \
|
||||
suite->addTest(new CppUnit::TestCaller<cls>(#cls"::"#mth, &cls::mth, CppUnit::Test::Long))
|
||||
|
||||
#endif // CppUnit_TestCaller_INCLUDED
|
291
vendor/POCO/CppUnit/include/CppUnit/TestCase.h
vendored
Normal file
291
vendor/POCO/CppUnit/include/CppUnit/TestCase.h
vendored
Normal file
@@ -0,0 +1,291 @@
|
||||
//
|
||||
// TestCase.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_TestCase_INCLUDED
|
||||
#define CppUnit_TestCase_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include "CppUnit/Guards.h"
|
||||
#include "CppUnit/Test.h"
|
||||
#include "CppUnit/CppUnitException.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <typeinfo>
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
class TestResult;
|
||||
|
||||
|
||||
/*
|
||||
* A test case defines the fixture to run multiple tests. To define a test case
|
||||
* 1) implement a subclass of TestCase
|
||||
* 2) define instance variables that store the state of the fixture
|
||||
* 3) initialize the fixture state by overriding setUp
|
||||
* 4) clean-up after a test by overriding tearDown.
|
||||
*
|
||||
* Each test runs in its own fixture so there
|
||||
* can be no side effects among test runs.
|
||||
* Here is an example:
|
||||
*
|
||||
* class MathTest : public TestCase {
|
||||
* protected: int m_value1;
|
||||
* protected: int m_value2;
|
||||
*
|
||||
* public: MathTest (std::string name)
|
||||
* : TestCase (name) {
|
||||
* }
|
||||
*
|
||||
* protected: void setUp () {
|
||||
* m_value1 = 2;
|
||||
* m_value2 = 3;
|
||||
* }
|
||||
* }
|
||||
*
|
||||
*
|
||||
* For each test implement a method which interacts
|
||||
* with the fixture. Verify the expected results with assertions specified
|
||||
* by calling assert on the expression you want to test:
|
||||
*
|
||||
* protected: void testAdd () {
|
||||
* int result = value1 + value2;
|
||||
* assert (result == 5);
|
||||
* }
|
||||
*
|
||||
* Once the methods are defined you can run them. To do this, use
|
||||
* a TestCaller.
|
||||
*
|
||||
* Test *test = new TestCaller<MathTest>("testAdd", MathTest::testAdd);
|
||||
* test->run ();
|
||||
*
|
||||
*
|
||||
* The tests to be run can be collected into a TestSuite. CppUnit provides
|
||||
* different test runners which can run a test suite and collect the results.
|
||||
* The test runners expect a static method suite as the entry
|
||||
* point to get a test to run.
|
||||
*
|
||||
* public: static MathTest::suite () {
|
||||
* TestSuite *suiteOfTests = new TestSuite;
|
||||
* suiteOfTests->addTest(new TestCaller<MathTest>("testAdd", testAdd));
|
||||
* suiteOfTests->addTest(new TestCaller<MathTest>("testDivideByZero", testDivideByZero));
|
||||
* return suiteOfTests;
|
||||
* }
|
||||
*
|
||||
* Note that the caller of suite assumes lifetime control
|
||||
* for the returned suite.
|
||||
*
|
||||
* see TestResult, TestSuite and TestCaller
|
||||
*
|
||||
*/
|
||||
class CppUnit_API TestCase: public Test
|
||||
{
|
||||
REFERENCEOBJECT (TestCase)
|
||||
|
||||
public:
|
||||
TestCase(const std::string& Name, Test::Type testType = Test::Normal);
|
||||
~TestCase();
|
||||
|
||||
virtual void run(TestResult* result);
|
||||
virtual TestResult* run();
|
||||
virtual int countTestCases() const;
|
||||
virtual std::string toString() const;
|
||||
virtual Test::Type getType() const;
|
||||
void setType(Test::Type testType);
|
||||
const std::string& name() const;
|
||||
|
||||
virtual void setUp();
|
||||
virtual void setUp(const std::vector<std::string>& setup);
|
||||
virtual void tearDown();
|
||||
|
||||
protected:
|
||||
virtual void runTest();
|
||||
TestResult* defaultResult();
|
||||
|
||||
void assertImplementation(bool condition,
|
||||
const std::string& conditionExpression = "",
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
void loop1assertImplementation(bool condition,
|
||||
const std::string& conditionExpression = "",
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
long dataLineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
void loop2assertImplementation(bool condition,
|
||||
const std::string& conditionExpression = "",
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
long data1LineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
long data2LineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
void assertEquals(long expected,
|
||||
long actual,
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
void assertEquals(double expected,
|
||||
double actual,
|
||||
double delta,
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
void assertEquals(const std::string& 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);
|
||||
std::string notEqualsMessage(const void* expected, const void* actual);
|
||||
std::string notEqualsMessage(const std::string& expected, const std::string& actual);
|
||||
|
||||
void assertNotNull(const void* pointer,
|
||||
const std::string& pointerExpression = "",
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
void assertNull(const void* pointer,
|
||||
const std::string& pointerExpression = "",
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
void fail(const std::string& message = "",
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
void warn(const std::string& message = "",
|
||||
long lineNumber = CppUnitException::CPPUNIT_UNKNOWNLINENUMBER,
|
||||
const std::string& fileName = CppUnitException::CPPUNIT_UNKNOWNFILENAME);
|
||||
|
||||
|
||||
private:
|
||||
const std::string _name;
|
||||
Test::Type _type;
|
||||
};
|
||||
|
||||
|
||||
// Constructs a test case
|
||||
inline TestCase::TestCase(const std::string& name, Test::Type testType)
|
||||
: _name (name)
|
||||
{
|
||||
setType(testType);
|
||||
}
|
||||
|
||||
|
||||
// Destructs a test case
|
||||
inline TestCase::~TestCase()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Returns a count of all the tests executed
|
||||
inline int TestCase::countTestCases() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// Returns the name of the test case
|
||||
inline const std::string& TestCase::name() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
|
||||
// A hook for fixture set up
|
||||
inline void TestCase::setUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// A hook for fixture set up with command line arguments
|
||||
inline void TestCase::setUp(const std::vector<std::string>& setup)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// A hook for fixture tear down
|
||||
inline void TestCase::tearDown()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Returns the name of the test case instance
|
||||
inline std::string TestCase::toString() const
|
||||
{
|
||||
const std::type_info& thisClass = typeid(*this);
|
||||
return std::string(thisClass.name()) + "." + name();
|
||||
}
|
||||
|
||||
|
||||
// Returns the type of the test, see Test::Type
|
||||
inline Test::Type TestCase::getType() const
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
|
||||
// Set the type of the test, see Test::Type
|
||||
inline void TestCase::setType(Test::Type testType)
|
||||
{
|
||||
_type = testType;
|
||||
}
|
||||
|
||||
|
||||
// A set of macros which allow us to get the line number
|
||||
// and file name at the point of an error.
|
||||
// Just goes to show that preprocessors do have some
|
||||
// redeeming qualities.
|
||||
|
||||
// for backward compatibility only
|
||||
// (may conflict with C assert, use at your own risk)
|
||||
#undef assert
|
||||
#define assert(condition) \
|
||||
(this->assertImplementation((condition), (#condition), __LINE__, __FILE__))
|
||||
|
||||
#define assertTrue(condition) \
|
||||
(this->assertImplementation((condition), (#condition), __LINE__, __FILE__))
|
||||
|
||||
#define assertFalse(condition) \
|
||||
(this->assertImplementation(!(condition), (#condition), __LINE__, __FILE__))
|
||||
|
||||
#define loop_1_assert(data1line, condition) \
|
||||
(this->loop1assertImplementation((condition), (#condition), __LINE__, data1line, __FILE__))
|
||||
|
||||
#define loop_2_assert(data1line, data2line, condition) \
|
||||
(this->loop2assertImplementation((condition), (#condition), __LINE__, data1line, data2line, __FILE__))
|
||||
|
||||
#define assertEqualDelta(expected, actual, delta) \
|
||||
(this->assertEquals((expected), (actual), (delta), __LINE__, __FILE__))
|
||||
|
||||
#define assertEqual(expected, actual) \
|
||||
(this->assertEquals((expected), (actual), __LINE__, __FILE__))
|
||||
|
||||
#define assertNullPtr(ptr) \
|
||||
(this->assertNull((ptr), #ptr, __LINE__, __FILE__))
|
||||
|
||||
#define assertNotNullPtr(ptr) \
|
||||
(this->assertNotNull((ptr), #ptr, __LINE__, __FILE__))
|
||||
|
||||
#define failmsg(msg) \
|
||||
(this->fail(msg, __LINE__, __FILE__))
|
||||
|
||||
#define warnmsg(msg) \
|
||||
(this->fail(msg, __LINE__, __FILE__))
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#endif // CppUnit_TestCase_INCLUDED
|
50
vendor/POCO/CppUnit/include/CppUnit/TestDecorator.h
vendored
Normal file
50
vendor/POCO/CppUnit/include/CppUnit/TestDecorator.h
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// TestDecorator.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_TestDecorator_INCLUDED
|
||||
#define CppUnit_TestDecorator_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include "CppUnit/Guards.h"
|
||||
#include "CppUnit/Test.h"
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
class TestResult;
|
||||
|
||||
|
||||
/*
|
||||
* A Decorator for Tests
|
||||
*
|
||||
* Does not assume ownership of the test it decorates
|
||||
*
|
||||
*/
|
||||
class CppUnit_API TestDecorator: public Test
|
||||
{
|
||||
REFERENCEOBJECT(TestDecorator)
|
||||
|
||||
public:
|
||||
TestDecorator(Test* test);
|
||||
|
||||
virtual ~TestDecorator();
|
||||
|
||||
int countTestCases() const;
|
||||
|
||||
void run(TestResult* result);
|
||||
|
||||
std::string toString() const;
|
||||
|
||||
protected:
|
||||
Test* _test;
|
||||
};
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#endif // CppUnit_TestDecorator_INCLUDED
|
84
vendor/POCO/CppUnit/include/CppUnit/TestFailure.h
vendored
Normal file
84
vendor/POCO/CppUnit/include/CppUnit/TestFailure.h
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
//
|
||||
// TestFailure.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_TestFailure_INCLUDED
|
||||
#define CppUnit_TestFailure_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include "CppUnit/CppUnitException.h"
|
||||
#include "CppUnit/Guards.h"
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
class Test;
|
||||
|
||||
|
||||
/*
|
||||
* A TestFailure collects a failed test together with
|
||||
* the caught exception.
|
||||
*
|
||||
* TestFailure assumes lifetime control for any exception
|
||||
* passed to it. The lifetime of tests is handled by
|
||||
* their TestSuite (if they have been added to one) or
|
||||
* whomever creates them.
|
||||
*
|
||||
* see TestResult
|
||||
* see TestSuite
|
||||
*
|
||||
*/
|
||||
class CppUnit_API TestFailure
|
||||
{
|
||||
REFERENCEOBJECT (TestFailure)
|
||||
|
||||
public:
|
||||
TestFailure(Test* failedTest, CppUnitException* thrownException);
|
||||
~TestFailure();
|
||||
|
||||
Test* failedTest();
|
||||
CppUnitException* thrownException();
|
||||
std::string toString();
|
||||
|
||||
protected:
|
||||
Test* _failedTest;
|
||||
CppUnitException *_thrownException;
|
||||
};
|
||||
|
||||
|
||||
// Constructs a TestFailure with the given test and exception.
|
||||
inline TestFailure::TestFailure(Test* failedTest, CppUnitException* thrownException): _failedTest(failedTest), _thrownException(thrownException)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Deletes the owned exception.
|
||||
inline TestFailure::~TestFailure()
|
||||
{
|
||||
delete _thrownException;
|
||||
}
|
||||
|
||||
|
||||
// Gets the failed test.
|
||||
inline Test* TestFailure::failedTest()
|
||||
{
|
||||
return _failedTest;
|
||||
}
|
||||
|
||||
|
||||
// Gets the thrown exception.
|
||||
inline CppUnitException* TestFailure::thrownException()
|
||||
{
|
||||
return _thrownException;
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#endif // CppUnit_TestFailure_INCLUDED
|
||||
|
||||
|
229
vendor/POCO/CppUnit/include/CppUnit/TestResult.h
vendored
Normal file
229
vendor/POCO/CppUnit/include/CppUnit/TestResult.h
vendored
Normal file
@@ -0,0 +1,229 @@
|
||||
//
|
||||
// TestResult.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_TestResult_INCLUDED
|
||||
#define CppUnit_TestResult_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include "CppUnit/Guards.h"
|
||||
#include "CppUnit/TestFailure.h"
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
class CppUnitException;
|
||||
class Test;
|
||||
|
||||
|
||||
/*
|
||||
* A TestResult collects the results of executing a test case. It is an
|
||||
* instance of the Collecting Parameter pattern.
|
||||
*
|
||||
* The test framework distinguishes between failures and errors.
|
||||
* A failure is anticipated and checked for with assertions. Errors are
|
||||
* unanticipated problems signified by exceptions that are not generated
|
||||
* by the framework.
|
||||
*
|
||||
* TestResult supplies a template method 'setSynchronizationObject ()'
|
||||
* so that subclasses can provide mutual exclusion in the face of multiple
|
||||
* threads. This can be useful when tests execute in one thread and
|
||||
* they fill a subclass of TestResult which effects change in another
|
||||
* thread. To have mutual exclusion, override setSynchronizationObject ()
|
||||
* and make sure that you create an instance of ExclusiveZone at the
|
||||
* beginning of each method.
|
||||
*
|
||||
* see Test
|
||||
*/
|
||||
class CppUnit_API TestResult
|
||||
{
|
||||
REFERENCEOBJECT (TestResult)
|
||||
|
||||
public:
|
||||
TestResult();
|
||||
virtual ~TestResult();
|
||||
|
||||
virtual void addError(Test* test, CppUnitException* e);
|
||||
virtual void addFailure(Test* test, CppUnitException* e);
|
||||
virtual void startTest(Test* test);
|
||||
virtual void endTest(Test* test);
|
||||
virtual int runTests();
|
||||
virtual int testErrors();
|
||||
virtual int testFailures();
|
||||
virtual bool wasSuccessful();
|
||||
virtual bool shouldStop();
|
||||
virtual void stop();
|
||||
|
||||
virtual std::vector<TestFailure*>& errors();
|
||||
virtual std::vector<TestFailure*>& failures();
|
||||
|
||||
class SynchronizationObject
|
||||
{
|
||||
public:
|
||||
SynchronizationObject()
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~SynchronizationObject()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void lock()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void unlock()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class ExclusiveZone
|
||||
{
|
||||
SynchronizationObject* m_syncObject;
|
||||
|
||||
public:
|
||||
ExclusiveZone(SynchronizationObject* syncObject): m_syncObject(syncObject)
|
||||
{
|
||||
m_syncObject->lock();
|
||||
}
|
||||
|
||||
~ExclusiveZone()
|
||||
{
|
||||
m_syncObject->unlock();
|
||||
}
|
||||
};
|
||||
|
||||
protected:
|
||||
virtual void setSynchronizationObject(SynchronizationObject* syncObject);
|
||||
|
||||
std::vector<TestFailure*> _errors;
|
||||
std::vector<TestFailure*> _failures;
|
||||
int _runTests;
|
||||
bool _stop;
|
||||
SynchronizationObject* _syncObject;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// Construct a TestResult
|
||||
inline TestResult::TestResult(): _syncObject(new SynchronizationObject())
|
||||
{
|
||||
_runTests = 0;
|
||||
_stop = false;
|
||||
}
|
||||
|
||||
|
||||
// Adds an error to the list of errors. The passed in exception
|
||||
// caused the error
|
||||
inline void TestResult::addError(Test* test, CppUnitException* e)
|
||||
{
|
||||
ExclusiveZone zone(_syncObject);
|
||||
_errors.push_back(new TestFailure(test, e));
|
||||
}
|
||||
|
||||
|
||||
// Adds a failure to the list of failures. The passed in exception
|
||||
// caused the failure.
|
||||
inline void TestResult::addFailure(Test* test, CppUnitException* e)
|
||||
{
|
||||
ExclusiveZone zone(_syncObject);
|
||||
_failures.push_back(new TestFailure(test, e));
|
||||
}
|
||||
|
||||
|
||||
// Informs the result that a test will be started.
|
||||
inline void TestResult::startTest(Test* test)
|
||||
{
|
||||
ExclusiveZone zone(_syncObject);
|
||||
_runTests++;
|
||||
}
|
||||
|
||||
|
||||
// Informs the result that a test was completed.
|
||||
inline void TestResult::endTest(Test* test)
|
||||
{
|
||||
ExclusiveZone zone(_syncObject);
|
||||
}
|
||||
|
||||
|
||||
// Gets the number of run tests.
|
||||
inline int TestResult::runTests()
|
||||
{
|
||||
ExclusiveZone zone(_syncObject);
|
||||
return _runTests;
|
||||
}
|
||||
|
||||
|
||||
// Gets the number of detected errors.
|
||||
inline int TestResult::testErrors()
|
||||
{
|
||||
ExclusiveZone zone(_syncObject);
|
||||
return (int) _errors.size();
|
||||
}
|
||||
|
||||
|
||||
// Gets the number of detected failures.
|
||||
inline int TestResult::testFailures()
|
||||
{
|
||||
ExclusiveZone zone(_syncObject);
|
||||
return (int) _failures.size();
|
||||
}
|
||||
|
||||
|
||||
// Returns whether the entire test was successful or not.
|
||||
inline bool TestResult::wasSuccessful()
|
||||
{
|
||||
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);
|
||||
return _errors;
|
||||
}
|
||||
|
||||
|
||||
// Returns a std::vector of the failures.
|
||||
inline std::vector<TestFailure*>& TestResult::failures()
|
||||
{
|
||||
ExclusiveZone zone(_syncObject);
|
||||
return _failures;
|
||||
}
|
||||
|
||||
|
||||
// Returns whether testing should be stopped
|
||||
inline bool TestResult::shouldStop()
|
||||
{
|
||||
ExclusiveZone zone(_syncObject);
|
||||
return _stop;
|
||||
}
|
||||
|
||||
|
||||
// Stop testing
|
||||
inline void TestResult::stop()
|
||||
{
|
||||
ExclusiveZone zone(_syncObject);
|
||||
_stop = true;
|
||||
}
|
||||
|
||||
|
||||
// Accept a new synchronization object for protection of this instance
|
||||
// TestResult assumes ownership of the object
|
||||
inline void TestResult::setSynchronizationObject(SynchronizationObject* syncObject)
|
||||
{
|
||||
delete _syncObject;
|
||||
_syncObject = syncObject;
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#endif // CppUnit_TestResult_INCLUDED
|
101
vendor/POCO/CppUnit/include/CppUnit/TestRunner.h
vendored
Normal file
101
vendor/POCO/CppUnit/include/CppUnit/TestRunner.h
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
//
|
||||
// TestRunner.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_TestRunner_INCLUDED
|
||||
#define CppUnit_TestRunner_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <ostream>
|
||||
#if defined(POCO_VXWORKS)
|
||||
#include <cstdarg>
|
||||
#endif
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
class Test;
|
||||
|
||||
|
||||
/*
|
||||
* A command line based tool to run tests.
|
||||
* TestRunner expects as its only argument the name of a TestCase class.
|
||||
* TestRunner prints out a trace as the tests are executed followed by a
|
||||
* summary at the end.
|
||||
*
|
||||
* You can add to the tests that the TestRunner knows about by
|
||||
* making additional calls to "addTest (...)" in main.
|
||||
*
|
||||
* Here is the synopsis:
|
||||
*
|
||||
* TestRunner [-all] [-long] [-print] [-wait] ExampleTestCase
|
||||
*
|
||||
*/
|
||||
class CppUnit_API TestRunner
|
||||
{
|
||||
typedef std::pair<std::string, Test*> Mapping;
|
||||
typedef std::vector<Mapping> Mappings;
|
||||
|
||||
public:
|
||||
TestRunner();
|
||||
TestRunner(std::ostream& ostr);
|
||||
~TestRunner();
|
||||
|
||||
bool run(const std::vector<std::string>& args);
|
||||
void addTest(const std::string& name, Test* test);
|
||||
|
||||
protected:
|
||||
void printBanner();
|
||||
void print(const std::string& name, Test* pTest, int indent);
|
||||
Test* find(const std::string& name, Test* pTest, const std::string& testName);
|
||||
int collectAllTestCases(Test* pTest, std::vector<Test*>& tests);
|
||||
|
||||
private:
|
||||
std::ostream& _ostr;
|
||||
Mappings _mappings;
|
||||
};
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#if defined(POCO_VXWORKS)
|
||||
#define CppUnitMain(testCase) \
|
||||
int testCase##Runner(const char* arg0, ...) \
|
||||
{ \
|
||||
std::vector<std::string> args; \
|
||||
args.push_back(#testCase "Runner"); \
|
||||
args.push_back(std::string(arg0)); \
|
||||
va_list vargs; \
|
||||
va_start(vargs, arg0); \
|
||||
const char* arg = va_arg(vargs, const char*); \
|
||||
while (arg) \
|
||||
{ \
|
||||
args.push_back(std::string(arg)); \
|
||||
arg = va_arg(vargs, const char*); \
|
||||
} \
|
||||
va_end(vargs); \
|
||||
CppUnit::TestRunner runner; \
|
||||
runner.addTest(#testCase, testCase::suite()); \
|
||||
return runner.run(args) ? 0 : 1; \
|
||||
}
|
||||
#else
|
||||
#define CppUnitMain(testCase) \
|
||||
int main(int ac, char **av) \
|
||||
{ \
|
||||
std::vector<std::string> args; \
|
||||
for (int i = 0; i < ac; ++i) \
|
||||
args.push_back(std::string(av[i])); \
|
||||
CppUnit::TestRunner runner; \
|
||||
runner.addTest(#testCase, testCase::suite()); \
|
||||
return runner.run(args) ? 0 : 1; \
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // CppUnit_TestRunner_INCLUDED
|
55
vendor/POCO/CppUnit/include/CppUnit/TestSetup.h
vendored
Normal file
55
vendor/POCO/CppUnit/include/CppUnit/TestSetup.h
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// TestSetup.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_TestSetup_INCLUDED
|
||||
#define CppUnit_TestSetup_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include "CppUnit/Guards.h"
|
||||
#include "CppUnit/TestDecorator.h"
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
class Test;
|
||||
class TestResult;
|
||||
|
||||
|
||||
class CppUnit_API TestSetup: public TestDecorator
|
||||
{
|
||||
REFERENCEOBJECT (TestSetup)
|
||||
|
||||
public:
|
||||
TestSetup(Test* test): TestDecorator(test)
|
||||
{
|
||||
}
|
||||
|
||||
void run(TestResult* result);
|
||||
|
||||
protected:
|
||||
void setUp()
|
||||
{
|
||||
}
|
||||
|
||||
void tearDown()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
inline void TestSetup::run(TestResult* result)
|
||||
{
|
||||
setUp();
|
||||
TestDecorator::run(result);
|
||||
tearDown();
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#endif // CppUnit_TestSetup_INCLUDED
|
102
vendor/POCO/CppUnit/include/CppUnit/TestSuite.h
vendored
Normal file
102
vendor/POCO/CppUnit/include/CppUnit/TestSuite.h
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
//
|
||||
// TestSuite.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_TestSuite_INCLUDED
|
||||
#define CppUnit_TestSuite_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include "CppUnit/Guards.h"
|
||||
#include "CppUnit/Test.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
class TestResult;
|
||||
|
||||
|
||||
/*
|
||||
* A TestSuite is a Composite of Tests.
|
||||
* It runs a collection of test cases. Here is an example.
|
||||
*
|
||||
* TestSuite *suite= new TestSuite();
|
||||
* suite->addTest(new TestCaller<MathTest> ("testAdd", testAdd));
|
||||
* suite->addTest(new TestCaller<MathTest> ("testDivideByZero", testDivideByZero));
|
||||
*
|
||||
* Note that TestSuites assume lifetime
|
||||
* control for any tests added to them.
|
||||
*
|
||||
* see Test and TestCaller
|
||||
*/
|
||||
class CppUnit_API TestSuite: public Test
|
||||
{
|
||||
REFERENCEOBJECT (TestSuite)
|
||||
|
||||
public:
|
||||
TestSuite(const std::string& name = "");
|
||||
~TestSuite();
|
||||
|
||||
void run(TestResult* result);
|
||||
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:
|
||||
std::vector<Test*> _tests;
|
||||
const std::string _name;
|
||||
};
|
||||
|
||||
|
||||
// Default constructor
|
||||
inline TestSuite::TestSuite(const std::string& name): _name(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Destructor
|
||||
inline TestSuite::~TestSuite()
|
||||
{
|
||||
deleteContents();
|
||||
}
|
||||
|
||||
|
||||
// Adds a test to the suite.
|
||||
inline void TestSuite::addTest(Test* test)
|
||||
{
|
||||
_tests.push_back(test);
|
||||
}
|
||||
|
||||
|
||||
// Returns a std::string representation of the test suite.
|
||||
inline std::string TestSuite::toString() const
|
||||
{
|
||||
return "suite " + _name;
|
||||
}
|
||||
|
||||
// Returns the type of the test, see Test::Type
|
||||
inline Test::Type TestSuite::getType() const
|
||||
{
|
||||
return Test::Suite;
|
||||
}
|
||||
|
||||
// Returns all tests
|
||||
inline const std::vector<Test*> TestSuite::tests() const
|
||||
{
|
||||
return _tests;
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#endif // CppUnit_TestSuite_INCLUDED
|
57
vendor/POCO/CppUnit/include/CppUnit/TextTestResult.h
vendored
Normal file
57
vendor/POCO/CppUnit/include/CppUnit/TextTestResult.h
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// TextTestResult.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_TextTestResult_INCLUDED
|
||||
#define CppUnit_TextTestResult_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include "CppUnit/TestResult.h"
|
||||
#include <set>
|
||||
#include <ostream>
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
class CppUnit_API TextTestResult: public TestResult
|
||||
{
|
||||
public:
|
||||
TextTestResult();
|
||||
TextTestResult(const std::string& ignore);
|
||||
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);
|
||||
virtual void print(std::ostream& stream);
|
||||
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();
|
||||
void ignoring(const std::string ignore);
|
||||
|
||||
private:
|
||||
std::ostream& _ostr;
|
||||
std::set<std::string> _ignored;
|
||||
};
|
||||
|
||||
|
||||
/* insertion operator for easy output */
|
||||
inline std::ostream& operator<< (std::ostream& stream, TextTestResult& result)
|
||||
{
|
||||
result.print(stream);
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#endif // CppUnit_TextTestResult_INCLUDED
|
71
vendor/POCO/CppUnit/include/CppUnit/estring.h
vendored
Normal file
71
vendor/POCO/CppUnit/include/CppUnit/estring.h
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// estring.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef CppUnit_estring_INCLUDED
|
||||
#define CppUnit_estring_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
|
||||
|
||||
// Create a std::string from a const char pointer
|
||||
inline std::string estring(const char *cstring)
|
||||
{
|
||||
return std::string(cstring);
|
||||
}
|
||||
|
||||
|
||||
// Create a std::string from a std::string (for uniformities' sake)
|
||||
inline std::string estring(std::string& expandedString)
|
||||
{
|
||||
return 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);
|
||||
}
|
||||
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
||||
// Create a std::string from a double
|
||||
inline std::string estring(double number)
|
||||
{
|
||||
char buffer[50];
|
||||
std::snprintf(buffer, sizeof(buffer), "%lf", number);
|
||||
return std::string(buffer);
|
||||
}
|
||||
|
||||
|
||||
// Create a std::string from a double
|
||||
inline std::string estring(const void* ptr)
|
||||
{
|
||||
char buffer[50];
|
||||
std::snprintf(buffer, sizeof(buffer), "%p", ptr);
|
||||
return std::string(buffer);
|
||||
}
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#endif // CppUnit_estring_INCLUDED
|
11
vendor/POCO/CppUnit/include/Poco/CppUnit/CppUnit.h
vendored
Normal file
11
vendor/POCO/CppUnit/include/Poco/CppUnit/CppUnit.h
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// CppUnit.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef Poco_CppUnit_CppUnit_INCLUDED
|
||||
#define Poco_CppUnit_CppUnit_INCLUDED
|
||||
|
||||
#include "CppUnit/CppUnit.h"
|
||||
|
||||
#endif // Poco_CppUnit_CppUnit_INCLUDED
|
11
vendor/POCO/CppUnit/include/Poco/CppUnit/CppUnitException.h
vendored
Normal file
11
vendor/POCO/CppUnit/include/Poco/CppUnit/CppUnitException.h
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// CppUnitException.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef Poco_CppUnit_CppUnitException_INCLUDED
|
||||
#define Poco_CppUnit_CppUnitException_INCLUDED
|
||||
|
||||
#include "CppUnit/CppUnitException.h"
|
||||
|
||||
#endif // Poco_CppUnit_CppUnitException_INCLUDED
|
11
vendor/POCO/CppUnit/include/Poco/CppUnit/Guards.h
vendored
Normal file
11
vendor/POCO/CppUnit/include/Poco/CppUnit/Guards.h
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// Guards.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef Poco_CppUnit_Guards_INCLUDED
|
||||
#define Poco_CppUnit_Guards_INCLUDED
|
||||
|
||||
#include "CppUnit/Guards.h"
|
||||
|
||||
#endif // Poco_CppUnit_Guards_INCLUDED
|
11
vendor/POCO/CppUnit/include/Poco/CppUnit/Orthodox.h
vendored
Normal file
11
vendor/POCO/CppUnit/include/Poco/CppUnit/Orthodox.h
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// Orthodox.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef Poco_CppUnit_Orthodox_INCLUDED
|
||||
#define Poco_CppUnit__INCLUDED
|
||||
|
||||
#include "CppUnit/Orthodox.h"
|
||||
|
||||
#endif // Poco_CppUnit_Orthodox_INCLUDED
|
11
vendor/POCO/CppUnit/include/Poco/CppUnit/RepeatedTest.h
vendored
Normal file
11
vendor/POCO/CppUnit/include/Poco/CppUnit/RepeatedTest.h
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// RepeatedTest.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef Poco_CppUnit_RepeatedTest_INCLUDED
|
||||
#define Poco_CppUnit_RepeatedTest_INCLUDED
|
||||
|
||||
#include "CppUnit/RepeatedTest.h"
|
||||
|
||||
#endif // Poco_CppUnit_RepeatedTest_INCLUDED
|
12
vendor/POCO/CppUnit/include/Poco/CppUnit/Test.h
vendored
Normal file
12
vendor/POCO/CppUnit/include/Poco/CppUnit/Test.h
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// Test.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef Poco_CppUnit_Test_INCLUDED
|
||||
#define Poco_CppUnit_Test_INCLUDED
|
||||
|
||||
|
||||
#include "CppUnit/Test.h"
|
||||
|
||||
#endif // Poco_CppUnit_Test_INCLUDED
|
11
vendor/POCO/CppUnit/include/Poco/CppUnit/TestCaller.h
vendored
Normal file
11
vendor/POCO/CppUnit/include/Poco/CppUnit/TestCaller.h
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// TestCaller.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef Poco_CppUnit_TestCaller_INCLUDED
|
||||
#define Poco_CppUnit_TestCaller_INCLUDED
|
||||
|
||||
#include "CppUnit/TestCaller.h"
|
||||
|
||||
#endif // Poco_CppUnit_TestCaller_INCLUDED
|
11
vendor/POCO/CppUnit/include/Poco/CppUnit/TestCase.h
vendored
Normal file
11
vendor/POCO/CppUnit/include/Poco/CppUnit/TestCase.h
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// TestCase.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef Poco_CppUnit_TestCase_INCLUDED
|
||||
#define Poco_CppUnit_TestCase_INCLUDED
|
||||
|
||||
#include "CppUnit/TestCase.h"
|
||||
|
||||
#endif // Poco_CppUnit_TestCase_INCLUDED
|
11
vendor/POCO/CppUnit/include/Poco/CppUnit/TestDecorator.h
vendored
Normal file
11
vendor/POCO/CppUnit/include/Poco/CppUnit/TestDecorator.h
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// TestDecorator.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef Poco_CppUnit_TestDecorator_INCLUDED
|
||||
#define Poco_CppUnit_TestDecorator_INCLUDED
|
||||
|
||||
#include "CppUnit/TestDecorator.h"
|
||||
|
||||
#endif // Poco_CppUnit_TestDecorator_INCLUDED
|
13
vendor/POCO/CppUnit/include/Poco/CppUnit/TestFailure.h
vendored
Normal file
13
vendor/POCO/CppUnit/include/Poco/CppUnit/TestFailure.h
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// TestFailure.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef Poco_CppUnit_TestFailure_INCLUDED
|
||||
#define Poco_CppUnit_TestFailure_INCLUDED
|
||||
|
||||
#include "CppUnit/TestFailure.h"
|
||||
|
||||
#endif // Poco_CppUnit_TestFailure_INCLUDED
|
||||
|
||||
|
11
vendor/POCO/CppUnit/include/Poco/CppUnit/TestResult.h
vendored
Normal file
11
vendor/POCO/CppUnit/include/Poco/CppUnit/TestResult.h
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// TestResult.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef Poco_CppUnit_TestResult_INCLUDED
|
||||
#define Poco_CppUnit_TestResult_INCLUDED
|
||||
|
||||
#include "CppUnit/TestResult.h"
|
||||
|
||||
#endif // Poco_CppUnit_TestResult_INCLUDED
|
11
vendor/POCO/CppUnit/include/Poco/CppUnit/TestRunner.h
vendored
Normal file
11
vendor/POCO/CppUnit/include/Poco/CppUnit/TestRunner.h
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// TestRunner.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef Poco_CppUnit_TestRunner_INCLUDED
|
||||
#define Poco_CppUnit_TestRunner_INCLUDED
|
||||
|
||||
#include "CppUnit/TestRunner.h"
|
||||
|
||||
#endif // Poco_CppUnit_TestRunner_INCLUDED
|
11
vendor/POCO/CppUnit/include/Poco/CppUnit/TestSetup.h
vendored
Normal file
11
vendor/POCO/CppUnit/include/Poco/CppUnit/TestSetup.h
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// TestSetup.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef Poco_CppUnit_TestSetup_INCLUDED
|
||||
#define Poco_CppUnit_TestSetup_INCLUDED
|
||||
|
||||
#include "CppUnit/TestSetup.h"
|
||||
|
||||
#endif // Poco_CppUnit_TestSetup_INCLUDED
|
11
vendor/POCO/CppUnit/include/Poco/CppUnit/TestSuite.h
vendored
Normal file
11
vendor/POCO/CppUnit/include/Poco/CppUnit/TestSuite.h
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// TestSuite.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef Poco_CppUnit_TestSuite_INCLUDED
|
||||
#define Poco_CppUnit_TestSuite_INCLUDED
|
||||
|
||||
#include "CppUnit/TestSuite.h"
|
||||
|
||||
#endif // Poco_CppUnit_TestSuite_INCLUDED
|
11
vendor/POCO/CppUnit/include/Poco/CppUnit/TextTestResult.h
vendored
Normal file
11
vendor/POCO/CppUnit/include/Poco/CppUnit/TextTestResult.h
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// TextTestResult.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef Poco_CppUnit_TextTestResult_INCLUDED
|
||||
#define Poco_CppUnit_TextTestResult_INCLUDED
|
||||
|
||||
#include "CppUnit/TextTestResult.h"
|
||||
|
||||
#endif // Poco_CppUnit_TextTestResult_INCLUDED
|
11
vendor/POCO/CppUnit/include/Poco/CppUnit/estring.h
vendored
Normal file
11
vendor/POCO/CppUnit/include/Poco/CppUnit/estring.h
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// estring.h
|
||||
//
|
||||
|
||||
|
||||
#ifndef Poco_CppUnit_estring_INCLUDED
|
||||
#define Poco_CppUnit_estring_INCLUDED
|
||||
|
||||
#include "CppUnit/estring.h"
|
||||
|
||||
#endif // Poco_CppUnit_estring_INCLUDED
|
Reference in New Issue
Block a user