mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-17 03:03:23 +02:00
cppunit: update from 1.4.2 & vs 2010 project
This commit is contained in:
@@ -12,6 +12,10 @@
|
||||
#include "CppUnit/CppUnit.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <ostream>
|
||||
#if defined(POCO_VXWORKS)
|
||||
#include <cstdarg>
|
||||
#endif
|
||||
|
||||
|
||||
namespace CppUnit {
|
||||
@@ -40,36 +44,60 @@ class CppUnit_API TestRunner
|
||||
typedef std::vector<Mapping> Mappings;
|
||||
|
||||
public:
|
||||
TestRunner();
|
||||
~TestRunner();
|
||||
TestRunner();
|
||||
TestRunner(std::ostream& ostr);
|
||||
~TestRunner();
|
||||
|
||||
bool run(const std::vector<std::string>& args);
|
||||
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);
|
||||
Test* find(const std::string& name, Test* pTest, const std::string& testName);
|
||||
|
||||
private:
|
||||
Mappings _mappings;
|
||||
std::ostream& _ostr;
|
||||
Mappings _mappings;
|
||||
};
|
||||
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
|
||||
#if defined(POCO_VXWORKS)
|
||||
#define CppUnitMain(testCase) \
|
||||
int main(int ac, char **av) \
|
||||
{ \
|
||||
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; \
|
||||
}
|
||||
runner.addTest(#testCase, testCase::suite()); \
|
||||
return runner.run(args) ? 0 : 1; \
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // CppUnit_TestRunner_INCLUDED
|
||||
|
@@ -20,16 +20,22 @@ namespace CppUnit {
|
||||
class CppUnit_API TextTestResult: public TestResult
|
||||
{
|
||||
public:
|
||||
virtual void addError(Test* test, CppUnitException* e);
|
||||
virtual void addFailure(Test* test, CppUnitException* e);
|
||||
virtual void startTest(Test* test);
|
||||
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);
|
||||
std::string shortName(const std::string& testName);
|
||||
|
||||
private:
|
||||
std::ostream& _ostr;
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user