removing old trunk files

This commit is contained in:
Aleksandar Fabijanic
2012-04-23 00:43:14 +00:00
parent 2ce14cafb5
commit f9b60296f7
4754 changed files with 0 additions and 943568 deletions

View File

@@ -1,56 +0,0 @@
//
// CppUnit.h
//
// $Id: //poco/Main/CppUnit/include/CppUnit/CppUnit.h#9 $
//
#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)
#define CppUnit_API
#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

View File

@@ -1,141 +0,0 @@
//
// CppUnitException.h
//
// $Id: //poco/Main/CppUnit/include/CppUnit/CppUnitException.h#8 $
//
#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

View File

@@ -1,236 +0,0 @@
//
// DataDrivenTestCaller.h
//
// $Id: //poco/Main/CppUnit/include/CppUnit/DataDrivenTestCaller.h#3 $
//
#ifndef CppUnit_DataDrivenTestCaller_INCLUDED
#define CppUnit_DataDrivenTestCaller_INCLUDED
#include "CppUnit/CppUnit.h"
#include "CppUnit/TestCase.h"
#include "CppUnit/TestSuite.h"
#include "CppUnit/CppUnitException.h"
#include <iostream>
#include <fstream>
#include "Poco/File.h"
#include "Poco/Path.h"
#include "Poco/Exception.h"
#include <algorithm>
#include <functional>
#include <map>
namespace CppUnit {
/*
* A data driven test case defines the fixture to run a single test with varying input streams.
* A data driven test is assumed to take an input stream and write its result to an output stream
* which can then be compared to a reference output.
* To do data driven testing
* 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.
*
* Each test method must implement the following method signature:
*
* void dotest(std::istream& in, std::ostream& out)
*
* Add the test in the suite() method of your test case with the CppUnit_addDataTest macro:
*
* CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("WebWidgetsTest");
* CppUnit_addDataTest(pSuite, WebWidgetsTest, doTest, "tests/", "temp/");
*
* CppUnit_addDataTest expects 5 input parameters:
* - the first is always a pointer to the suite where the tests are added
* - the second parameter is the name of your test class
* - the third parameter is the test method
* - the fourth parameter contains the directory where the tests are stored. Note that
* we assume a certain directory structure inside the tests folder.
* Input files are stored in the subfolder tests/data, the reference results are stored
* in the subfolder tests/results. The matching of reference to input data happens automatically via the file
* base name. For each input a separate test is inserted with the base name as the name of the test.
* - the last parameter defines where we should generate temporary files
*
* Note that the test framework guarantees that input and output stream for the test
* method are valid and open. It will also perform the comparision (i.e. does the produced output matches
* the reference output) and close the input and outout streams.
*
*/
template <class Fixture>
class DataDrivenTestCaller: public TestCase
{
REFERENCEOBJECT (DataDrivenTestCaller)
typedef void (Fixture::*TestMethod)(std::istream& in, std::ostream& out);
public:
DataDrivenTestCaller(const std::string& name, TestMethod test, const Poco::File& in, const Poco::File& out, const Poco::File& expectedResult):
TestCase(name),
_test(test),
_fixture(new Fixture(name)),
_in(in),
_out(out),
_result(expectedResult)
{
}
protected:
void runTest()
{
std::ifstream in(_in.path().c_str(), std::ios::binary);
if (!in)
throw Poco::FileNotFoundException("Failed to open file " + _in.path());
std::ofstream out(_out.path().c_str(), std::ios::binary);
if (!out)
throw Poco::CreateFileException("Failed to open file for writing " + _out.path());
try
{
(_fixture.get()->*_test)(in, out);
}
catch(Poco::Exception&)
{
// maybe an exception is wanted
// compare with ref file
if (_result.exists() && _result.getSize() > 0)
{
in.close();
out.close();
throw;
}
}
in.close();
out.close();
// now compare
std::ifstream inRes(_out.path().c_str(), std::ios::binary);
std::ifstream refRes(_result.path().c_str(), std::ios::binary);
if (!inRes || !refRes)
throw Poco::FileNotFoundException("Can't compare with reference file. Reference result missing or file not created " + _out.path());
while (!inRes.eof())
{
int c = inRes.get();
int c2 = refRes.get();
if (c != c2)
throw Poco::DataException("Created file does not match reference file" + _out.path());
}
}
void setUp()
{
_fixture.get()->setUp();
}
void tearDown()
{
_fixture.get()->tearDown();
}
public:
static void addDirectoryTest(TestSuite* pSuite, typename DataDrivenTestCaller::TestMethod method, const std::string& rootDir, const Poco::Path& tempD)
/// rootDir contains the name of the root directory (not a path). We will start searching for the root dir in the
/// current directory and go up until we are at the root level
/// The root dir must contain a subfolder /data and /results. tempDir will be used to store temporary files
{
Poco::Path dir(rootDir);
std::string cwd(Poco::Path::current());
Poco::Path cwdPath(cwd);
Poco::Path p(cwdPath, dir);
p.makeFile();
bool found = false;
while (!found && p.depth() > 0)
{
Poco::File f(p);
if (f.exists())
found = true;
else
p.popDirectory();
}
if (!found)
return;
Poco::Path data(p, "data");
data.makeDirectory();
Poco::File dataDir(data);
if (!dataDir.exists())
return;
Poco::Path results(p, "results");
results.makeDirectory();
Poco::File resDir(results);
if (!resDir.exists())
return;
Poco::Path temp(tempD);
Poco::File tempDir(temp);
temp.makeDirectory();
tempDir.createDirectories();
std::vector<std::string> inputFiles;
dataDir.list(inputFiles);
std::vector<std::string> referenceFiles;
resDir.list(referenceFiles);
std::sort(inputFiles.begin(), inputFiles.end(), std::less<std::string>());
std::sort(referenceFiles.begin(), referenceFiles.end(), std::less<std::string>());
typedef std::pair<Poco::File, Poco::File> InputRef;
std::map<std::string, InputRef> pairs;
// now map input to reference via basename
std::vector<std::string>::const_iterator itIn = inputFiles.begin();
std::vector<std::string>::const_iterator itInEnd = inputFiles.end();
for (; itIn != itInEnd; ++itIn)
{
std::cout << *itIn << std::endl;
Poco::Path inTmp(data, *itIn);
Poco::File inFTmp(inTmp);
if (!inTmp.getBaseName().empty())
pairs.insert(std::make_pair(inTmp.getBaseName(), std::make_pair(inFTmp, Poco::File())));
}
std::vector<std::string>::const_iterator itRef = referenceFiles.begin();
std::vector<std::string>::const_iterator itRefEnd = referenceFiles.end();
for (; itRef != itRefEnd; ++itRef)
{
Poco::Path refTmp(results, *itRef);
Poco::File refFTmp(refTmp);
std::map<std::string, InputRef>::iterator it = pairs.find(refTmp.getBaseName());
if (it != pairs.end())
it->second.second = refFTmp;
}
std::map<std::string, InputRef>::const_iterator itP = pairs.begin();
std::map<std::string, InputRef>::const_iterator itPEnd = pairs.end();
for (; itP != itPEnd; ++itP)
{
std::string fileName;
if (!itP->second.second.path().empty())
{
Poco::Path refTmp(itP->second.second.path());
fileName = refTmp.getFileName();
}
else
fileName = itP->first + ".tmp";
Poco::Path outTmp(temp, fileName);
Poco::File outFTmp(outTmp);
pSuite->addTest(new DataDrivenTestCaller(itP->first, method, itP->second.first, outFTmp, itP->second.second));
}
}
private:
TestMethod _test;
std::auto_ptr<Fixture> _fixture;
Poco::File _in;
Poco::File _out;
Poco::File _result;
};
} // namespace CppUnit
#define CppUnit_addDataTest(suite, cls, mth, rootDir, tempDir) \
CppUnit::DataDrivenTestCaller<cls>::addDirectoryTest(suite, &cls::mth, rootDir, tempDir)
#endif // DataDrivenTestCaller_INCLUDED

View File

@@ -1,19 +0,0 @@
//
// Guards.h
//
// $Id: //poco/Main/CppUnit/include/CppUnit/Guards.h#5 $
//
#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

View File

@@ -1,105 +0,0 @@
//
// Orthodox.h
//
// $Id: //poco/Main/CppUnit/include/CppUnit/Orthodox.h#7 $
//
#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

View File

@@ -1,77 +0,0 @@
//
// RepeatedTest.h
//
// $Id: //poco/Main/CppUnit/include/CppUnit/RepeatedTest.h#7 $
//
#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

View File

@@ -1,65 +0,0 @@
//
// Test.h
//
// $Id: //poco/Main/CppUnit/include/CppUnit/Test.h#7 $
//
#ifndef CppUnit_Test_INCLUDED
#define CppUnit_Test_INCLUDED
#include "CppUnit/CppUnit.h"
#include <string>
namespace CppUnit {
class TestResult;
/*
* A Test can be run and collect its results.
* See TestResult.
*
*/
class CppUnit_API Test
{
public:
virtual ~Test() = 0;
virtual void run(TestResult* result) = 0;
virtual int countTestCases() = 0;
virtual std::string toString() = 0;
};
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()
{
return 0;
}
// Returns the name of the test instance.
inline std::string Test::toString()
{
return "";
}
} // namespace CppUnit
#endif // CppUnit_Test_INCLUDED

View File

@@ -1,95 +0,0 @@
//
// TestCaller.h
//
// $Id: //poco/Main/CppUnit/include/CppUnit/TestCaller.h#8 $
//
#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):
TestCase(name),
_test(test),
_fixture(new Fixture(name))
{
}
protected:
void runTest()
{
(_fixture.get()->*_test)();
}
void setUp()
{
_fixture.get()->setUp();
}
void tearDown()
{
_fixture.get()->tearDown();
}
private:
TestMethod _test;
std::auto_ptr<Fixture> _fixture;
};
} // namespace CppUnit
#define CppUnit_addTest(suite, cls, mth) \
suite->addTest(new CppUnit::TestCaller<cls>(#mth, &cls::mth))
#endif // CppUnit_TestCaller_INCLUDED

View File

@@ -1,249 +0,0 @@
//
// TestCase.h
//
// $Id: //poco/Main/CppUnit/include/CppUnit/TestCase.h#8 $
//
#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 <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);
~TestCase();
virtual void run(TestResult* result);
virtual TestResult* run();
virtual int countTestCases();
const std::string& name() const;
std::string toString();
virtual void 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);
private:
const std::string _name;
};
// Constructs a test case
inline TestCase::TestCase(const std::string& name): _name (name)
{
}
// Destructs a test case
inline TestCase::~TestCase()
{
}
// Returns a count of all the tests executed
inline int TestCase::countTestCases()
{
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 tear down
inline void TestCase::tearDown()
{
}
// Returns the name of the test case instance
inline std::string TestCase::toString()
{
const std::type_info& thisClass = typeid(*this);
return std::string(thisClass.name()) + "." + name();
}
// 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.
#undef assert
#define assert(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__))
} // namespace CppUnit
#endif // CppUnit_TestCase_INCLUDED

View File

@@ -1,52 +0,0 @@
//
// TestDecorator.h
//
// $Id: //poco/Main/CppUnit/include/CppUnit/TestDecorator.h#7 $
//
#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();
void run(TestResult* result);
std::string toString();
protected:
Test* _test;
};
} // namespace CppUnit
#endif // CppUnit_TestDecorator_INCLUDED

View File

@@ -1,86 +0,0 @@
//
// TestFailure.h
//
// $Id: //poco/Main/CppUnit/include/CppUnit/TestFailure.h#7 $
//
#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

View File

@@ -1,231 +0,0 @@
//
// TestResult.h
//
// $Id: //poco/Main/CppUnit/include/CppUnit/TestResult.h#7 $
//
#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

View File

@@ -1,103 +0,0 @@
//
// TestRunner.h
//
// $Id: //poco/Main/CppUnit/include/CppUnit/TestRunner.h#7 $
//
#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] [-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:
bool run(Test* test);
void printBanner();
void print(const std::string& name, Test* pTest, int indent);
Test* find(const std::string& name, Test* pTest, const std::string& testName);
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

View File

@@ -1,57 +0,0 @@
//
// TestSetup.h
//
// $Id: //poco/Main/CppUnit/include/CppUnit/TestSetup.h#7 $
//
#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

View File

@@ -1,98 +0,0 @@
//
// TestSuite.h
//
// $Id: //poco/Main/CppUnit/include/CppUnit/TestSuite.h#7 $
//
#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();
void addTest(Test* test);
std::string toString();
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()
{
return "suite " + _name;
}
// Returns all tests
inline const std::vector<Test*> TestSuite::tests() const
{
return _tests;
}
} // namespace CppUnit
#endif // CppUnit_TestSuite_INCLUDED

View File

@@ -1,53 +0,0 @@
//
// TextTestResult.h
//
// $Id: //poco/Main/CppUnit/include/CppUnit/TextTestResult.h#7 $
//
#ifndef CppUnit_TextTestResult_INCLUDED
#define CppUnit_TextTestResult_INCLUDED
#include "CppUnit/CppUnit.h"
#include "CppUnit/TestResult.h"
#include <ostream>
namespace CppUnit {
class CppUnit_API TextTestResult: public TestResult
{
public:
TextTestResult();
TextTestResult(std::ostream& ostr);
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);
private:
std::ostream& _ostr;
};
/* 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

View File

@@ -1,73 +0,0 @@
//
// estring.h
//
// $Id: //poco/Main/CppUnit/include/CppUnit/estring.h#7 $
//
#ifndef CppUnit_estring_INCLUDED
#define CppUnit_estring_INCLUDED
#include "CppUnit/CppUnit.h"
#include <string>
#include <stdio.h>
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];
sprintf(buffer, "%d", number);
return std::string (buffer);
}
// Create a string from a long
inline std::string estring(long number)
{
char buffer[50];
sprintf(buffer, "%ld", number);
return std::string (buffer);
}
// Create a std::string from a double
inline std::string estring(double number)
{
char buffer[50];
sprintf(buffer, "%lf", number);
return std::string(buffer);
}
// Create a std::string from a double
inline std::string estring(const void* ptr)
{
char buffer[50];
sprintf(buffer, "%p", ptr);
return std::string(buffer);
}
} // namespace CppUnit
#endif // CppUnit_estring_INCLUDED