* fix gcc4 build of cppunit library by explicitly spelling out std:: in
the headers and importing the required classes in the implementation files * automatic whitespace cleanup git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30586 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -9,30 +9,30 @@
|
|||||||
//! Base class for single threaded unit tests
|
//! Base class for single threaded unit tests
|
||||||
class CPPUNIT_API BTestCase : public CppUnit::TestCase {
|
class CPPUNIT_API BTestCase : public CppUnit::TestCase {
|
||||||
public:
|
public:
|
||||||
BTestCase(string Name = "");
|
BTestCase(std::string Name = "");
|
||||||
|
|
||||||
//! Displays the next sub test progress indicator (i.e. [0][1][2][3]...).
|
//! Displays the next sub test progress indicator (i.e. [0][1][2][3]...).
|
||||||
virtual void NextSubTest();
|
virtual void NextSubTest();
|
||||||
|
|
||||||
//! Starts a new sub test block (i.e. prints a newline :-)
|
//! Starts a new sub test block (i.e. prints a newline :-)
|
||||||
virtual void NextSubTestBlock();
|
virtual void NextSubTestBlock();
|
||||||
|
|
||||||
/*! \brief Prints to standard out just like printf, except shell verbosity
|
/*! \brief Prints to standard out just like printf, except shell verbosity
|
||||||
settings are honored.
|
settings are honored.
|
||||||
*/
|
*/
|
||||||
virtual void Outputf(const char *str, ...);
|
virtual void Outputf(const char *str, ...);
|
||||||
|
|
||||||
//! Saves the location of the current working directory.
|
//! Saves the location of the current working directory.
|
||||||
void SaveCWD();
|
void SaveCWD();
|
||||||
|
|
||||||
virtual void tearDown();
|
virtual void tearDown();
|
||||||
|
|
||||||
//! Restores the current working directory to last directory saved by a call to SaveCWD().
|
//! Restores the current working directory to last directory saved by a call to SaveCWD().
|
||||||
void RestoreCWD(const char *alternate = NULL);
|
void RestoreCWD(const char *alternate = NULL);
|
||||||
protected:
|
protected:
|
||||||
bool fValidCWD;
|
bool fValidCWD;
|
||||||
char fCurrentWorkingDir[B_PATH_NAME_LENGTH+1];
|
char fCurrentWorkingDir[B_PATH_NAME_LENGTH+1];
|
||||||
int32 fSubTestNum;
|
int32 fSubTestNum;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _beos_test_case_h_
|
#endif // _beos_test_case_h_
|
||||||
|
|||||||
@@ -4,15 +4,17 @@
|
|||||||
#include <cppunit/TestListener.h>
|
#include <cppunit/TestListener.h>
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
class CppUnit::Test;
|
namespace CppUnit {
|
||||||
class CppUnit::TestFailure;
|
class Test;
|
||||||
class CppUnit::Exception;
|
class TestFailure;
|
||||||
|
class Exception;
|
||||||
|
}
|
||||||
|
|
||||||
//! Handles printing of test information
|
//! Handles printing of test information
|
||||||
/*! Receives notification of the beginning and end of each test,
|
/*! Receives notification of the beginning and end of each test,
|
||||||
and notification of all failures and errors. Prints out said
|
and notification of all failures and errors. Prints out said
|
||||||
information in a standard format to standard output.
|
information in a standard format to standard output.
|
||||||
|
|
||||||
You should not need to explicitly use this class in any
|
You should not need to explicitly use this class in any
|
||||||
of your tests.
|
of your tests.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -48,9 +48,9 @@ typedef CppUnit::SynchronizedObject::SynchronizationObject SyncObject;
|
|||||||
*/
|
*/
|
||||||
class CPPUNIT_API BTestShell {
|
class CPPUNIT_API BTestShell {
|
||||||
public:
|
public:
|
||||||
BTestShell(const string &description = "", SyncObject *syncObject = 0);
|
BTestShell(const std::string &description = "", SyncObject *syncObject = 0);
|
||||||
virtual ~BTestShell();
|
virtual ~BTestShell();
|
||||||
|
|
||||||
// This function is used to add the tests for a given kit (as contained
|
// This function is used to add the tests for a given kit (as contained
|
||||||
// in a BTestSuite object) to the list of available tests. The shell assumes
|
// in a BTestSuite object) to the list of available tests. The shell assumes
|
||||||
// ownership of the BTestSuite object. Each test in the kit is added to
|
// ownership of the BTestSuite object. Each test in the kit is added to
|
||||||
@@ -64,7 +64,7 @@ public:
|
|||||||
// when the program is run with "--list" as an argument. Usually the
|
// when the program is run with "--list" as an argument. Usually the
|
||||||
// given suite would be a test suite for an entire class, but that's
|
// given suite would be a test suite for an entire class, but that's
|
||||||
// not a requirement.
|
// not a requirement.
|
||||||
void AddTest(const string &name, CppUnit::Test* test);
|
void AddTest(const std::string &name, CppUnit::Test* test);
|
||||||
|
|
||||||
// This function loads all the test addons it finds in the given
|
// This function loads all the test addons it finds in the given
|
||||||
// directory, returning the number of tests actually loaded.
|
// directory, returning the number of tests actually loaded.
|
||||||
@@ -75,7 +75,7 @@ public:
|
|||||||
// help, or lists installed tests, or whatever, depending on the
|
// help, or lists installed tests, or whatever, depending on the
|
||||||
// command-line arguments passed in.
|
// command-line arguments passed in.
|
||||||
int Run(int argc, char *argv[]);
|
int Run(int argc, char *argv[]);
|
||||||
|
|
||||||
// Verbosity Level enumeration and accessor function
|
// Verbosity Level enumeration and accessor function
|
||||||
enum VerbosityLevel { v0, v1, v2, v3, v4 };
|
enum VerbosityLevel { v0, v1, v2, v3, v4 };
|
||||||
VerbosityLevel Verbosity() const;
|
VerbosityLevel Verbosity() const;
|
||||||
@@ -92,9 +92,9 @@ public:
|
|||||||
// have to (and always make sure the pointer it returns isn't NULL
|
// have to (and always make sure the pointer it returns isn't NULL
|
||||||
// before you try to use it :-).
|
// before you try to use it :-).
|
||||||
static BTestShell* GlobalShell() { return fGlobalShell; };
|
static BTestShell* GlobalShell() { return fGlobalShell; };
|
||||||
|
|
||||||
// Sets the global BTestShell pointer. The BTestShell class does
|
// Sets the global BTestShell pointer. The BTestShell class does
|
||||||
// not assume ownership of the object.
|
// not assume ownership of the object.
|
||||||
static void SetGlobalShell(BTestShell *shell) { fGlobalShell = shell; };
|
static void SetGlobalShell(BTestShell *shell) { fGlobalShell = shell; };
|
||||||
|
|
||||||
const char* TestDir() const;
|
const char* TestDir() const;
|
||||||
@@ -104,18 +104,18 @@ public:
|
|||||||
bool WasDebuggerCalled();
|
bool WasDebuggerCalled();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
typedef map<string, CppUnit::Test*> TestMap;
|
typedef std::map<std::string, CppUnit::Test*> TestMap;
|
||||||
typedef map<string, BTestSuite*> SuiteMap;
|
typedef std::map<std::string, BTestSuite*> SuiteMap;
|
||||||
|
|
||||||
VerbosityLevel fVerbosityLevel;
|
VerbosityLevel fVerbosityLevel;
|
||||||
set<string> fTestsToRun;
|
std::set<std::string> fTestsToRun;
|
||||||
set<string> fSuitesToRun;
|
std::set<std::string> fSuitesToRun;
|
||||||
TestMap fTests;
|
TestMap fTests;
|
||||||
SuiteMap fSuites;
|
SuiteMap fSuites;
|
||||||
set<string> fLibDirs;
|
std::set<std::string> fLibDirs;
|
||||||
CppUnit::TestResult fTestResults;
|
CppUnit::TestResult fTestResults;
|
||||||
CppUnit::TestResultCollector fResultsCollector;
|
CppUnit::TestResultCollector fResultsCollector;
|
||||||
string fDescription;
|
std::string fDescription;
|
||||||
static BTestShell* fGlobalShell;
|
static BTestShell* fGlobalShell;
|
||||||
static const char indent[];
|
static const char indent[];
|
||||||
bool fListTestsAndExit;
|
bool fListTestsAndExit;
|
||||||
@@ -134,7 +134,7 @@ protected:
|
|||||||
|
|
||||||
//! Prints out command line argument instructions
|
//! Prints out command line argument instructions
|
||||||
void PrintHelp();
|
void PrintHelp();
|
||||||
|
|
||||||
/*! \brief Prints out the list of valid command line arguments.
|
/*! \brief Prints out the list of valid command line arguments.
|
||||||
Called by PrintHelp().
|
Called by PrintHelp().
|
||||||
*/
|
*/
|
||||||
@@ -142,15 +142,15 @@ protected:
|
|||||||
|
|
||||||
//! Prints out a list of all the currently available tests
|
//! Prints out a list of all the currently available tests
|
||||||
void PrintInstalledTests();
|
void PrintInstalledTests();
|
||||||
|
|
||||||
/*! \brief Handles command line arguments; returns true if everything goes
|
/*! \brief Handles command line arguments; returns true if everything goes
|
||||||
okay, false if not (or if the program just needs to terminate without
|
okay, false if not (or if the program just needs to terminate without
|
||||||
running any tests). Modifies settings in "settings" as necessary.
|
running any tests). Modifies settings in "settings" as necessary.
|
||||||
*/
|
*/
|
||||||
bool ProcessArguments(int argc, char *argv[]);
|
bool ProcessArguments(int argc, char *argv[]);
|
||||||
|
|
||||||
//! Processes a single argument, given by the \c arg parameter.
|
//! Processes a single argument, given by the \c arg parameter.
|
||||||
virtual bool ProcessArgument(string arg, int argc, char *argv[]);
|
virtual bool ProcessArgument(std::string arg, int argc, char *argv[]);
|
||||||
|
|
||||||
//! Makes any necessary pre-test preparations
|
//! Makes any necessary pre-test preparations
|
||||||
void InitOutput();
|
void InitOutput();
|
||||||
@@ -159,12 +159,12 @@ protected:
|
|||||||
the specified verbosity level.
|
the specified verbosity level.
|
||||||
*/
|
*/
|
||||||
void PrintResults();
|
void PrintResults();
|
||||||
|
|
||||||
/*! \brief Searches all the paths in \c fLibDirs, loading any dynamically
|
/*! \brief Searches all the paths in \c fLibDirs, loading any dynamically
|
||||||
loadable suites it finds.
|
loadable suites it finds.
|
||||||
*/
|
*/
|
||||||
virtual void LoadDynamicSuites();
|
virtual void LoadDynamicSuites();
|
||||||
|
|
||||||
//! Sets the current test directory.
|
//! Sets the current test directory.
|
||||||
void UpdateTestDir(char *argv[]);
|
void UpdateTestDir(char *argv[]);
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ private:
|
|||||||
static image_id _LoadAddOnHook(const char* path);
|
static image_id _LoadAddOnHook(const char* path);
|
||||||
static status_t _UnloadAddOnHook(image_id image);
|
static status_t _UnloadAddOnHook(image_id image);
|
||||||
#endif // ! NO_ELF_SYMBOL_PATCHING
|
#endif // ! NO_ELF_SYMBOL_PATCHING
|
||||||
|
|
||||||
}; // class BTestShell
|
}; // class BTestShell
|
||||||
|
|
||||||
#endif // _beos_test_shell_h_
|
#endif // _beos_test_shell_h_
|
||||||
|
|||||||
@@ -6,31 +6,33 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class CppUnit::TestResult;
|
namespace CppUnit {
|
||||||
|
class TestResult;
|
||||||
|
}
|
||||||
|
|
||||||
//! Groups together a set of tests for a given kit.
|
//! Groups together a set of tests for a given kit.
|
||||||
class CPPUNIT_API BTestSuite : public CppUnit::Test {
|
class CPPUNIT_API BTestSuite : public CppUnit::Test {
|
||||||
public:
|
public:
|
||||||
BTestSuite( string name = "" );
|
BTestSuite(std::string name = "");
|
||||||
virtual ~BTestSuite();
|
virtual ~BTestSuite();
|
||||||
|
|
||||||
virtual void run( CppUnit::TestResult *result );
|
virtual void run(CppUnit::TestResult *result);
|
||||||
virtual int countTestCases() const;
|
virtual int countTestCases() const;
|
||||||
virtual string getName() const;
|
virtual std::string getName() const;
|
||||||
virtual string toString() const;
|
virtual std::string toString() const;
|
||||||
|
|
||||||
virtual void addTest(string name, CppUnit::Test *test);
|
virtual void addTest(std::string name, CppUnit::Test *test);
|
||||||
virtual void deleteContents();
|
virtual void deleteContents();
|
||||||
|
|
||||||
const map<string, CppUnit::Test*> &getTests() const;
|
const std::map<std::string, CppUnit::Test*> &getTests() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
map<string, CppUnit::Test*> fTests;
|
std::map<std::string, CppUnit::Test*> fTests;
|
||||||
const string fName;
|
const std::string fName;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BTestSuite(const BTestSuite &other);
|
BTestSuite(const BTestSuite &other);
|
||||||
BTestSuite& operator=(const BTestSuite &other);
|
BTestSuite& operator=(const BTestSuite &other);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ Equals(const A &a, const B &b, const C &c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns a string version of the given integer
|
// Returns a string version of the given integer
|
||||||
extern CPPUNIT_API string IntToStr(int i);
|
extern CPPUNIT_API std::string IntToStr(int i);
|
||||||
|
|
||||||
// Calls system() with the concatenated string of command and parameter.
|
// Calls system() with the concatenated string of command and parameter.
|
||||||
extern CPPUNIT_API void ExecCommand(const char *command, const char *parameter);
|
extern CPPUNIT_API void ExecCommand(const char *command, const char *parameter);
|
||||||
@@ -40,5 +40,5 @@ extern CPPUNIT_API void ExecCommand(const char *command, const char *parameter1,
|
|||||||
|
|
||||||
// Calls system() with the given command (kind of silly, but it's consistent :-)
|
// Calls system() with the given command (kind of silly, but it's consistent :-)
|
||||||
extern CPPUNIT_API void ExecCommand(const char *command);
|
extern CPPUNIT_API void ExecCommand(const char *command);
|
||||||
|
|
||||||
#endif // __beos_test_utils_h__
|
#endif // __beos_test_utils_h__
|
||||||
|
|||||||
@@ -14,23 +14,23 @@
|
|||||||
class TestResult;
|
class TestResult;
|
||||||
|
|
||||||
template <class TestClass, class ExpectedException = CppUnit::NoExceptionExpected>
|
template <class TestClass, class ExpectedException = CppUnit::NoExceptionExpected>
|
||||||
class CPPUNIT_API BThreadedTestCaller : public CppUnit::TestCase {
|
class CPPUNIT_API BThreadedTestCaller : public CppUnit::TestCase {
|
||||||
public:
|
public:
|
||||||
/*! \brief Pointer to a test function in the given class.
|
/*! \brief Pointer to a test function in the given class.
|
||||||
Each ThreadMethod added with addThread() is run in its own thread.
|
Each ThreadMethod added with addThread() is run in its own thread.
|
||||||
*/
|
*/
|
||||||
typedef void (TestClass::*ThreadMethod)();
|
typedef void (TestClass::*ThreadMethod)();
|
||||||
|
|
||||||
BThreadedTestCaller(std::string name);
|
BThreadedTestCaller(std::string name);
|
||||||
BThreadedTestCaller(std::string name, TestClass &object);
|
BThreadedTestCaller(std::string name, TestClass &object);
|
||||||
BThreadedTestCaller(std::string name, TestClass *object);
|
BThreadedTestCaller(std::string name, TestClass *object);
|
||||||
virtual ~BThreadedTestCaller();
|
virtual ~BThreadedTestCaller();
|
||||||
|
|
||||||
virtual CppUnit::TestResult *run();
|
virtual CppUnit::TestResult *run();
|
||||||
virtual void run(CppUnit::TestResult *result);
|
virtual void run(CppUnit::TestResult *result);
|
||||||
|
|
||||||
//! Adds a thread to the test. \c threadName must be unique to this BThreadedTestCaller.
|
//! Adds a thread to the test. \c threadName must be unique to this BThreadedTestCaller.
|
||||||
void addThread(std::string threadName, ThreadMethod method);
|
void addThread(std::string threadName, ThreadMethod method);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void setUp();
|
virtual void setUp();
|
||||||
@@ -42,9 +42,9 @@ protected:
|
|||||||
bool fOwnObject;
|
bool fOwnObject;
|
||||||
TestClass *fObject;
|
TestClass *fObject;
|
||||||
ThreadManagerMap fThreads;
|
ThreadManagerMap fThreads;
|
||||||
|
|
||||||
sem_id fThreadSem;
|
sem_id fThreadSem;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -78,19 +78,19 @@ BThreadedTestCaller<TestClass, ExpectedException>::BThreadedTestCaller(std::stri
|
|||||||
template <class TestClass, class ExpectedException>
|
template <class TestClass, class ExpectedException>
|
||||||
BThreadedTestCaller<TestClass, ExpectedException>::~BThreadedTestCaller() {
|
BThreadedTestCaller<TestClass, ExpectedException>::~BThreadedTestCaller() {
|
||||||
if (fOwnObject)
|
if (fOwnObject)
|
||||||
delete fObject;
|
delete fObject;
|
||||||
for (ThreadManagerMap::iterator it = fThreads.begin(); it != fThreads.end (); ++it) {
|
for (typename ThreadManagerMap::iterator it = fThreads.begin(); it != fThreads.end (); ++it) {
|
||||||
delete it->second;
|
delete it->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class TestClass, class ExpectedException>
|
template <class TestClass, class ExpectedException>
|
||||||
void
|
void
|
||||||
BThreadedTestCaller<TestClass, ExpectedException>::addThread(std::string threadName, ThreadMethod method) {
|
BThreadedTestCaller<TestClass, ExpectedException>::addThread(std::string threadName, ThreadMethod method) {
|
||||||
if (fThreads.find(threadName) == fThreads.end()) {
|
if (fThreads.find(threadName) == fThreads.end()) {
|
||||||
// Unused name, go ahead and add
|
// Unused name, go ahead and add
|
||||||
fThreads[threadName] = new BThreadManager<TestClass, ExpectedException>(threadName, fObject, method, fThreadSem);
|
fThreads[threadName] = new BThreadManager<TestClass, ExpectedException>(threadName, fObject, method, fThreadSem);
|
||||||
} else {
|
} else {
|
||||||
// Duplicate name, throw an exception
|
// Duplicate name, throw an exception
|
||||||
throw CppUnit::Exception("BThreadedTestCaller::addThread() - Attempt to add thread under duplicated name ('"
|
throw CppUnit::Exception("BThreadedTestCaller::addThread() - Attempt to add thread under duplicated name ('"
|
||||||
@@ -110,11 +110,11 @@ template <class TestClass, class ExpectedException>
|
|||||||
void
|
void
|
||||||
BThreadedTestCaller<TestClass, ExpectedException>::run(CppUnit::TestResult *result) {
|
BThreadedTestCaller<TestClass, ExpectedException>::run(CppUnit::TestResult *result) {
|
||||||
result->startTest(this);
|
result->startTest(this);
|
||||||
|
|
||||||
if (fThreads.size() <= 0)
|
if (fThreads.size() <= 0)
|
||||||
throw CppUnit::Exception("BThreadedTestCaller::run() -- No threads added to BThreadedTestCaller()");
|
throw CppUnit::Exception("BThreadedTestCaller::run() -- No threads added to BThreadedTestCaller()");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setUp();
|
setUp();
|
||||||
|
|
||||||
// This try/catch block should never actually have to catch
|
// This try/catch block should never actually have to catch
|
||||||
@@ -131,13 +131,13 @@ BThreadedTestCaller<TestClass, ExpectedException>::run(CppUnit::TestResult *resu
|
|||||||
// blocked; their output appears later...).
|
// blocked; their output appears later...).
|
||||||
//
|
//
|
||||||
// Each thread will acquire the semaphore once when launched,
|
// Each thread will acquire the semaphore once when launched,
|
||||||
// thus the initial thread count is equal the number of threads.
|
// thus the initial thread count is equal the number of threads.
|
||||||
fThreadSem = create_sem(fThreads.size(), "ThreadSem");
|
fThreadSem = create_sem(fThreads.size(), "ThreadSem");
|
||||||
if (fThreadSem < B_OK)
|
if (fThreadSem < B_OK)
|
||||||
throw CppUnit::Exception("BThreadedTestCaller::run() -- Error creating fThreadSem");
|
throw CppUnit::Exception("BThreadedTestCaller::run() -- Error creating fThreadSem");
|
||||||
|
|
||||||
// Launch all the threads.
|
// Launch all the threads.
|
||||||
for (ThreadManagerMap::iterator i = fThreads.begin();
|
for (typename ThreadManagerMap::iterator i = fThreads.begin();
|
||||||
i != fThreads.end ();
|
i != fThreads.end ();
|
||||||
++i)
|
++i)
|
||||||
{
|
{
|
||||||
@@ -146,7 +146,7 @@ BThreadedTestCaller<TestClass, ExpectedException>::run(CppUnit::TestResult *resu
|
|||||||
result->addError(this, new CppUnit::Exception("Error launching thread '" + i->second->getName() + "'"));
|
result->addError(this, new CppUnit::Exception("Error launching thread '" + i->second->getName() + "'"));
|
||||||
// printf("Launch(%s)\n", i->second->getName().c_str());
|
// printf("Launch(%s)\n", i->second->getName().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now we loop. Before you faint, there is a reason for this:
|
// Now we loop. Before you faint, there is a reason for this:
|
||||||
// Calls to NextSubTest() from other threads don't actually
|
// Calls to NextSubTest() from other threads don't actually
|
||||||
// print anything while the main thread is blocked waiting
|
// print anything while the main thread is blocked waiting
|
||||||
@@ -158,13 +158,13 @@ BThreadedTestCaller<TestClass, ExpectedException>::run(CppUnit::TestResult *resu
|
|||||||
// any pending updates, and tries to acquire the semaphore
|
// any pending updates, and tries to acquire the semaphore
|
||||||
// again. When it finally manages to acquire it, all the
|
// again. When it finally manages to acquire it, all the
|
||||||
// test threads have terminated, and it's safe to clean up.
|
// test threads have terminated, and it's safe to clean up.
|
||||||
|
|
||||||
status_t err;
|
status_t err;
|
||||||
do {
|
do {
|
||||||
// Try to acquire the semaphore
|
// Try to acquire the semaphore
|
||||||
err = acquire_sem_etc(fThreadSem, fThreads.size(), B_RELATIVE_TIMEOUT, 500000);
|
err = acquire_sem_etc(fThreadSem, fThreads.size(), B_RELATIVE_TIMEOUT, 500000);
|
||||||
|
|
||||||
// Empty the UpdateList
|
// Empty the UpdateList
|
||||||
std::vector<std::string> &list = fObject->AcquireUpdateList();
|
std::vector<std::string> &list = fObject->AcquireUpdateList();
|
||||||
for (std::vector<std::string>::iterator i = list.begin();
|
for (std::vector<std::string>::iterator i = list.begin();
|
||||||
i != list.end();
|
i != list.end();
|
||||||
@@ -172,16 +172,16 @@ BThreadedTestCaller<TestClass, ExpectedException>::run(CppUnit::TestResult *resu
|
|||||||
{
|
{
|
||||||
// Only print to standard out if the current global shell
|
// Only print to standard out if the current global shell
|
||||||
// lets us (or if no global shell is designated).
|
// lets us (or if no global shell is designated).
|
||||||
if (BTestShell::GlobalBeVerbose()) {
|
if (BTestShell::GlobalBeVerbose()) {
|
||||||
printf("%s", (*i).c_str());
|
printf("%s", (*i).c_str());
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
list.clear();
|
list.clear();
|
||||||
fObject->ReleaseUpdateList();
|
fObject->ReleaseUpdateList();
|
||||||
|
|
||||||
} while (err != B_OK);
|
} while (err != B_OK);
|
||||||
|
|
||||||
// If we get this far, we actually managed to acquire the semaphore,
|
// If we get this far, we actually managed to acquire the semaphore,
|
||||||
// so we should release it now.
|
// so we should release it now.
|
||||||
release_sem_etc(fThreadSem, fThreads.size(), 0);
|
release_sem_etc(fThreadSem, fThreads.size(), 0);
|
||||||
@@ -189,9 +189,9 @@ BThreadedTestCaller<TestClass, ExpectedException>::run(CppUnit::TestResult *resu
|
|||||||
// Print out a newline for asthetics :-)
|
// Print out a newline for asthetics :-)
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
|
||||||
// Wait for them all to finish, then clean up
|
// Wait for them all to finish, then clean up
|
||||||
for (ThreadManagerMap::iterator i = fThreads.begin();
|
for (ThreadManagerMap::iterator i = fThreads.begin();
|
||||||
i != fThreads.end ();
|
i != fThreads.end ();
|
||||||
@@ -206,21 +206,21 @@ BThreadedTestCaller<TestClass, ExpectedException>::run(CppUnit::TestResult *resu
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
fThreads.clear();
|
fThreads.clear();
|
||||||
|
|
||||||
} catch ( CppUnit::Exception &e ) {
|
} catch ( CppUnit::Exception &e ) {
|
||||||
// Add on the a note that this exception was caught by the
|
// Add on the a note that this exception was caught by the
|
||||||
// thread caller (which is a bad thing), then note the exception
|
// thread caller (which is a bad thing), then note the exception
|
||||||
CppUnit::Exception *threadException = new CppUnit::Exception(
|
CppUnit::Exception *threadException = new CppUnit::Exception(
|
||||||
std::string(e.what()) + " (NOTE: caught by BThreadedTestCaller)",
|
std::string(e.what()) + " (NOTE: caught by BThreadedTestCaller)",
|
||||||
e.sourceLine()
|
e.sourceLine()
|
||||||
);
|
);
|
||||||
result->addFailure( fObject, threadException );
|
result->addFailure( fObject, threadException );
|
||||||
}
|
}
|
||||||
catch ( std::exception &e ) {
|
catch ( std::exception &e ) {
|
||||||
// Add on the thread name, then note the exception
|
// Add on the thread name, then note the exception
|
||||||
CppUnit::Exception *threadException = new CppUnit::Exception(
|
CppUnit::Exception *threadException = new CppUnit::Exception(
|
||||||
std::string(e.what()) + " (NOTE: caught by BThreadedTestCaller)"
|
std::string(e.what()) + " (NOTE: caught by BThreadedTestCaller)"
|
||||||
);
|
);
|
||||||
result->addError( fObject, threadException );
|
result->addError( fObject, threadException );
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
@@ -237,7 +237,7 @@ BThreadedTestCaller<TestClass, ExpectedException>::run(CppUnit::TestResult *resu
|
|||||||
tearDown();
|
tearDown();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
result->addError(this, new CppUnit::Exception("tearDown() failed"));
|
result->addError(this, new CppUnit::Exception("tearDown() failed"));
|
||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
result->addError(this, new CppUnit::Exception("setUp() failed"));
|
result->addError(this, new CppUnit::Exception("setUp() failed"));
|
||||||
} // setUp() try/catch block
|
} // setUp() try/catch block
|
||||||
@@ -253,7 +253,7 @@ BThreadedTestCaller<TestClass, ExpectedException>::setUp() {
|
|||||||
throw CppUnit::Exception("BThreadedTestCaller::runTest() -- NULL fObject pointer");
|
throw CppUnit::Exception("BThreadedTestCaller::runTest() -- NULL fObject pointer");
|
||||||
if (!fObject->RegisterForUse())
|
if (!fObject->RegisterForUse())
|
||||||
throw CppUnit::Exception("BThreadedTestCaller::runTest() -- Attempt to reuse ThreadedTestCase object already in use");
|
throw CppUnit::Exception("BThreadedTestCaller::runTest() -- Attempt to reuse ThreadedTestCase object already in use");
|
||||||
|
|
||||||
fObject->setUp();
|
fObject->setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,8 +265,8 @@ BThreadedTestCaller<TestClass, ExpectedException>::tearDown() {
|
|||||||
|
|
||||||
template <class TestClass, class ExpectedException>
|
template <class TestClass, class ExpectedException>
|
||||||
std::string
|
std::string
|
||||||
BThreadedTestCaller<TestClass, ExpectedException>::toString() const {
|
BThreadedTestCaller<TestClass, ExpectedException>::toString() const {
|
||||||
return std::string("BThreadedTestCaller for ") + getName();
|
return std::string("BThreadedTestCaller for ") + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // _beos_threaded_test_caller_h_
|
#endif // _beos_threaded_test_caller_h_
|
||||||
|
|||||||
@@ -11,46 +11,46 @@
|
|||||||
//! Base class for single threaded unit tests
|
//! Base class for single threaded unit tests
|
||||||
class CPPUNIT_API BThreadedTestCase : public BTestCase {
|
class CPPUNIT_API BThreadedTestCase : public BTestCase {
|
||||||
public:
|
public:
|
||||||
BThreadedTestCase(string Name = "", string progressSeparator = ".");
|
BThreadedTestCase(std::string Name = "", std::string progressSeparator = ".");
|
||||||
virtual ~BThreadedTestCase();
|
virtual ~BThreadedTestCase();
|
||||||
|
|
||||||
/*! \brief Displays the next sub test progress indicator for the
|
/*! \brief Displays the next sub test progress indicator for the
|
||||||
thread in which it's called (i.e. [A.0][B.0][A.1][A.2][B.1]...). */
|
thread in which it's called (i.e. [A.0][B.0][A.1][A.2][B.1]...). */
|
||||||
virtual void NextSubTest();
|
virtual void NextSubTest();
|
||||||
|
|
||||||
/*! \brief Prints to standard out just like printf, except shell verbosity
|
/*! \brief Prints to standard out just like printf, except shell verbosity
|
||||||
settings are honored, and output from threads other than the main thread
|
settings are honored, and output from threads other than the main thread
|
||||||
happens before the test is over.
|
happens before the test is over.
|
||||||
|
|
||||||
\note Currently your output is limited to a length of 1024 characters. If
|
\note Currently your output is limited to a length of 1024 characters. If
|
||||||
you really need to print a single string that's long than that, fix the
|
you really need to print a single string that's long than that, fix the
|
||||||
function yourself :-).
|
function yourself :-).
|
||||||
*/
|
*/
|
||||||
virtual void Outputf(const char *str, ...);
|
virtual void Outputf(const char *str, ...);
|
||||||
|
|
||||||
//! Saves the location of the current working directory.
|
//! Saves the location of the current working directory.
|
||||||
void SaveCWD();
|
void SaveCWD();
|
||||||
|
|
||||||
//! Restores the current working directory to last directory saved by a call to SaveCWD().
|
//! Restores the current working directory to last directory saved by a call to SaveCWD().
|
||||||
void RestoreCWD(const char *alternate = NULL);
|
void RestoreCWD(const char *alternate = NULL);
|
||||||
void InitThreadInfo(thread_id id, string threadName);
|
void InitThreadInfo(thread_id id, std::string threadName);
|
||||||
bool RegisterForUse();
|
bool RegisterForUse();
|
||||||
void UnregisterForUse();
|
void UnregisterForUse();
|
||||||
|
|
||||||
vector<string>& AcquireUpdateList();
|
std::vector<std::string>& AcquireUpdateList();
|
||||||
void ReleaseUpdateList();
|
void ReleaseUpdateList();
|
||||||
protected:
|
protected:
|
||||||
bool fInUse;
|
bool fInUse;
|
||||||
|
|
||||||
// friend class ThreadManager<BThreadedTestCase>;
|
// friend class ThreadManager<BThreadedTestCase>;
|
||||||
string fProgressSeparator;
|
std::string fProgressSeparator;
|
||||||
|
|
||||||
struct ThreadSubTestInfo {
|
struct ThreadSubTestInfo {
|
||||||
string name;
|
std::string name;
|
||||||
int32 subTestNum;
|
int32 subTestNum;
|
||||||
};
|
};
|
||||||
map<thread_id, ThreadSubTestInfo*> fNumberMap;
|
std::map<thread_id, ThreadSubTestInfo*> fNumberMap;
|
||||||
vector<string> fUpdateList;
|
std::vector<std::string> fUpdateList;
|
||||||
BLocker *fUpdateLock;
|
BLocker *fUpdateLock;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,23 +16,23 @@ namespace CppUnit
|
|||||||
* \code
|
* \code
|
||||||
* #include <cppunit/SourceLine.h>
|
* #include <cppunit/SourceLine.h>
|
||||||
* #include <cppunit/TestAssert.h>
|
* #include <cppunit/TestAssert.h>
|
||||||
*
|
*
|
||||||
* void
|
* void
|
||||||
* checkXmlEqual( string expectedXml,
|
* checkXmlEqual( string expectedXml,
|
||||||
* string actualXml,
|
* string actualXml,
|
||||||
* CppUnit::SourceLine sourceLine )
|
* CppUnit::SourceLine sourceLine )
|
||||||
* {
|
* {
|
||||||
* string expected = XmlUniformiser( expectedXml ).stripped();
|
* string expected = XmlUniformiser( expectedXml ).stripped();
|
||||||
* string actual = XmlUniformiser( actualXml ).stripped();
|
* string actual = XmlUniformiser( actualXml ).stripped();
|
||||||
*
|
*
|
||||||
* if ( expected == actual )
|
* if ( expected == actual )
|
||||||
* return;
|
* return;
|
||||||
*
|
*
|
||||||
* ::CppUnit::Asserter::failNotEqual( expected,
|
* ::CppUnit::Asserter::failNotEqual( expected,
|
||||||
* actual,
|
* actual,
|
||||||
* sourceLine );
|
* sourceLine );
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* /// Asserts that two XML strings are equivalent.
|
* /// Asserts that two XML strings are equivalent.
|
||||||
* #define CPPUNITTEST_ASSERT_XML_EQUAL( expected, actual ) \
|
* #define CPPUNITTEST_ASSERT_XML_EQUAL( expected, actual ) \
|
||||||
* checkXmlEqual( expected, actual, \
|
* checkXmlEqual( expected, actual, \
|
||||||
@@ -44,7 +44,7 @@ namespace Asserter
|
|||||||
|
|
||||||
/*! Throws a Exception with the specified message and location.
|
/*! Throws a Exception with the specified message and location.
|
||||||
*/
|
*/
|
||||||
void CPPUNIT_API fail( string message,
|
void CPPUNIT_API fail( std::string message,
|
||||||
SourceLine sourceLine = SourceLine() );
|
SourceLine sourceLine = SourceLine() );
|
||||||
|
|
||||||
/*! Throws a Exception with the specified message and location.
|
/*! Throws a Exception with the specified message and location.
|
||||||
@@ -53,8 +53,8 @@ namespace Asserter
|
|||||||
* \param message Message explaining the assertion failiure.
|
* \param message Message explaining the assertion failiure.
|
||||||
* \param sourceLine Location of the assertion.
|
* \param sourceLine Location of the assertion.
|
||||||
*/
|
*/
|
||||||
void CPPUNIT_API failIf( bool shouldFail,
|
void CPPUNIT_API failIf( bool shouldFail,
|
||||||
string message,
|
std::string message,
|
||||||
SourceLine sourceLine = SourceLine() );
|
SourceLine sourceLine = SourceLine() );
|
||||||
|
|
||||||
/*! Throws a NotEqualException with the specified message and location.
|
/*! Throws a NotEqualException with the specified message and location.
|
||||||
@@ -64,10 +64,10 @@ namespace Asserter
|
|||||||
* where the "difference" is located.
|
* where the "difference" is located.
|
||||||
* \param sourceLine Location of the assertion.
|
* \param sourceLine Location of the assertion.
|
||||||
*/
|
*/
|
||||||
void CPPUNIT_API failNotEqual( string expected,
|
void CPPUNIT_API failNotEqual( std::string expected,
|
||||||
string actual,
|
std::string actual,
|
||||||
SourceLine sourceLine = SourceLine(),
|
SourceLine sourceLine = SourceLine(),
|
||||||
string additionalMessage ="" );
|
std::string additionalMessage ="" );
|
||||||
|
|
||||||
/*! Throws a NotEqualException with the specified message and location.
|
/*! Throws a NotEqualException with the specified message and location.
|
||||||
* \param shouldFail if \c true then the exception is thrown. Otherwise
|
* \param shouldFail if \c true then the exception is thrown. Otherwise
|
||||||
@@ -79,10 +79,10 @@ namespace Asserter
|
|||||||
* \param sourceLine Location of the assertion.
|
* \param sourceLine Location of the assertion.
|
||||||
*/
|
*/
|
||||||
void CPPUNIT_API failNotEqualIf( bool shouldFail,
|
void CPPUNIT_API failNotEqualIf( bool shouldFail,
|
||||||
string expected,
|
std::string expected,
|
||||||
string actual,
|
std::string actual,
|
||||||
SourceLine sourceLine = SourceLine(),
|
SourceLine sourceLine = SourceLine(),
|
||||||
string additionalMessage ="" );
|
std::string additionalMessage ="" );
|
||||||
|
|
||||||
} // namespace Asserter
|
} // namespace Asserter
|
||||||
} // namespace CppUnit
|
} // namespace CppUnit
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class Test;
|
|||||||
class TestFailure;
|
class TestFailure;
|
||||||
class TestResultCollector;
|
class TestResultCollector;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Outputs a TestResultCollector in a compiler compatible format.
|
* \brief Outputs a TestResultCollector in a compiler compatible format.
|
||||||
* \ingroup WritingTestResult
|
* \ingroup WritingTestResult
|
||||||
*
|
*
|
||||||
@@ -33,23 +33,23 @@ class TestResultCollector;
|
|||||||
* int main( int argc, char* argv[] ) {
|
* int main( int argc, char* argv[] ) {
|
||||||
* // if command line contains "-selftest" then this is the post build check
|
* // if command line contains "-selftest" then this is the post build check
|
||||||
* // => the output must be in the compiler error format.
|
* // => the output must be in the compiler error format.
|
||||||
* bool selfTest = (argc > 1) &&
|
* bool selfTest = (argc > 1) &&
|
||||||
* (string("-selftest") == argv[1]);
|
* (string("-selftest") == argv[1]);
|
||||||
*
|
*
|
||||||
* CppUnit::TextUi::TestRunner runner;
|
* CppUnit::TextUi::TestRunner runner;
|
||||||
* runner.addTest( CppUnitTest::suite() ); // Add the top suite to the test runner
|
* runner.addTest( CppUnitTest::suite() ); // Add the top suite to the test runner
|
||||||
*
|
*
|
||||||
* if ( selfTest )
|
* if ( selfTest )
|
||||||
* { // Change the default outputter to a compiler error format outputter
|
* { // Change the default outputter to a compiler error format outputter
|
||||||
* // The test runner owns the new outputter.
|
* // The test runner owns the new outputter.
|
||||||
* runner.setOutputter( CppUnit::CompilerOutputter::defaultOutputter(
|
* runner.setOutputter( CppUnit::CompilerOutputter::defaultOutputter(
|
||||||
* &runner.result(),
|
* &runner.result(),
|
||||||
* cerr ) );
|
* cerr ) );
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* // Run the test and don't wait a key if post build check.
|
* // Run the test and don't wait a key if post build check.
|
||||||
* bool wasSucessful = runner.run( "", !selfTest );
|
* bool wasSucessful = runner.run( "", !selfTest );
|
||||||
*
|
*
|
||||||
* // Return error code 1 if the one of test failed.
|
* // Return error code 1 if the one of test failed.
|
||||||
* return wasSucessful ? 0 : 1;
|
* return wasSucessful ? 0 : 1;
|
||||||
* }
|
* }
|
||||||
@@ -61,7 +61,7 @@ public:
|
|||||||
/*! Constructs a CompilerOutputter object.
|
/*! Constructs a CompilerOutputter object.
|
||||||
*/
|
*/
|
||||||
CompilerOutputter( TestResultCollector *result,
|
CompilerOutputter( TestResultCollector *result,
|
||||||
ostream &stream );
|
std::ostream &stream );
|
||||||
|
|
||||||
/// Destructor.
|
/// Destructor.
|
||||||
virtual ~CompilerOutputter();
|
virtual ~CompilerOutputter();
|
||||||
@@ -69,7 +69,7 @@ public:
|
|||||||
/*! Creates an instance of an outputter that matches your current compiler.
|
/*! Creates an instance of an outputter that matches your current compiler.
|
||||||
*/
|
*/
|
||||||
static CompilerOutputter *defaultOutputter( TestResultCollector *result,
|
static CompilerOutputter *defaultOutputter( TestResultCollector *result,
|
||||||
ostream &stream );
|
std::ostream &stream );
|
||||||
|
|
||||||
void write();
|
void write();
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ public:
|
|||||||
virtual void printFailureMessage( TestFailure *failure );
|
virtual void printFailureMessage( TestFailure *failure );
|
||||||
virtual void printNotEqualMessage( Exception *thrownException );
|
virtual void printNotEqualMessage( Exception *thrownException );
|
||||||
virtual void printDefaultMessage( Exception *thrownException );
|
virtual void printDefaultMessage( Exception *thrownException );
|
||||||
virtual string wrap( string message );
|
virtual std::string wrap( std::string message );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Prevents the use of the copy constructor.
|
/// Prevents the use of the copy constructor.
|
||||||
@@ -93,12 +93,12 @@ private:
|
|||||||
/// Prevents the use of the copy operator.
|
/// Prevents the use of the copy operator.
|
||||||
void operator =( const CompilerOutputter © );
|
void operator =( const CompilerOutputter © );
|
||||||
|
|
||||||
typedef vector<string> Lines;
|
typedef std::vector<std::string> Lines;
|
||||||
static Lines splitMessageIntoLines( string message );
|
static Lines splitMessageIntoLines( std::string message );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TestResultCollector *m_result;
|
TestResultCollector *m_result;
|
||||||
ostream &m_stream;
|
std::ostream &m_stream;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,31 +14,31 @@ namespace CppUnit {
|
|||||||
* Exception is an exception that serves
|
* Exception is an exception that serves
|
||||||
* descriptive strings through its what() method
|
* descriptive strings through its what() method
|
||||||
*/
|
*/
|
||||||
class CPPUNIT_API Exception : public exception
|
class CPPUNIT_API Exception : public std::exception
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
class Type
|
class Type
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Type( string type ) : m_type ( type ) {}
|
Type( std::string type ) : m_type ( type ) {}
|
||||||
|
|
||||||
bool operator ==( const Type &other ) const
|
bool operator ==( const Type &other ) const
|
||||||
{
|
{
|
||||||
return m_type == other.m_type;
|
return m_type == other.m_type;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
const string m_type;
|
const std::string m_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Exception( string message = "",
|
Exception( std::string message = "",
|
||||||
SourceLine sourceLine = SourceLine() );
|
SourceLine sourceLine = SourceLine() );
|
||||||
|
|
||||||
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
|
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
|
||||||
Exception( string message,
|
Exception( std::string message,
|
||||||
long lineNumber,
|
long lineNumber,
|
||||||
string fileName );
|
std::string fileName );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Exception (const Exception& other);
|
Exception (const Exception& other);
|
||||||
@@ -55,12 +55,12 @@ public:
|
|||||||
long lineNumber() const;
|
long lineNumber() const;
|
||||||
string fileName() const;
|
string fileName() const;
|
||||||
|
|
||||||
static const string UNKNOWNFILENAME;
|
static const std::string UNKNOWNFILENAME;
|
||||||
static const long UNKNOWNLINENUMBER;
|
static const long UNKNOWNLINENUMBER;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
virtual Exception *clone() const;
|
virtual Exception *clone() const;
|
||||||
|
|
||||||
virtual bool isInstanceOf( const Type &type ) const;
|
virtual bool isInstanceOf( const Type &type ) const;
|
||||||
|
|
||||||
static Type type();
|
static Type type();
|
||||||
@@ -68,9 +68,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
// VC++ does not recognize call to parent class when prefixed
|
// VC++ does not recognize call to parent class when prefixed
|
||||||
// with a namespace. This is a workaround.
|
// with a namespace. This is a workaround.
|
||||||
typedef exception SuperClass;
|
typedef std::exception SuperClass;
|
||||||
|
|
||||||
string m_message;
|
std::string m_message;
|
||||||
SourceLine m_sourceLine;
|
SourceLine m_sourceLine;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -19,16 +19,16 @@ public:
|
|||||||
* \param additionalMessage Additionnal information provided to further qualify
|
* \param additionalMessage Additionnal information provided to further qualify
|
||||||
* the inequality.
|
* the inequality.
|
||||||
*/
|
*/
|
||||||
NotEqualException( string expected,
|
NotEqualException( std::string expected,
|
||||||
string actual,
|
std::string actual,
|
||||||
SourceLine sourceLine = SourceLine(),
|
SourceLine sourceLine = SourceLine(),
|
||||||
string additionalMessage = "" );
|
std::string additionalMessage = "" );
|
||||||
|
|
||||||
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
|
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
|
||||||
NotEqualException( string expected,
|
NotEqualException( std::string expected,
|
||||||
string actual,
|
std::string actual,
|
||||||
long lineNumber,
|
long lineNumber,
|
||||||
string fileName );
|
std::string fileName );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NotEqualException( const NotEqualException &other );
|
NotEqualException( const NotEqualException &other );
|
||||||
@@ -36,11 +36,11 @@ public:
|
|||||||
|
|
||||||
virtual ~NotEqualException() throw();
|
virtual ~NotEqualException() throw();
|
||||||
|
|
||||||
string expectedValue() const;
|
std::string expectedValue() const;
|
||||||
|
|
||||||
string actualValue() const;
|
std::string actualValue() const;
|
||||||
|
|
||||||
string additionalMessage() const;
|
std::string additionalMessage() const;
|
||||||
|
|
||||||
/*! Copy operator.
|
/*! Copy operator.
|
||||||
* @param other Object to copy.
|
* @param other Object to copy.
|
||||||
@@ -55,9 +55,9 @@ public:
|
|||||||
static Type type();
|
static Type type();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string m_expected;
|
std::string m_expected;
|
||||||
string m_actual;
|
std::string m_actual;
|
||||||
string m_additionalMessage;
|
std::string m_additionalMessage;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace CppUnit
|
} // namespace CppUnit
|
||||||
|
|||||||
@@ -21,6 +21,10 @@
|
|||||||
#undef CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST
|
#undef CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if __GNUC__ > 2
|
||||||
|
#undef CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Define to 1 if you wish to have the old-style macros
|
/* Define to 1 if you wish to have the old-style macros
|
||||||
assert(), assertEqual(), assertDoublesEqual(), and assertLongsEqual() */
|
assert(), assertEqual(), assertDoublesEqual(), and assertLongsEqual() */
|
||||||
#ifndef CPPUNIT_ENABLE_NAKED_ASSERT
|
#ifndef CPPUNIT_ENABLE_NAKED_ASSERT
|
||||||
@@ -33,7 +37,7 @@
|
|||||||
#define CPPUNIT_ENABLE_CU_TEST_MACROS 0
|
#define CPPUNIT_ENABLE_CU_TEST_MACROS 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Define to 1 if the preprocessor expands (#foo) to "foo" (quotes incl.)
|
/* Define to 1 if the preprocessor expands (#foo) to "foo" (quotes incl.)
|
||||||
I don't think there is any C preprocess that does NOT support this! */
|
I don't think there is any C preprocess that does NOT support this! */
|
||||||
#ifndef CPPUNIT_HAVE_CPP_SOURCE_ANNOTATION
|
#ifndef CPPUNIT_HAVE_CPP_SOURCE_ANNOTATION
|
||||||
#define CPPUNIT_HAVE_CPP_SOURCE_ANNOTATION 1
|
#define CPPUNIT_HAVE_CPP_SOURCE_ANNOTATION 1
|
||||||
@@ -60,11 +64,11 @@
|
|||||||
#if CPPUNIT_HAVE_SSTREAM
|
#if CPPUNIT_HAVE_SSTREAM
|
||||||
# include <sstream>
|
# include <sstream>
|
||||||
namespace CppUnit {
|
namespace CppUnit {
|
||||||
class OStringStream : public ostringstream
|
class OStringStream : public ostringstream
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#if CPPUNIT_HAVE_CLASS_STRSTREAM
|
#if CPPUNIT_HAVE_CLASS_STRSTREAM
|
||||||
# include <string>
|
# include <string>
|
||||||
# if CPPUNIT_HAVE_STRSTREAM
|
# if CPPUNIT_HAVE_STRSTREAM
|
||||||
@@ -74,14 +78,14 @@
|
|||||||
# endif
|
# endif
|
||||||
|
|
||||||
namespace CppUnit {
|
namespace CppUnit {
|
||||||
class OStringStream : public ostrstream
|
class OStringStream : public std::ostrstream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
string str()
|
std::string str()
|
||||||
{
|
{
|
||||||
(*this) << '\0';
|
(*this) << '\0';
|
||||||
string msg(ostrstream::str());
|
std::string msg(std::ostrstream::str());
|
||||||
ostrstream::freeze(false);
|
std::ostrstream::freeze(false);
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace CppUnit
|
|||||||
* \ingroup BrowsingCollectedTestResult
|
* \ingroup BrowsingCollectedTestResult
|
||||||
*
|
*
|
||||||
* Used to capture the failure location in assertion.
|
* Used to capture the failure location in assertion.
|
||||||
*
|
*
|
||||||
* Use the CPPUNIT_SOURCELINE() macro to construct that object. Typically used when
|
* Use the CPPUNIT_SOURCELINE() macro to construct that object. Typically used when
|
||||||
* writing an assertion macro in association with Asserter.
|
* writing an assertion macro in association with Asserter.
|
||||||
*
|
*
|
||||||
@@ -32,7 +32,7 @@ class CPPUNIT_API SourceLine
|
|||||||
public:
|
public:
|
||||||
SourceLine();
|
SourceLine();
|
||||||
|
|
||||||
SourceLine( const string &fileName,
|
SourceLine( const std::string &fileName,
|
||||||
int lineNumber );
|
int lineNumber );
|
||||||
|
|
||||||
/// Destructor.
|
/// Destructor.
|
||||||
@@ -42,13 +42,13 @@ public:
|
|||||||
|
|
||||||
int lineNumber() const;
|
int lineNumber() const;
|
||||||
|
|
||||||
string fileName() const;
|
std::string fileName() const;
|
||||||
|
|
||||||
bool operator ==( const SourceLine &other ) const;
|
bool operator ==( const SourceLine &other ) const;
|
||||||
bool operator !=( const SourceLine &other ) const;
|
bool operator !=( const SourceLine &other ) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string m_fileName;
|
std::string m_fileName;
|
||||||
int m_lineNumber;
|
int m_lineNumber;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class TestResult;
|
|||||||
*
|
*
|
||||||
* All test objects should be a subclass of Test. Some test objects,
|
* All test objects should be a subclass of Test. Some test objects,
|
||||||
* TestCase for example, represent one individual test. Other test
|
* TestCase for example, represent one individual test. Other test
|
||||||
* objects, such as TestSuite, are comprised of several tests.
|
* objects, such as TestSuite, are comprised of several tests.
|
||||||
*
|
*
|
||||||
* When a Test is run, the result is collected by a TestResult object.
|
* When a Test is run, the result is collected by a TestResult object.
|
||||||
*
|
*
|
||||||
@@ -38,20 +38,20 @@ public:
|
|||||||
virtual int countTestCases () const = 0;
|
virtual int countTestCases () const = 0;
|
||||||
|
|
||||||
/*! \brief Returns the test name.
|
/*! \brief Returns the test name.
|
||||||
*
|
*
|
||||||
* Each test has a name. This name may be used to find the
|
* Each test has a name. This name may be used to find the
|
||||||
* test in a suite or registry of tests.
|
* test in a suite or registry of tests.
|
||||||
*/
|
*/
|
||||||
virtual string getName () const = 0;
|
virtual std::string getName () const = 0;
|
||||||
|
|
||||||
/*! \brief Description of the test, for diagnostic output.
|
/*! \brief Description of the test, for diagnostic output.
|
||||||
*
|
*
|
||||||
* The test description will typically include the test name,
|
* The test description will typically include the test name,
|
||||||
* but may have additional description. For example, a test
|
* but may have additional description. For example, a test
|
||||||
* suite named <tt>complex_add</tt> may be described as
|
* suite named <tt>complex_add</tt> may be described as
|
||||||
* <tt>suite complex_add</tt>.
|
* <tt>suite complex_add</tt>.
|
||||||
*/
|
*/
|
||||||
virtual string toString () const = 0;
|
virtual std::string toString () const = 0;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace CppUnit {
|
|||||||
* {
|
* {
|
||||||
* return x == y;
|
* return x == y;
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* static string toString( const string& x )
|
* static string toString( const string& x )
|
||||||
* {
|
* {
|
||||||
* string text = '"' + x + '"'; // adds quote around the string to see whitespace
|
* string text = '"' + x + '"'; // adds quote around the string to see whitespace
|
||||||
@@ -32,14 +32,14 @@ namespace CppUnit {
|
|||||||
* \endcode
|
* \endcode
|
||||||
*/
|
*/
|
||||||
template <class T>
|
template <class T>
|
||||||
struct assertion_traits
|
struct assertion_traits
|
||||||
{
|
{
|
||||||
static bool equal( const T& x, const T& y )
|
static bool equal( const T& x, const T& y )
|
||||||
{
|
{
|
||||||
return x == y;
|
return x == y;
|
||||||
}
|
}
|
||||||
|
|
||||||
static string toString( const T& x )
|
static std::string toString( const T& x )
|
||||||
{
|
{
|
||||||
OStringStream ost;
|
OStringStream ost;
|
||||||
ost << x;
|
ost << x;
|
||||||
@@ -51,37 +51,37 @@ namespace CppUnit {
|
|||||||
namespace TestAssert
|
namespace TestAssert
|
||||||
{
|
{
|
||||||
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
|
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
|
||||||
void CPPUNIT_API assertImplementation( bool condition,
|
void CPPUNIT_API assertImplementation( bool condition,
|
||||||
string conditionExpression = "",
|
std::string conditionExpression = "",
|
||||||
long lineNumber,
|
long lineNumber,
|
||||||
string fileName );
|
std::string fileName );
|
||||||
|
|
||||||
void CPPUNIT_API assertNotEqualImplementation( string expected,
|
void CPPUNIT_API assertNotEqualImplementation( std::string expected,
|
||||||
string actual,
|
std::string actual,
|
||||||
long lineNumber,
|
long lineNumber,
|
||||||
string fileName );
|
std::string fileName );
|
||||||
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void assertEquals( const T& expected,
|
void assertEquals( const T& expected,
|
||||||
const T& actual,
|
const T& actual,
|
||||||
long lineNumber,
|
long lineNumber,
|
||||||
string fileName )
|
std::string fileName )
|
||||||
{
|
{
|
||||||
if ( !assertion_traits<T>::equal(expected,actual) ) // lazy toString conversion...
|
if ( !assertion_traits<T>::equal(expected,actual) ) // lazy toString conversion...
|
||||||
{
|
{
|
||||||
assertNotEqualImplementation( assertion_traits<T>::toString(expected),
|
assertNotEqualImplementation( assertion_traits<T>::toString(expected),
|
||||||
assertion_traits<T>::toString(actual),
|
assertion_traits<T>::toString(actual),
|
||||||
lineNumber,
|
lineNumber,
|
||||||
fileName );
|
fileName );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPPUNIT_API assertEquals( double expected,
|
void CPPUNIT_API assertEquals( double expected,
|
||||||
double actual,
|
double actual,
|
||||||
double delta,
|
double delta,
|
||||||
long lineNumber,
|
long lineNumber,
|
||||||
string fileName );
|
std::string fileName );
|
||||||
|
|
||||||
#else // using SourceLine
|
#else // using SourceLine
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ namespace CppUnit {
|
|||||||
void assertEquals( const T& expected,
|
void assertEquals( const T& expected,
|
||||||
const T& actual,
|
const T& actual,
|
||||||
SourceLine sourceLine,
|
SourceLine sourceLine,
|
||||||
const string &message ="" )
|
const std::string &message ="" )
|
||||||
{
|
{
|
||||||
if ( !assertion_traits<T>::equal(expected,actual) ) // lazy toString conversion...
|
if ( !assertion_traits<T>::equal(expected,actual) ) // lazy toString conversion...
|
||||||
{
|
{
|
||||||
@@ -167,7 +167,7 @@ namespace CppUnit {
|
|||||||
* Requirement for \a expected and \a actual parameters:
|
* Requirement for \a expected and \a actual parameters:
|
||||||
* - They are exactly of the same type
|
* - They are exactly of the same type
|
||||||
* - They are serializable into a strstream using operator <<.
|
* - They are serializable into a strstream using operator <<.
|
||||||
* - They can be compared using operator ==.
|
* - They can be compared using operator ==.
|
||||||
*
|
*
|
||||||
* The last two requirements (serialization and comparison) can be
|
* The last two requirements (serialization and comparison) can be
|
||||||
* removed by specializing the CppUnit::assertion_traits.
|
* removed by specializing the CppUnit::assertion_traits.
|
||||||
@@ -190,7 +190,7 @@ namespace CppUnit {
|
|||||||
* Requirement for \a expected and \a actual parameters:
|
* Requirement for \a expected and \a actual parameters:
|
||||||
* - They are exactly of the same type
|
* - They are exactly of the same type
|
||||||
* - They are serializable into a strstream using operator <<.
|
* - They are serializable into a strstream using operator <<.
|
||||||
* - They can be compared using operator ==.
|
* - They can be compared using operator ==.
|
||||||
*
|
*
|
||||||
* The last two requirements (serialization and comparison) can be
|
* The last two requirements (serialization and comparison) can be
|
||||||
* removed by specializing the CppUnit::assertion_traits.
|
* removed by specializing the CppUnit::assertion_traits.
|
||||||
|
|||||||
@@ -33,18 +33,18 @@ struct ExpectedExceptionTraits
|
|||||||
static void expectedException()
|
static void expectedException()
|
||||||
{
|
{
|
||||||
#if CPPUNIT_USE_TYPEINFO_NAME
|
#if CPPUNIT_USE_TYPEINFO_NAME
|
||||||
string message( "Expected exception of type " );
|
std::string message( "Expected exception of type " );
|
||||||
message += TypeInfoHelper::getClassName( typeid( ExceptionType ) );
|
message += TypeInfoHelper::getClassName( typeid( ExceptionType ) );
|
||||||
message += ", but got none";
|
message += ", but got none";
|
||||||
#else
|
#else
|
||||||
string message( "Expected exception but got none" );
|
std::string message( "Expected exception but got none" );
|
||||||
#endif
|
#endif
|
||||||
throw Exception( message );
|
throw Exception( message );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*! \brief (Implementation) Traits specialization used by TestCaller to
|
/*! \brief (Implementation) Traits specialization used by TestCaller to
|
||||||
* expect no exception.
|
* expect no exception.
|
||||||
*
|
*
|
||||||
* This class is an implementation detail. You should never use this class directly.
|
* This class is an implementation detail. You should never use this class directly.
|
||||||
@@ -65,13 +65,13 @@ struct ExpectedExceptionTraits<NoExceptionExpected>
|
|||||||
/*! \brief Generate a test case from a fixture method.
|
/*! \brief Generate a test case from a fixture method.
|
||||||
* \ingroup WritingTestFixture
|
* \ingroup WritingTestFixture
|
||||||
*
|
*
|
||||||
* A test caller provides access to a test case method
|
* A test caller provides access to a test case method
|
||||||
* on a test fixture class. Test callers are useful when
|
* on a test fixture class. Test callers are useful when
|
||||||
* you want to run an individual test or add it to a
|
* you want to run an individual test or add it to a
|
||||||
* suite.
|
* suite.
|
||||||
* Test Callers invoke only one Test (i.e. test method) on one
|
* Test Callers invoke only one Test (i.e. test method) on one
|
||||||
* Fixture of a TestFixture.
|
* Fixture of a TestFixture.
|
||||||
*
|
*
|
||||||
* Here is an example:
|
* Here is an example:
|
||||||
* \code
|
* \code
|
||||||
* class MathTest : public CppUnit::TestFixture {
|
* class MathTest : public CppUnit::TestFixture {
|
||||||
@@ -94,16 +94,16 @@ struct ExpectedExceptionTraits<NoExceptionExpected>
|
|||||||
*
|
*
|
||||||
* You can use a TestCaller to bind any test method on a TestFixture
|
* You can use a TestCaller to bind any test method on a TestFixture
|
||||||
* class, as long as it accepts void and returns void.
|
* class, as long as it accepts void and returns void.
|
||||||
*
|
*
|
||||||
* \see TestCase
|
* \see TestCase
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template <typename Fixture,
|
template <typename Fixture,
|
||||||
typename ExpectedException = NoExceptionExpected>
|
typename ExpectedException = NoExceptionExpected>
|
||||||
class TestCaller : public TestCase
|
class TestCaller : public TestCase
|
||||||
{
|
{
|
||||||
typedef void (Fixture::*TestMethod)();
|
typedef void (Fixture::*TestMethod)();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
* Constructor for TestCaller. This constructor builds a new Fixture
|
* Constructor for TestCaller. This constructor builds a new Fixture
|
||||||
@@ -111,8 +111,8 @@ public:
|
|||||||
* \param name name of this TestCaller
|
* \param name name of this TestCaller
|
||||||
* \param test the method this TestCaller calls in runTest()
|
* \param test the method this TestCaller calls in runTest()
|
||||||
*/
|
*/
|
||||||
TestCaller( string name, TestMethod test ) :
|
TestCaller( std::string name, TestMethod test ) :
|
||||||
TestCase( name ),
|
TestCase( name ),
|
||||||
m_ownFixture( true ),
|
m_ownFixture( true ),
|
||||||
m_fixture( new Fixture() ),
|
m_fixture( new Fixture() ),
|
||||||
m_test( test )
|
m_test( test )
|
||||||
@@ -120,7 +120,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Constructor for TestCaller.
|
* Constructor for TestCaller.
|
||||||
* This constructor does not create a new Fixture instance but accepts
|
* This constructor does not create a new Fixture instance but accepts
|
||||||
* an existing one as parameter. The TestCaller will not own the
|
* an existing one as parameter. The TestCaller will not own the
|
||||||
* Fixture object.
|
* Fixture object.
|
||||||
@@ -128,16 +128,16 @@ public:
|
|||||||
* \param test the method this TestCaller calls in runTest()
|
* \param test the method this TestCaller calls in runTest()
|
||||||
* \param fixture the Fixture to invoke the test method on.
|
* \param fixture the Fixture to invoke the test method on.
|
||||||
*/
|
*/
|
||||||
TestCaller(string name, TestMethod test, Fixture& fixture) :
|
TestCaller(std::string name, TestMethod test, Fixture& fixture) :
|
||||||
TestCase( name ),
|
TestCase( name ),
|
||||||
m_ownFixture( false ),
|
m_ownFixture( false ),
|
||||||
m_fixture( &fixture ),
|
m_fixture( &fixture ),
|
||||||
m_test( test )
|
m_test( test )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Constructor for TestCaller.
|
* Constructor for TestCaller.
|
||||||
* This constructor does not create a new Fixture instance but accepts
|
* This constructor does not create a new Fixture instance but accepts
|
||||||
* an existing one as parameter. The TestCaller will own the
|
* an existing one as parameter. The TestCaller will own the
|
||||||
* Fixture object and delete it in its destructor.
|
* Fixture object and delete it in its destructor.
|
||||||
@@ -145,15 +145,15 @@ public:
|
|||||||
* \param test the method this TestCaller calls in runTest()
|
* \param test the method this TestCaller calls in runTest()
|
||||||
* \param fixture the Fixture to invoke the test method on.
|
* \param fixture the Fixture to invoke the test method on.
|
||||||
*/
|
*/
|
||||||
TestCaller(string name, TestMethod test, Fixture* fixture) :
|
TestCaller(std::string name, TestMethod test, Fixture* fixture) :
|
||||||
TestCase( name ),
|
TestCase( name ),
|
||||||
m_ownFixture( true ),
|
m_ownFixture( true ),
|
||||||
m_fixture( fixture ),
|
m_fixture( fixture ),
|
||||||
m_test( test )
|
m_test( test )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~TestCaller()
|
~TestCaller()
|
||||||
{
|
{
|
||||||
if (m_ownFixture)
|
if (m_ownFixture)
|
||||||
delete m_fixture;
|
delete m_fixture;
|
||||||
@@ -161,7 +161,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void runTest()
|
void runTest()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
(m_fixture->*m_test)();
|
(m_fixture->*m_test)();
|
||||||
}
|
}
|
||||||
@@ -170,25 +170,25 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
ExpectedExceptionTraits<ExpectedException>::expectedException();
|
ExpectedExceptionTraits<ExpectedException>::expectedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setUp()
|
void setUp()
|
||||||
{
|
{
|
||||||
m_fixture->setUp ();
|
m_fixture->setUp ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void tearDown()
|
void tearDown()
|
||||||
{
|
{
|
||||||
m_fixture->tearDown ();
|
m_fixture->tearDown ();
|
||||||
}
|
}
|
||||||
|
|
||||||
string toString() const
|
std::string toString() const
|
||||||
{
|
{
|
||||||
return "TestCaller " + getName();
|
return "TestCaller " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TestCaller( const TestCaller &other );
|
TestCaller( const TestCaller &other );
|
||||||
TestCaller &operator =( const TestCaller &other );
|
TestCaller &operator =( const TestCaller &other );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -28,34 +28,34 @@ class CPPUNIT_API TestCase : public Test,
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TestCase( string Name );
|
TestCase( std::string Name );
|
||||||
//! \internal
|
//! \internal
|
||||||
TestCase();
|
TestCase();
|
||||||
~TestCase();
|
~TestCase();
|
||||||
|
|
||||||
virtual void run(TestResult *result);
|
virtual void run(TestResult *result);
|
||||||
virtual int countTestCases() const;
|
virtual int countTestCases() const;
|
||||||
string getName() const;
|
std::string getName() const;
|
||||||
string toString() const;
|
std::string toString() const;
|
||||||
|
|
||||||
//! FIXME: what is this for?
|
//! FIXME: what is this for?
|
||||||
virtual TestResult *run();
|
virtual TestResult *run();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! FIXME: this should probably be pure virtual.
|
//! FIXME: this should probably be pure virtual.
|
||||||
virtual void runTest();
|
virtual void runTest();
|
||||||
|
|
||||||
//! Create TestResult for the run(void) method.
|
//! Create TestResult for the run(void) method.
|
||||||
TestResult *defaultResult();
|
TestResult *defaultResult();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TestCase( const TestCase &other );
|
TestCase( const TestCase &other );
|
||||||
TestCase &operator=( const TestCase &other );
|
TestCase &operator=( const TestCase &other );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const string m_name;
|
const std::string m_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace CppUnit
|
} // namespace CppUnit
|
||||||
|
|
||||||
#endif // CPPUNIT_TESTCASE_H
|
#endif // CPPUNIT_TESTCASE_H
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class Test;
|
|||||||
* TestFailure assumes lifetime control for any exception
|
* TestFailure assumes lifetime control for any exception
|
||||||
* passed to it.
|
* passed to it.
|
||||||
*/
|
*/
|
||||||
class CPPUNIT_API TestFailure
|
class CPPUNIT_API TestFailure
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TestFailure( Test *failedTest,
|
TestFailure( Test *failedTest,
|
||||||
@@ -37,9 +37,9 @@ public:
|
|||||||
|
|
||||||
virtual bool isError() const;
|
virtual bool isError() const;
|
||||||
|
|
||||||
virtual string failedTestName() const;
|
virtual std::string failedTestName() const;
|
||||||
|
|
||||||
virtual string toString() const;
|
virtual std::string toString() const;
|
||||||
|
|
||||||
virtual TestFailure *clone() const;
|
virtual TestFailure *clone() const;
|
||||||
|
|
||||||
@@ -48,9 +48,9 @@ protected:
|
|||||||
Exception *m_thrownException;
|
Exception *m_thrownException;
|
||||||
bool m_isError;
|
bool m_isError;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TestFailure( const TestFailure &other );
|
TestFailure( const TestFailure &other );
|
||||||
TestFailure &operator =( const TestFailure& other );
|
TestFailure &operator =( const TestFailure& other );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,9 +35,9 @@ class TestListener;
|
|||||||
* TestResult supplies a template method 'setSynchronizationObject()'
|
* TestResult supplies a template method 'setSynchronizationObject()'
|
||||||
* so that subclasses can provide mutual exclusion in the face of multiple
|
* so that subclasses can provide mutual exclusion in the face of multiple
|
||||||
* threads. This can be useful when tests execute in one thread and
|
* threads. This can be useful when tests execute in one thread and
|
||||||
* they fill a subclass of TestResult which effects change in another
|
* they fill a subclass of TestResult which effects change in another
|
||||||
* thread. To have mutual exclusion, override setSynchronizationObject()
|
* thread. To have mutual exclusion, override setSynchronizationObject()
|
||||||
* and make sure that you create an instance of ExclusiveZone at the
|
* and make sure that you create an instance of ExclusiveZone at the
|
||||||
* beginning of each method.
|
* beginning of each method.
|
||||||
*
|
*
|
||||||
* \see Test, TestListener, TestResultCollector, Outputter.
|
* \see Test, TestListener, TestResultCollector, Outputter.
|
||||||
@@ -63,13 +63,13 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void addFailure( const TestFailure &failure );
|
void addFailure( const TestFailure &failure );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
typedef deque<TestListener *> TestListeners;
|
typedef std::deque<TestListener *> TestListeners;
|
||||||
TestListeners m_listeners;
|
TestListeners m_listeners;
|
||||||
bool m_stop;
|
bool m_stop;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TestResult( const TestResult &other );
|
TestResult( const TestResult &other );
|
||||||
TestResult &operator =( const TestResult &other );
|
TestResult &operator =( const TestResult &other );
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ namespace CppUnit
|
|||||||
/*! \brief Collects test result.
|
/*! \brief Collects test result.
|
||||||
* \ingroup WritingTestResult
|
* \ingroup WritingTestResult
|
||||||
* \ingroup BrowsingCollectedTestResult
|
* \ingroup BrowsingCollectedTestResult
|
||||||
*
|
*
|
||||||
* A TestResultCollector is a TestListener which collects the results of executing
|
* A TestResultCollector is a TestListener which collects the results of executing
|
||||||
* a test case. It is an instance of the Collecting Parameter pattern.
|
* a test case. It is an instance of the Collecting Parameter pattern.
|
||||||
*
|
*
|
||||||
* The test framework distinguishes between failures and errors.
|
* The test framework distinguishes between failures and errors.
|
||||||
@@ -38,8 +38,8 @@ namespace CppUnit
|
|||||||
class CPPUNIT_API TestResultCollector : public TestSucessListener
|
class CPPUNIT_API TestResultCollector : public TestSucessListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef deque<TestFailure *> TestFailures;
|
typedef std::deque<TestFailure *> TestFailures;
|
||||||
typedef deque<Test *> Tests;
|
typedef std::deque<Test *> Tests;
|
||||||
|
|
||||||
|
|
||||||
/*! Constructs a TestResultCollector object.
|
/*! Constructs a TestResultCollector object.
|
||||||
|
|||||||
@@ -12,6 +12,9 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
namespace CppUnit {
|
namespace CppUnit {
|
||||||
|
|
||||||
class TestResult;
|
class TestResult;
|
||||||
@@ -36,7 +39,7 @@ class TestResult;
|
|||||||
* control for any tests added to them.
|
* control for any tests added to them.
|
||||||
*
|
*
|
||||||
* TestSuites do not register themselves in the TestRegistry.
|
* TestSuites do not register themselves in the TestRegistry.
|
||||||
* \see Test
|
* \see Test
|
||||||
* \see TestCaller
|
* \see TestCaller
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -59,7 +62,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
TestSuite( const TestSuite &other );
|
TestSuite( const TestSuite &other );
|
||||||
TestSuite &operator =( const TestSuite &other );
|
TestSuite &operator =( const TestSuite &other );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vector<Test *> m_tests;
|
vector<Test *> m_tests;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class CPPUNIT_API TextOutputter : public Outputter
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TextOutputter( TestResultCollector *result,
|
TextOutputter( TestResultCollector *result,
|
||||||
ostream &stream );
|
std::ostream &stream );
|
||||||
|
|
||||||
/// Destructor.
|
/// Destructor.
|
||||||
virtual ~TextOutputter();
|
virtual ~TextOutputter();
|
||||||
@@ -42,7 +42,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
TestResultCollector *m_result;
|
TestResultCollector *m_result;
|
||||||
ostream &m_stream;
|
std::ostream &m_stream;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Prevents the use of the copy constructor.
|
/// Prevents the use of the copy constructor.
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class Test;
|
|||||||
|
|
||||||
/*! \brief Holds printable test result (DEPRECATED).
|
/*! \brief Holds printable test result (DEPRECATED).
|
||||||
* \ingroup TrackingTestExecution
|
* \ingroup TrackingTestExecution
|
||||||
*
|
*
|
||||||
* deprecated Use class TextTestProgressListener and TextOutputter instead.
|
* deprecated Use class TextTestProgressListener and TextOutputter instead.
|
||||||
*/
|
*/
|
||||||
class CPPUNIT_API TextTestResult : public TestResult,
|
class CPPUNIT_API TextTestResult : public TestResult,
|
||||||
@@ -25,29 +25,29 @@ public:
|
|||||||
virtual void addFailure( Test *test, Exception *e );
|
virtual void addFailure( Test *test, Exception *e );
|
||||||
virtual void addFailure( const TestFailure &failure );
|
virtual void addFailure( const TestFailure &failure );
|
||||||
virtual void startTest( Test *test );
|
virtual void startTest( Test *test );
|
||||||
virtual void print( ostream &stream );
|
virtual void print( std::ostream &stream );
|
||||||
virtual void printFailures( ostream &stream );
|
virtual void printFailures( std::ostream &stream );
|
||||||
virtual void printHeader( ostream &stream );
|
virtual void printHeader( std::ostream &stream );
|
||||||
|
|
||||||
virtual void printFailure( TestFailure *failure,
|
virtual void printFailure( TestFailure *failure,
|
||||||
int failureNumber,
|
int failureNumber,
|
||||||
ostream &stream );
|
std::ostream &stream );
|
||||||
virtual void printFailureListMark( int failureNumber,
|
virtual void printFailureListMark( int failureNumber,
|
||||||
ostream &stream );
|
std::ostream &stream );
|
||||||
virtual void printFailureTestName( TestFailure *failure,
|
virtual void printFailureTestName( TestFailure *failure,
|
||||||
ostream &stream );
|
std::ostream &stream );
|
||||||
virtual void printFailureType( TestFailure *failure,
|
virtual void printFailureType( TestFailure *failure,
|
||||||
ostream &stream );
|
std::ostream &stream );
|
||||||
virtual void printFailureLocation( SourceLine sourceLine,
|
virtual void printFailureLocation( SourceLine sourceLine,
|
||||||
ostream &stream );
|
std::ostream &stream );
|
||||||
virtual void printFailureDetail( Exception *thrownException,
|
virtual void printFailureDetail( Exception *thrownException,
|
||||||
ostream &stream );
|
std::ostream &stream );
|
||||||
virtual void printFailureWarning( ostream &stream );
|
virtual void printFailureWarning( std::ostream &stream );
|
||||||
virtual void printStatistics( ostream &stream );
|
virtual void printStatistics( std::ostream &stream );
|
||||||
};
|
};
|
||||||
|
|
||||||
/** insertion operator for easy output */
|
/** insertion operator for easy output */
|
||||||
ostream &operator <<( ostream &stream,
|
std::ostream &operator <<( std::ostream &stream,
|
||||||
TextTestResult &result );
|
TextTestResult &result );
|
||||||
|
|
||||||
} // namespace CppUnit
|
} // namespace CppUnit
|
||||||
|
|||||||
@@ -33,11 +33,11 @@ public:
|
|||||||
/*! Constructs a XmlOutputter object.
|
/*! Constructs a XmlOutputter object.
|
||||||
* \param result Result of the test run.
|
* \param result Result of the test run.
|
||||||
* \param stream Stream used to output the XML output.
|
* \param stream Stream used to output the XML output.
|
||||||
* \param encoding Encoding used in the XML file (default is Latin-1).
|
* \param encoding Encoding used in the XML file (default is Latin-1).
|
||||||
*/
|
*/
|
||||||
XmlOutputter( TestResultCollector *result,
|
XmlOutputter( TestResultCollector *result,
|
||||||
ostream &stream,
|
std::ostream &stream,
|
||||||
string encoding = "ISO-8859-1" );
|
std::string encoding = "ISO-8859-1" );
|
||||||
|
|
||||||
/// Destructor.
|
/// Destructor.
|
||||||
virtual ~XmlOutputter();
|
virtual ~XmlOutputter();
|
||||||
@@ -56,33 +56,33 @@ public:
|
|||||||
class CPPUNIT_API Node
|
class CPPUNIT_API Node
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Node( string elementName,
|
Node( std::string elementName,
|
||||||
string content ="" );
|
std::string content ="" );
|
||||||
Node( string elementName,
|
Node( std::string elementName,
|
||||||
int numericContent );
|
int numericContent );
|
||||||
virtual ~Node();
|
virtual ~Node();
|
||||||
|
|
||||||
void addAttribute( string attributeName,
|
void addAttribute( std::string attributeName,
|
||||||
string value );
|
std::string value );
|
||||||
void addAttribute( string attributeName,
|
void addAttribute( std::string attributeName,
|
||||||
int numericValue );
|
int numericValue );
|
||||||
void addNode( Node *node );
|
void addNode( Node *node );
|
||||||
|
|
||||||
string toString() const;
|
std::string toString() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef pair<string,string> Attribute;
|
typedef std::pair<std::string,std::string> Attribute;
|
||||||
|
|
||||||
string attributesAsString() const;
|
std::string attributesAsString() const;
|
||||||
string escape( string value ) const;
|
std::string escape( std::string value ) const;
|
||||||
static string asString( int value );
|
static std::string asString( int value );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string m_name;
|
std::string m_name;
|
||||||
string m_content;
|
std::string m_content;
|
||||||
typedef deque<Attribute> Attributes;
|
typedef std::deque<Attribute> Attributes;
|
||||||
Attributes m_attributes;
|
Attributes m_attributes;
|
||||||
typedef deque<Node *> Nodes;
|
typedef std::deque<Node *> Nodes;
|
||||||
Nodes m_nodes;
|
Nodes m_nodes;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ public:
|
|||||||
virtual void writeProlog();
|
virtual void writeProlog();
|
||||||
virtual void writeTestsResult();
|
virtual void writeTestsResult();
|
||||||
|
|
||||||
typedef map<Test *,TestFailure*> FailedTests;
|
typedef std::map<Test *,TestFailure*> FailedTests;
|
||||||
virtual Node *makeRootNode();
|
virtual Node *makeRootNode();
|
||||||
virtual void addFailedTests( FailedTests &failedTests,
|
virtual void addFailedTests( FailedTests &failedTests,
|
||||||
Node *rootNode );
|
Node *rootNode );
|
||||||
@@ -103,7 +103,7 @@ public:
|
|||||||
Node *testsNode );
|
Node *testsNode );
|
||||||
virtual void addFailureLocation( TestFailure *failure,
|
virtual void addFailureLocation( TestFailure *failure,
|
||||||
Node *testNode );
|
Node *testNode );
|
||||||
virtual void addSucessfulTest( Test *test,
|
virtual void addSucessfulTest( Test *test,
|
||||||
int testNumber,
|
int testNumber,
|
||||||
Node *testsNode );
|
Node *testsNode );
|
||||||
protected:
|
protected:
|
||||||
@@ -111,8 +111,8 @@ protected:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
TestResultCollector *m_result;
|
TestResultCollector *m_result;
|
||||||
ostream &m_stream;
|
std::ostream &m_stream;
|
||||||
string m_encoding;
|
std::string m_encoding;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Prevents the use of the copy constructor.
|
/// Prevents the use of the copy constructor.
|
||||||
|
|||||||
@@ -14,17 +14,17 @@ class TestResult;
|
|||||||
*
|
*
|
||||||
* Does not assume ownership of the test it decorates
|
* Does not assume ownership of the test it decorates
|
||||||
*/
|
*/
|
||||||
class CPPUNIT_API RepeatedTest : public TestDecorator
|
class CPPUNIT_API RepeatedTest : public TestDecorator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RepeatedTest( Test *test,
|
RepeatedTest( Test *test,
|
||||||
int timesRepeat ) :
|
int timesRepeat ) :
|
||||||
TestDecorator( test ),
|
TestDecorator( test ),
|
||||||
m_timesRepeat(timesRepeat) {}
|
m_timesRepeat(timesRepeat) {}
|
||||||
|
|
||||||
void run( TestResult *result );
|
void run( TestResult *result );
|
||||||
int countTestCases() const;
|
int countTestCases() const;
|
||||||
string toString() const;
|
std::string toString() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RepeatedTest( const RepeatedTest & );
|
RepeatedTest( const RepeatedTest & );
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ class TestResult;
|
|||||||
* subclass the decorater and use it to wrap the test class.
|
* subclass the decorater and use it to wrap the test class.
|
||||||
*
|
*
|
||||||
* Does not assume ownership of the test it decorates
|
* Does not assume ownership of the test it decorates
|
||||||
*/
|
*/
|
||||||
class CPPUNIT_API TestDecorator : public Test
|
class CPPUNIT_API TestDecorator : public Test
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TestDecorator (Test *test);
|
TestDecorator (Test *test);
|
||||||
@@ -25,8 +25,8 @@ public:
|
|||||||
|
|
||||||
void run (TestResult *result);
|
void run (TestResult *result);
|
||||||
int countTestCases () const;
|
int countTestCases () const;
|
||||||
string getName () const;
|
std::string getName () const;
|
||||||
string toString () const;
|
std::string toString () const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Test *m_test;
|
Test *m_test;
|
||||||
@@ -53,11 +53,11 @@ inline void TestDecorator::run (TestResult *result)
|
|||||||
{ m_test->run (result); }
|
{ m_test->run (result); }
|
||||||
|
|
||||||
|
|
||||||
inline string TestDecorator::toString () const
|
inline std::string TestDecorator::toString () const
|
||||||
{ return m_test->toString (); }
|
{ return m_test->toString (); }
|
||||||
|
|
||||||
|
|
||||||
inline string TestDecorator::getName () const
|
inline std::string TestDecorator::getName () const
|
||||||
{ return m_test->getName(); }
|
{ return m_test->getName(); }
|
||||||
|
|
||||||
} // namespace CppUnit
|
} // namespace CppUnit
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class TestSuite;
|
|||||||
* CppUnit::TestSuite *suite = registry.makeTest();
|
* CppUnit::TestSuite *suite = registry.makeTest();
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* Since a TestFactoryRegistry is a TestFactory, the named registries can be
|
* Since a TestFactoryRegistry is a TestFactory, the named registries can be
|
||||||
* registered in the unnamed registry, creating the hierarchy links.
|
* registered in the unnamed registry, creating the hierarchy links.
|
||||||
*
|
*
|
||||||
* \see TestSuiteFactory, AutoRegisterSuite
|
* \see TestSuiteFactory, AutoRegisterSuite
|
||||||
@@ -79,19 +79,19 @@ public:
|
|||||||
* \param name Name of the registry. It is the name of TestSuite returned by
|
* \param name Name of the registry. It is the name of TestSuite returned by
|
||||||
* makeTest().
|
* makeTest().
|
||||||
*/
|
*/
|
||||||
TestFactoryRegistry( string name = "All Tests" );
|
TestFactoryRegistry( std::string name = "All Tests" );
|
||||||
|
|
||||||
/// Destructor.
|
/// Destructor.
|
||||||
virtual ~TestFactoryRegistry();
|
virtual ~TestFactoryRegistry();
|
||||||
|
|
||||||
/** Returns a new TestSuite that contains the registered test.
|
/** Returns a new TestSuite that contains the registered test.
|
||||||
* \return A new TestSuite which contains all the test added using
|
* \return A new TestSuite which contains all the test added using
|
||||||
* registerFactory(TestFactory *).
|
* registerFactory(TestFactory *).
|
||||||
*/
|
*/
|
||||||
virtual Test *makeTest();
|
virtual Test *makeTest();
|
||||||
|
|
||||||
/** Returns unnamed the registry.
|
/** Returns unnamed the registry.
|
||||||
* TestSuite registered using CPPUNIT_TEST_SUITE_REGISTRATION() are registered
|
* TestSuite registered using CPPUNIT_TEST_SUITE_REGISTRATION() are registered
|
||||||
* in this registry.
|
* in this registry.
|
||||||
* \return Registry which name is "All Tests".
|
* \return Registry which name is "All Tests".
|
||||||
*/
|
*/
|
||||||
@@ -104,7 +104,7 @@ public:
|
|||||||
* \return Registry. If the registry does not exist, it is created with the
|
* \return Registry. If the registry does not exist, it is created with the
|
||||||
* specified name.
|
* specified name.
|
||||||
*/
|
*/
|
||||||
static TestFactoryRegistry &getRegistry( const string &name );
|
static TestFactoryRegistry &getRegistry( const std::string &name );
|
||||||
|
|
||||||
/** Adds the registered tests to the specified suite.
|
/** Adds the registered tests to the specified suite.
|
||||||
* \param suite Suite the tests are added to.
|
* \param suite Suite the tests are added to.
|
||||||
@@ -113,15 +113,15 @@ public:
|
|||||||
|
|
||||||
/** Adds the specified TestFactory with a specific name (DEPRECATED).
|
/** Adds the specified TestFactory with a specific name (DEPRECATED).
|
||||||
* \param name Name associated to the factory.
|
* \param name Name associated to the factory.
|
||||||
* \param factory Factory to register.
|
* \param factory Factory to register.
|
||||||
* \deprecated Use registerFactory( TestFactory *) instead.
|
* \deprecated Use registerFactory( TestFactory *) instead.
|
||||||
*/
|
*/
|
||||||
void registerFactory( const string &name,
|
void registerFactory( const std::string &name,
|
||||||
TestFactory *factory );
|
TestFactory *factory );
|
||||||
|
|
||||||
/** Adds the specified TestFactory to the registry.
|
/** Adds the specified TestFactory to the registry.
|
||||||
*
|
*
|
||||||
* \param factory Factory to register.
|
* \param factory Factory to register.
|
||||||
*/
|
*/
|
||||||
void registerFactory( TestFactory *factory );
|
void registerFactory( TestFactory *factory );
|
||||||
|
|
||||||
@@ -130,10 +130,10 @@ private:
|
|||||||
void operator =( const TestFactoryRegistry © );
|
void operator =( const TestFactoryRegistry © );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef map<string, TestFactory *> Factories;
|
typedef std::map<std::string, TestFactory *> Factories;
|
||||||
Factories m_factories;
|
Factories m_factories;
|
||||||
|
|
||||||
string m_name;
|
std::string m_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace CppUnit {
|
|||||||
* the "class" prefix. If the name is not prefixed
|
* the "class" prefix. If the name is not prefixed
|
||||||
* by "class", it is returned as this.
|
* by "class", it is returned as this.
|
||||||
*/
|
*/
|
||||||
static string getClassName( const type_info &info );
|
static std::string getClassName( const std::type_info &info );
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace CppUnit
|
} // namespace CppUnit
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
|
||||||
_EXPORT
|
_EXPORT
|
||||||
BTestCase::BTestCase(string name)
|
BTestCase::BTestCase(string name)
|
||||||
: CppUnit::TestCase(name)
|
: CppUnit::TestCase(name)
|
||||||
@@ -31,7 +33,7 @@ BTestCase::NextSubTest() {
|
|||||||
_EXPORT
|
_EXPORT
|
||||||
void
|
void
|
||||||
BTestCase::NextSubTestBlock() {
|
BTestCase::NextSubTestBlock() {
|
||||||
if (BTestShell::GlobalBeVerbose())
|
if (BTestShell::GlobalBeVerbose())
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
#include <cppunit/Test.h>
|
#include <cppunit/Test.h>
|
||||||
#include <cppunit/TestResult.h>
|
#include <cppunit/TestResult.h>
|
||||||
|
|
||||||
|
using std::map;
|
||||||
|
using std::string;
|
||||||
|
|
||||||
// Default constructor
|
// Default constructor
|
||||||
_EXPORT
|
_EXPORT
|
||||||
BTestSuite::BTestSuite( string name )
|
BTestSuite::BTestSuite( string name )
|
||||||
@@ -11,14 +14,14 @@ BTestSuite::BTestSuite( string name )
|
|||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
_EXPORT
|
_EXPORT
|
||||||
BTestSuite::~BTestSuite() {
|
BTestSuite::~BTestSuite() {
|
||||||
deleteContents();
|
deleteContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Deletes all tests in the suite.
|
// Deletes all tests in the suite.
|
||||||
_EXPORT
|
_EXPORT
|
||||||
void
|
void
|
||||||
BTestSuite::deleteContents() {
|
BTestSuite::deleteContents() {
|
||||||
for ( map<string, CppUnit::Test*>::iterator it = fTests.begin();
|
for ( map<string, CppUnit::Test*>::iterator it = fTests.begin();
|
||||||
it != fTests.end();
|
it != fTests.end();
|
||||||
@@ -30,7 +33,7 @@ BTestSuite::deleteContents() {
|
|||||||
|
|
||||||
/// Runs the tests and collects their result in a TestResult.
|
/// Runs the tests and collects their result in a TestResult.
|
||||||
_EXPORT
|
_EXPORT
|
||||||
void
|
void
|
||||||
BTestSuite::run( CppUnit::TestResult *result ) {
|
BTestSuite::run( CppUnit::TestResult *result ) {
|
||||||
for ( map<string, CppUnit::Test*>::iterator it = fTests.begin();
|
for ( map<string, CppUnit::Test*>::iterator it = fTests.begin();
|
||||||
it != fTests.end();
|
it != fTests.end();
|
||||||
@@ -47,7 +50,7 @@ BTestSuite::run( CppUnit::TestResult *result ) {
|
|||||||
|
|
||||||
// Counts the number of test cases that will be run by this test.
|
// Counts the number of test cases that will be run by this test.
|
||||||
_EXPORT
|
_EXPORT
|
||||||
int
|
int
|
||||||
BTestSuite::countTestCases() const {
|
BTestSuite::countTestCases() const {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
@@ -60,27 +63,27 @@ BTestSuite::countTestCases() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Adds a test to the suite.
|
// Adds a test to the suite.
|
||||||
_EXPORT
|
_EXPORT
|
||||||
void
|
void
|
||||||
BTestSuite::addTest(string name, CppUnit::Test *test) {
|
BTestSuite::addTest(string name, CppUnit::Test *test) {
|
||||||
fTests[name] = test;
|
fTests[name] = test;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Returns a string representation of the test suite.
|
// Returns a string representation of the test suite.
|
||||||
_EXPORT
|
_EXPORT
|
||||||
string
|
string
|
||||||
BTestSuite::toString() const {
|
BTestSuite::toString() const {
|
||||||
return "suite " + getName();
|
return "suite " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Returns the name of the test suite.
|
// Returns the name of the test suite.
|
||||||
_EXPORT
|
_EXPORT
|
||||||
string
|
string
|
||||||
BTestSuite::getName() const {
|
BTestSuite::getName() const {
|
||||||
return fName;
|
return fName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// TestApp.cpp
|
// TestApp.cpp
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
|
|||||||
@@ -7,6 +7,9 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
|
|
||||||
|
using std::cout;
|
||||||
|
using std::endl;
|
||||||
|
|
||||||
_EXPORT
|
_EXPORT
|
||||||
void
|
void
|
||||||
BTestListener::startTest( CppUnit::Test *test ) {
|
BTestListener::startTest( CppUnit::Test *test ) {
|
||||||
@@ -25,7 +28,7 @@ BTestListener::addFailure( const CppUnit::TestFailure &failure ) {
|
|||||||
cout << (failure.thrownException() != NULL
|
cout << (failure.thrownException() != NULL
|
||||||
? failure.thrownException()->what()
|
? failure.thrownException()->what()
|
||||||
: "(unknown error)");
|
: "(unknown error)");
|
||||||
cout << endl;
|
cout << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
_EXPORT
|
_EXPORT
|
||||||
@@ -38,7 +41,7 @@ BTestListener::endTest( CppUnit::Test *test ) {
|
|||||||
// cout << " - FAILED" << endl;
|
// cout << " - FAILED" << endl;
|
||||||
printTime(length);
|
printTime(length);
|
||||||
cout << endl;
|
cout << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
_EXPORT
|
_EXPORT
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -26,6 +26,10 @@
|
|||||||
# include <ElfSymbolPatcher.h>
|
# include <ElfSymbolPatcher.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
using std::cout;
|
||||||
|
using std::endl;
|
||||||
|
using std::set;
|
||||||
|
|
||||||
_EXPORT BTestShell *BTestShell::fGlobalShell = NULL;
|
_EXPORT BTestShell *BTestShell::fGlobalShell = NULL;
|
||||||
const char BTestShell::indent[] = " ";
|
const char BTestShell::indent[] = " ";
|
||||||
|
|
||||||
@@ -62,20 +66,20 @@ BTestShell::AddSuite(BTestSuite *suite) {
|
|||||||
if (suite) {
|
if (suite) {
|
||||||
if (Verbosity() >= v3)
|
if (Verbosity() >= v3)
|
||||||
cout << "Adding suite '" << suite->getName() << "'" << endl;
|
cout << "Adding suite '" << suite->getName() << "'" << endl;
|
||||||
|
|
||||||
// Add the suite
|
// Add the suite
|
||||||
fSuites[suite->getName()] = suite;
|
fSuites[suite->getName()] = suite;
|
||||||
|
|
||||||
// Add its tests
|
// Add its tests
|
||||||
const TestMap &map = suite->getTests();
|
const TestMap &map = suite->getTests();
|
||||||
for (TestMap::const_iterator i = map.begin();
|
for (TestMap::const_iterator i = map.begin();
|
||||||
i != map.end();
|
i != map.end();
|
||||||
i++) {
|
i++) {
|
||||||
AddTest(i->first, i->second);
|
AddTest(i->first, i->second);
|
||||||
if (Verbosity() >= v4 && i->second)
|
if (Verbosity() >= v4 && i->second)
|
||||||
cout << " " << i->first << endl;
|
cout << " " << i->first << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
} else
|
} else
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -121,7 +125,7 @@ BTestShell::LoadSuitesFrom(BDirectory *libDir) {
|
|||||||
} else {
|
} else {
|
||||||
// cout << " !!! err == " << err << endl;
|
// cout << " !!! err == " << err << endl;
|
||||||
}
|
}
|
||||||
if (!err)
|
if (!err)
|
||||||
err = AddSuite(func());
|
err = AddSuite(func());
|
||||||
if (!err)
|
if (!err)
|
||||||
count++;
|
count++;
|
||||||
@@ -133,11 +137,11 @@ _EXPORT
|
|||||||
int
|
int
|
||||||
BTestShell::Run(int argc, char *argv[]) {
|
BTestShell::Run(int argc, char *argv[]) {
|
||||||
// Make note of which directory we started in
|
// Make note of which directory we started in
|
||||||
UpdateTestDir(argv);
|
UpdateTestDir(argv);
|
||||||
|
|
||||||
// Parse the command line args
|
// Parse the command line args
|
||||||
if (!ProcessArguments(argc, argv))
|
if (!ProcessArguments(argc, argv))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Load any dynamically loadable tests we can find
|
// Load any dynamically loadable tests we can find
|
||||||
LoadDynamicSuites();
|
LoadDynamicSuites();
|
||||||
@@ -147,24 +151,24 @@ BTestShell::Run(int argc, char *argv[]) {
|
|||||||
if (fListTestsAndExit) {
|
if (fListTestsAndExit) {
|
||||||
PrintInstalledTests();
|
PrintInstalledTests();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the proper tests to our suite (or exit if there
|
// Add the proper tests to our suite (or exit if there
|
||||||
// are no tests installed).
|
// are no tests installed).
|
||||||
CppUnit::TestSuite suite;
|
CppUnit::TestSuite suite;
|
||||||
if (fTests.empty()) {
|
if (fTests.empty()) {
|
||||||
|
|
||||||
// No installed tests whatsoever, so bail
|
// No installed tests whatsoever, so bail
|
||||||
cout << "ERROR: No installed tests to run!" << endl;
|
cout << "ERROR: No installed tests to run!" << endl;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
} else if (fSuitesToRun.empty() && fTestsToRun.empty()) {
|
} else if (fSuitesToRun.empty() && fTestsToRun.empty()) {
|
||||||
|
|
||||||
// None specified, so run them all
|
// None specified, so run them all
|
||||||
TestMap::iterator i;
|
TestMap::iterator i;
|
||||||
for (i = fTests.begin(); i != fTests.end(); ++i)
|
for (i = fTests.begin(); i != fTests.end(); ++i)
|
||||||
suite.addTest( i->second );
|
suite.addTest( i->second );
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
set<string>::const_iterator i;
|
set<string>::const_iterator i;
|
||||||
set<string> suitesToRemove;
|
set<string> suitesToRemove;
|
||||||
@@ -187,14 +191,14 @@ BTestShell::Run(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the names of all of the suites we discovered from the
|
// Remove the names of all of the suites we discovered from the
|
||||||
// list of tests to run (unless there's also an installed individual
|
// list of tests to run (unless there's also an installed individual
|
||||||
// test of the same name).
|
// test of the same name).
|
||||||
for (i = suitesToRemove.begin(); i != suitesToRemove.end(); i++) {
|
for (i = suitesToRemove.begin(); i != suitesToRemove.end(); i++) {
|
||||||
fTestsToRun.erase(*i);
|
fTestsToRun.erase(*i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Everything still in fTestsToRun must then be an explicit test
|
// Everything still in fTestsToRun must then be an explicit test
|
||||||
for (i = fTestsToRun.begin(); i != fTestsToRun.end(); ++i) {
|
for (i = fTestsToRun.begin(); i != fTestsToRun.end(); ++i) {
|
||||||
// Make sure it's a valid test
|
// Make sure it's a valid test
|
||||||
@@ -206,9 +210,9 @@ BTestShell::Run(int argc, char *argv[]) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run all the tests
|
// Run all the tests
|
||||||
InitOutput();
|
InitOutput();
|
||||||
InstallPatches();
|
InstallPatches();
|
||||||
@@ -223,7 +227,7 @@ _EXPORT
|
|||||||
BTestShell::VerbosityLevel
|
BTestShell::VerbosityLevel
|
||||||
BTestShell::Verbosity() const {
|
BTestShell::Verbosity() const {
|
||||||
return fVerbosityLevel;
|
return fVerbosityLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
_EXPORT
|
_EXPORT
|
||||||
const char*
|
const char*
|
||||||
@@ -276,7 +280,7 @@ BTestShell::PrintHelp() {
|
|||||||
cout << "VALID ARGUMENTS: " << endl;
|
cout << "VALID ARGUMENTS: " << endl;
|
||||||
PrintValidArguments();
|
PrintValidArguments();
|
||||||
cout << endl;
|
cout << endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_EXPORT
|
_EXPORT
|
||||||
@@ -308,7 +312,7 @@ BTestShell::PrintInstalledTests() {
|
|||||||
cout << "------------------------------------------------------------------------------" << endl;
|
cout << "------------------------------------------------------------------------------" << endl;
|
||||||
cout << "Available Suites:" << endl;
|
cout << "Available Suites:" << endl;
|
||||||
cout << "------------------------------------------------------------------------------" << endl;
|
cout << "------------------------------------------------------------------------------" << endl;
|
||||||
SuiteMap::const_iterator j;
|
SuiteMap::const_iterator j;
|
||||||
for (j = fSuites.begin(); j != fSuites.end(); ++j)
|
for (j = fSuites.begin(); j != fSuites.end(); ++j)
|
||||||
cout << j->first << endl;
|
cout << j->first << endl;
|
||||||
cout << endl;
|
cout << endl;
|
||||||
@@ -317,7 +321,7 @@ BTestShell::PrintInstalledTests() {
|
|||||||
cout << "------------------------------------------------------------------------------" << endl;
|
cout << "------------------------------------------------------------------------------" << endl;
|
||||||
cout << "Available Tests:" << endl;
|
cout << "Available Tests:" << endl;
|
||||||
cout << "------------------------------------------------------------------------------" << endl;
|
cout << "------------------------------------------------------------------------------" << endl;
|
||||||
TestMap::const_iterator i;
|
TestMap::const_iterator i;
|
||||||
for (i = fTests.begin(); i != fTests.end(); ++i)
|
for (i = fTests.begin(); i != fTests.end(); ++i)
|
||||||
cout << i->first << endl;
|
cout << i->first << endl;
|
||||||
cout << endl;
|
cout << endl;
|
||||||
@@ -335,11 +339,11 @@ BTestShell::ProcessArguments(int argc, char *argv[]) {
|
|||||||
// which is just the app name)
|
// which is just the app name)
|
||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
string str(argv[i]);
|
string str(argv[i]);
|
||||||
|
|
||||||
if (!ProcessArgument(str, argc, argv))
|
if (!ProcessArgument(str, argc, argv))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -363,12 +367,12 @@ BTestShell::ProcessArgument(string arg, int argc, char *argv[]) {
|
|||||||
} else if (arg == "-v4") {
|
} else if (arg == "-v4") {
|
||||||
fVerbosityLevel = v4;
|
fVerbosityLevel = v4;
|
||||||
} else if (arg.length() >= 2 && arg[0] == '-' && arg[1] == 'l') {
|
} else if (arg.length() >= 2 && arg[0] == '-' && arg[1] == 'l') {
|
||||||
fLibDirs.insert(arg.substr(2, arg.size()-2));
|
fLibDirs.insert(arg.substr(2, arg.size()-2));
|
||||||
} else {
|
} else {
|
||||||
fTestsToRun.insert(arg);
|
fTestsToRun.insert(arg);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_EXPORT
|
_EXPORT
|
||||||
void
|
void
|
||||||
@@ -404,7 +408,7 @@ BTestShell::PrintResults() {
|
|||||||
iFailure != fResultsCollector.failures().end();
|
iFailure != fResultsCollector.failures().end();
|
||||||
++iFailure)
|
++iFailure)
|
||||||
{
|
{
|
||||||
if (!(*iFailure)->isError())
|
if (!(*iFailure)->isError())
|
||||||
cout << " " << (*iFailure)->toString() << endl;
|
cout << " " << (*iFailure)->toString() << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -414,17 +418,17 @@ BTestShell::PrintResults() {
|
|||||||
iFailure != fResultsCollector.failures().end();
|
iFailure != fResultsCollector.failures().end();
|
||||||
++iFailure)
|
++iFailure)
|
||||||
{
|
{
|
||||||
if ((*iFailure)->isError())
|
if ((*iFailure)->isError())
|
||||||
cout << " " << (*iFailure)->toString() << endl;
|
cout << " " << (*iFailure)->toString() << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
cout << "+ PASSED" << endl;
|
cout << "+ PASSED" << endl;
|
||||||
|
|
||||||
cout << endl;
|
cout << endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Print out concise results for verbosity level == 0
|
// Print out concise results for verbosity level == 0
|
||||||
@@ -433,7 +437,7 @@ BTestShell::PrintResults() {
|
|||||||
else
|
else
|
||||||
cout << "+ PASSED" << endl;
|
cout << "+ PASSED" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_EXPORT
|
_EXPORT
|
||||||
@@ -448,15 +452,15 @@ BTestShell::LoadDynamicSuites() {
|
|||||||
set<string>::iterator i;
|
set<string>::iterator i;
|
||||||
for (i = fLibDirs.begin(); i != fLibDirs.end(); i++) {
|
for (i = fLibDirs.begin(); i != fLibDirs.end(); i++) {
|
||||||
BDirectory libDir((*i).c_str());
|
BDirectory libDir((*i).c_str());
|
||||||
if (Verbosity() >= v3)
|
if (Verbosity() >= v3)
|
||||||
cout << "Checking " << *i << endl;
|
cout << "Checking " << *i << endl;
|
||||||
/* int count =*/ LoadSuitesFrom(&libDir);
|
/* int count =*/ LoadSuitesFrom(&libDir);
|
||||||
if (Verbosity() >= v3) {
|
if (Verbosity() >= v3) {
|
||||||
// cout << "Loaded " << count << " suite" << (count == 1 ? "" : "s");
|
// cout << "Loaded " << count << " suite" << (count == 1 ? "" : "s");
|
||||||
// cout << " from " << *i << endl;
|
// cout << " from " << *i << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Verbosity() >= v3)
|
if (Verbosity() >= v3)
|
||||||
cout << endl;
|
cout << endl;
|
||||||
|
|
||||||
@@ -466,11 +470,11 @@ BTestShell::LoadDynamicSuites() {
|
|||||||
if (fTests.find(i->first) != fTests.end() && Verbosity() > v0) {
|
if (fTests.find(i->first) != fTests.end() && Verbosity() > v0) {
|
||||||
cout << "WARNING: '" << i->first << "' refers to both a test suite *and* an individual" <<
|
cout << "WARNING: '" << i->first << "' refers to both a test suite *and* an individual" <<
|
||||||
endl << " test. Both will be executed, but it is reccommended you rename" <<
|
endl << " test. Both will be executed, but it is reccommended you rename" <<
|
||||||
endl << " one of them to resolve the conflict." <<
|
endl << " one of them to resolve the conflict." <<
|
||||||
endl << endl;
|
endl << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_EXPORT
|
_EXPORT
|
||||||
|
|||||||
@@ -3,8 +3,16 @@
|
|||||||
#include <TestUtils.h>
|
#include <TestUtils.h>
|
||||||
#include <TestShell.h>
|
#include <TestShell.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
using std::cout;
|
||||||
|
using std::dec;
|
||||||
|
using std::endl;
|
||||||
|
using std::hex;
|
||||||
|
using std::string;
|
||||||
|
|
||||||
_EXPORT
|
_EXPORT
|
||||||
status_t DecodeResult(status_t result) {
|
status_t DecodeResult(status_t result) {
|
||||||
if (!BTestShell::GlobalBeVerbose())
|
if (!BTestShell::GlobalBeVerbose())
|
||||||
@@ -20,134 +28,134 @@ status_t DecodeResult(status_t result) {
|
|||||||
case B_ERROR:
|
case B_ERROR:
|
||||||
str = "B_ERROR";
|
str = "B_ERROR";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
// Storage Kit Errors
|
// Storage Kit Errors
|
||||||
case B_FILE_ERROR:
|
case B_FILE_ERROR:
|
||||||
str = "B_FILE_ERROR";
|
str = "B_FILE_ERROR";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_FILE_NOT_FOUND:
|
case B_FILE_NOT_FOUND:
|
||||||
str = "B_FILE_NOT_FOUND";
|
str = "B_FILE_NOT_FOUND";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_FILE_EXISTS:
|
case B_FILE_EXISTS:
|
||||||
str = "B_FILE_EXISTS";
|
str = "B_FILE_EXISTS";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_ENTRY_NOT_FOUND:
|
case B_ENTRY_NOT_FOUND:
|
||||||
str = "B_ENTRY_NOT_FOUND";
|
str = "B_ENTRY_NOT_FOUND";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_NAME_TOO_LONG:
|
case B_NAME_TOO_LONG:
|
||||||
str = "B_NAME_TOO_LONG";
|
str = "B_NAME_TOO_LONG";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_DIRECTORY_NOT_EMPTY:
|
case B_DIRECTORY_NOT_EMPTY:
|
||||||
str = "B_DIRECTORY_NOT_EMPTY";
|
str = "B_DIRECTORY_NOT_EMPTY";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_DEVICE_FULL:
|
case B_DEVICE_FULL:
|
||||||
str = "B_DEVICE_FULL";
|
str = "B_DEVICE_FULL";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_READ_ONLY_DEVICE:
|
case B_READ_ONLY_DEVICE:
|
||||||
str = "B_READ_ONLY_DEVICE";
|
str = "B_READ_ONLY_DEVICE";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_IS_A_DIRECTORY:
|
case B_IS_A_DIRECTORY:
|
||||||
str = "B_IS_A_DIRECTORY";
|
str = "B_IS_A_DIRECTORY";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_NO_MORE_FDS:
|
case B_NO_MORE_FDS:
|
||||||
str = "B_NO_MORE_FDS";
|
str = "B_NO_MORE_FDS";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_CROSS_DEVICE_LINK:
|
case B_CROSS_DEVICE_LINK:
|
||||||
str = "B_CROSS_DEVICE_LINK";
|
str = "B_CROSS_DEVICE_LINK";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_LINK_LIMIT:
|
case B_LINK_LIMIT:
|
||||||
str = "B_LINK_LIMIT";
|
str = "B_LINK_LIMIT";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_BUSTED_PIPE:
|
case B_BUSTED_PIPE:
|
||||||
str = "B_BUSTED_PIPE";
|
str = "B_BUSTED_PIPE";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_UNSUPPORTED:
|
case B_UNSUPPORTED:
|
||||||
str = "B_UNSUPPORTED";
|
str = "B_UNSUPPORTED";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_PARTITION_TOO_SMALL:
|
case B_PARTITION_TOO_SMALL:
|
||||||
str = "B_PARTITION_TOO_SMALL";
|
str = "B_PARTITION_TOO_SMALL";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_BAD_MIME_SNIFFER_RULE:
|
case B_BAD_MIME_SNIFFER_RULE:
|
||||||
str = "B_BAD_MIME_SNIFFER_RULE";
|
str = "B_BAD_MIME_SNIFFER_RULE";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// General Errors
|
// General Errors
|
||||||
case B_NO_MEMORY:
|
case B_NO_MEMORY:
|
||||||
str = "B_NO_MEMORY";
|
str = "B_NO_MEMORY";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_IO_ERROR:
|
case B_IO_ERROR:
|
||||||
str = "B_IO_ERROR";
|
str = "B_IO_ERROR";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_PERMISSION_DENIED:
|
case B_PERMISSION_DENIED:
|
||||||
str = "B_PERMISSION_DENIED";
|
str = "B_PERMISSION_DENIED";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_BAD_INDEX:
|
case B_BAD_INDEX:
|
||||||
str = "B_BAD_INDEX";
|
str = "B_BAD_INDEX";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_BAD_TYPE:
|
case B_BAD_TYPE:
|
||||||
str = "B_BAD_TYPE";
|
str = "B_BAD_TYPE";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_BAD_VALUE:
|
case B_BAD_VALUE:
|
||||||
str = "B_BAD_VALUE";
|
str = "B_BAD_VALUE";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_MISMATCHED_VALUES:
|
case B_MISMATCHED_VALUES:
|
||||||
str = "B_MISMATCHED_VALUES";
|
str = "B_MISMATCHED_VALUES";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_NAME_NOT_FOUND:
|
case B_NAME_NOT_FOUND:
|
||||||
str = "B_NAME_NOT_FOUND";
|
str = "B_NAME_NOT_FOUND";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_NAME_IN_USE:
|
case B_NAME_IN_USE:
|
||||||
str = "B_NAME_IN_USE";
|
str = "B_NAME_IN_USE";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_TIMED_OUT:
|
case B_TIMED_OUT:
|
||||||
str = "B_TIMED_OUT";
|
str = "B_TIMED_OUT";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_INTERRUPTED:
|
case B_INTERRUPTED:
|
||||||
str = "B_INTERRUPTED";
|
str = "B_INTERRUPTED";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_WOULD_BLOCK:
|
case B_WOULD_BLOCK:
|
||||||
str = "B_WOULD_BLOCK";
|
str = "B_WOULD_BLOCK";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_CANCELED:
|
case B_CANCELED:
|
||||||
str = "B_CANCELED";
|
str = "B_CANCELED";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_NO_INIT:
|
case B_NO_INIT:
|
||||||
str = "B_NO_INIT";
|
str = "B_NO_INIT";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_BUSY:
|
case B_BUSY:
|
||||||
str = "B_BUSY";
|
str = "B_BUSY";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_NOT_ALLOWED:
|
case B_NOT_ALLOWED:
|
||||||
str = "B_NOT_ALLOWED";
|
str = "B_NOT_ALLOWED";
|
||||||
break;
|
break;
|
||||||
@@ -171,11 +179,11 @@ status_t DecodeResult(status_t result) {
|
|||||||
default:
|
default:
|
||||||
str = "??????????";
|
str = "??????????";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << endl << "DecodeResult() -- " "0x" << hex << result << " (" << dec << result << ") == " << str << endl;
|
cout << endl << "DecodeResult() -- " "0x" << hex << result << " (" << dec << result << ") == " << str << endl;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,10 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
using std::map;
|
||||||
|
using std::string;
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
_EXPORT
|
_EXPORT
|
||||||
BThreadedTestCase::BThreadedTestCase(string name, string progressSeparator)
|
BThreadedTestCase::BThreadedTestCase(string name, string progressSeparator)
|
||||||
: BTestCase(name)
|
: BTestCase(name)
|
||||||
@@ -24,7 +28,7 @@ BThreadedTestCase::~BThreadedTestCase() {
|
|||||||
i++)
|
i++)
|
||||||
{
|
{
|
||||||
delete i->second;
|
delete i->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_EXPORT
|
_EXPORT
|
||||||
@@ -47,9 +51,9 @@ BThreadedTestCase::NextSubTest() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle single-threaded case
|
// Handle single-threaded case
|
||||||
BTestCase::NextSubTest();
|
BTestCase::NextSubTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
_EXPORT
|
_EXPORT
|
||||||
@@ -62,7 +66,7 @@ BThreadedTestCase::Outputf(const char *str, ...) {
|
|||||||
{
|
{
|
||||||
BAutolock lock(fUpdateLock);
|
BAutolock lock(fUpdateLock);
|
||||||
isSingleThreaded = fNumberMap.find(id) == fNumberMap.end();
|
isSingleThreaded = fNumberMap.find(id) == fNumberMap.end();
|
||||||
}
|
}
|
||||||
if (isSingleThreaded) {
|
if (isSingleThreaded) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, str);
|
va_start(args, str);
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
#include <cppunit/NotEqualException.h>
|
#include <cppunit/NotEqualException.h>
|
||||||
|
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
|
||||||
namespace CppUnit
|
namespace CppUnit
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -10,17 +12,17 @@ namespace Asserter
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
fail( string message,
|
fail( string message,
|
||||||
SourceLine sourceLine )
|
SourceLine sourceLine )
|
||||||
{
|
{
|
||||||
throw Exception( message, sourceLine );
|
throw Exception( message, sourceLine );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
failIf( bool shouldFail,
|
failIf( bool shouldFail,
|
||||||
string message,
|
string message,
|
||||||
SourceLine location )
|
SourceLine location )
|
||||||
{
|
{
|
||||||
if ( shouldFail )
|
if ( shouldFail )
|
||||||
@@ -28,23 +30,23 @@ failIf( bool shouldFail,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
failNotEqual( string expected,
|
failNotEqual( string expected,
|
||||||
string actual,
|
string actual,
|
||||||
SourceLine sourceLine,
|
SourceLine sourceLine,
|
||||||
string additionalMessage )
|
string additionalMessage )
|
||||||
{
|
{
|
||||||
throw NotEqualException( expected,
|
throw NotEqualException( expected,
|
||||||
actual,
|
actual,
|
||||||
sourceLine,
|
sourceLine,
|
||||||
additionalMessage );
|
additionalMessage );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
failNotEqualIf( bool shouldFail,
|
failNotEqualIf( bool shouldFail,
|
||||||
string expected,
|
string expected,
|
||||||
string actual,
|
string actual,
|
||||||
SourceLine sourceLine,
|
SourceLine sourceLine,
|
||||||
string additionalMessage )
|
string additionalMessage )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
#include <cppunit/CompilerOutputter.h>
|
#include <cppunit/CompilerOutputter.h>
|
||||||
|
|
||||||
|
|
||||||
|
using std::endl;
|
||||||
|
using std::ostream;
|
||||||
|
using std::string;
|
||||||
|
|
||||||
namespace CppUnit
|
namespace CppUnit
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -32,7 +36,7 @@ CompilerOutputter::defaultOutputter( TestResultCollector *result,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CompilerOutputter::write()
|
CompilerOutputter::write()
|
||||||
{
|
{
|
||||||
if ( m_result->wasSuccessful() )
|
if ( m_result->wasSuccessful() )
|
||||||
@@ -42,15 +46,15 @@ CompilerOutputter::write()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CompilerOutputter::printSucess()
|
CompilerOutputter::printSucess()
|
||||||
{
|
{
|
||||||
m_stream << "OK (" << m_result->runTests() << ")"
|
m_stream << "OK (" << m_result->runTests() << ")"
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CompilerOutputter::printFailureReport()
|
CompilerOutputter::printFailureReport()
|
||||||
{
|
{
|
||||||
printFailuresList();
|
printFailuresList();
|
||||||
@@ -58,7 +62,7 @@ CompilerOutputter::printFailureReport()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CompilerOutputter::printFailuresList()
|
CompilerOutputter::printFailuresList()
|
||||||
{
|
{
|
||||||
for ( int index =0; index < m_result->testFailuresTotal(); ++index)
|
for ( int index =0; index < m_result->testFailuresTotal(); ++index)
|
||||||
@@ -68,7 +72,7 @@ CompilerOutputter::printFailuresList()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CompilerOutputter::printFailureDetail( TestFailure *failure )
|
CompilerOutputter::printFailureDetail( TestFailure *failure )
|
||||||
{
|
{
|
||||||
printFailureLocation( failure->sourceLine() );
|
printFailureLocation( failure->sourceLine() );
|
||||||
@@ -77,26 +81,26 @@ CompilerOutputter::printFailureDetail( TestFailure *failure )
|
|||||||
printFailureMessage( failure );
|
printFailureMessage( failure );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CompilerOutputter::printFailureLocation( SourceLine sourceLine )
|
CompilerOutputter::printFailureLocation( SourceLine sourceLine )
|
||||||
{
|
{
|
||||||
if ( sourceLine.isValid() )
|
if ( sourceLine.isValid() )
|
||||||
m_stream << sourceLine.fileName()
|
m_stream << sourceLine.fileName()
|
||||||
<< "(" << sourceLine.lineNumber() << ") : ";
|
<< "(" << sourceLine.lineNumber() << ") : ";
|
||||||
else
|
else
|
||||||
m_stream << "##Failure Location unknown## : ";
|
m_stream << "##Failure Location unknown## : ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CompilerOutputter::printFailureType( TestFailure *failure )
|
CompilerOutputter::printFailureType( TestFailure *failure )
|
||||||
{
|
{
|
||||||
m_stream << (failure->isError() ? "Error" : "Assertion");
|
m_stream << (failure->isError() ? "Error" : "Assertion");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CompilerOutputter::printFailedTestName( TestFailure *failure )
|
CompilerOutputter::printFailedTestName( TestFailure *failure )
|
||||||
{
|
{
|
||||||
m_stream << endl;
|
m_stream << endl;
|
||||||
@@ -104,7 +108,7 @@ CompilerOutputter::printFailedTestName( TestFailure *failure )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CompilerOutputter::printFailureMessage( TestFailure *failure )
|
CompilerOutputter::printFailureMessage( TestFailure *failure )
|
||||||
{
|
{
|
||||||
m_stream << endl;
|
m_stream << endl;
|
||||||
@@ -117,7 +121,7 @@ CompilerOutputter::printFailureMessage( TestFailure *failure )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CompilerOutputter::printNotEqualMessage( Exception *thrownException )
|
CompilerOutputter::printNotEqualMessage( Exception *thrownException )
|
||||||
{
|
{
|
||||||
NotEqualException *e = (NotEqualException *)thrownException;
|
NotEqualException *e = (NotEqualException *)thrownException;
|
||||||
@@ -133,7 +137,7 @@ CompilerOutputter::printNotEqualMessage( Exception *thrownException )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CompilerOutputter::printDefaultMessage( Exception *thrownException )
|
CompilerOutputter::printDefaultMessage( Exception *thrownException )
|
||||||
{
|
{
|
||||||
string wrappedMessage = wrap( thrownException->what() );
|
string wrappedMessage = wrap( thrownException->what() );
|
||||||
@@ -141,7 +145,7 @@ CompilerOutputter::printDefaultMessage( Exception *thrownException )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CompilerOutputter::printStatistics()
|
CompilerOutputter::printStatistics()
|
||||||
{
|
{
|
||||||
m_stream << "Failures !!!" << endl;
|
m_stream << "Failures !!!" << endl;
|
||||||
@@ -177,7 +181,7 @@ CompilerOutputter::wrap( string message )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CompilerOutputter::Lines
|
CompilerOutputter::Lines
|
||||||
CompilerOutputter::splitMessageIntoLines( string message )
|
CompilerOutputter::splitMessageIntoLines( string message )
|
||||||
{
|
{
|
||||||
Lines lines;
|
Lines lines;
|
||||||
@@ -185,8 +189,8 @@ CompilerOutputter::splitMessageIntoLines( string message )
|
|||||||
string::iterator itStart = message.begin();
|
string::iterator itStart = message.begin();
|
||||||
while ( true )
|
while ( true )
|
||||||
{
|
{
|
||||||
string::iterator itEol = find( itStart,
|
string::iterator itEol = find( itStart,
|
||||||
message.end(),
|
message.end(),
|
||||||
'\n' );
|
'\n' );
|
||||||
lines.push_back( message.substr( itStart - message.begin(),
|
lines.push_back( message.substr( itStart - message.begin(),
|
||||||
itEol - itStart ) );
|
itEol - itStart ) );
|
||||||
|
|||||||
@@ -18,20 +18,20 @@ const long Exception::UNKNOWNLINENUMBER = -1;
|
|||||||
|
|
||||||
|
|
||||||
/// Construct the exception
|
/// Construct the exception
|
||||||
Exception::Exception( const Exception &other ) :
|
Exception::Exception( const Exception &other ) :
|
||||||
exception( other )
|
exception( other )
|
||||||
{
|
{
|
||||||
m_message = other.m_message;
|
m_message = other.m_message;
|
||||||
m_sourceLine = other.m_sourceLine;
|
m_sourceLine = other.m_sourceLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \deprecated Use other constructor instead.
|
* \deprecated Use other constructor instead.
|
||||||
*/
|
*/
|
||||||
Exception::Exception( string message,
|
Exception::Exception( std::string message,
|
||||||
SourceLine sourceLine ) :
|
SourceLine sourceLine ) :
|
||||||
m_message( message ),
|
m_message( message ),
|
||||||
m_sourceLine( sourceLine )
|
m_sourceLine( sourceLine )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -41,10 +41,10 @@ Exception::Exception( string message,
|
|||||||
/*!
|
/*!
|
||||||
* \deprecated Use other constructor instead.
|
* \deprecated Use other constructor instead.
|
||||||
*/
|
*/
|
||||||
Exception::Exception( string message,
|
Exception::Exception( std::string message,
|
||||||
long lineNumber,
|
long lineNumber,
|
||||||
string fileName ) :
|
std::string fileName ) :
|
||||||
m_message( message ),
|
m_message( message ),
|
||||||
m_sourceLine( fileName, lineNumber )
|
m_sourceLine( fileName, lineNumber )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -58,33 +58,33 @@ Exception::~Exception () throw()
|
|||||||
|
|
||||||
|
|
||||||
/// Perform an assignment
|
/// Perform an assignment
|
||||||
Exception&
|
Exception&
|
||||||
Exception::operator =( const Exception& other )
|
Exception::operator =( const Exception& other )
|
||||||
{
|
{
|
||||||
// Don't call superclass operator =(). VC++ STL implementation
|
// Don't call superclass operator =(). VC++ STL implementation
|
||||||
// has a bug. It calls the destructor and copy constructor of
|
// has a bug. It calls the destructor and copy constructor of
|
||||||
// exception() which reset the virtual table to exception.
|
// exception() which reset the virtual table to exception.
|
||||||
// SuperClass::operator =(other);
|
// SuperClass::operator =(other);
|
||||||
|
|
||||||
if ( &other != this )
|
if ( &other != this )
|
||||||
{
|
{
|
||||||
m_message = other.m_message;
|
m_message = other.m_message;
|
||||||
m_sourceLine = other.m_sourceLine;
|
m_sourceLine = other.m_sourceLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Return descriptive message
|
/// Return descriptive message
|
||||||
const char*
|
const char*
|
||||||
Exception::what() const throw()
|
Exception::what() const throw()
|
||||||
{
|
{
|
||||||
return m_message.c_str ();
|
return m_message.c_str ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Location where the error occured
|
/// Location where the error occured
|
||||||
SourceLine
|
SourceLine
|
||||||
Exception::sourceLine() const
|
Exception::sourceLine() const
|
||||||
{
|
{
|
||||||
return m_sourceLine;
|
return m_sourceLine;
|
||||||
@@ -93,19 +93,19 @@ Exception::sourceLine() const
|
|||||||
|
|
||||||
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
|
#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED
|
||||||
/// The line on which the error occurred
|
/// The line on which the error occurred
|
||||||
long
|
long
|
||||||
Exception::lineNumber() const
|
Exception::lineNumber() const
|
||||||
{
|
{
|
||||||
return m_sourceLine.isValid() ? m_sourceLine.lineNumber() :
|
return m_sourceLine.isValid() ? m_sourceLine.lineNumber() :
|
||||||
UNKNOWNLINENUMBER;
|
UNKNOWNLINENUMBER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// The file in which the error occurred
|
/// The file in which the error occurred
|
||||||
string
|
string
|
||||||
Exception::fileName() const
|
Exception::fileName() const
|
||||||
{
|
{
|
||||||
return m_sourceLine.isValid() ? m_sourceLine.fileName() :
|
return m_sourceLine.isValid() ? m_sourceLine.fileName() :
|
||||||
UNKNOWNFILENAME;
|
UNKNOWNFILENAME;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -118,7 +118,7 @@ Exception::clone() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Exception::isInstanceOf( const Type &exceptionType ) const
|
Exception::isInstanceOf( const Type &exceptionType ) const
|
||||||
{
|
{
|
||||||
return exceptionType == type();
|
return exceptionType == type();
|
||||||
|
|||||||
@@ -3,12 +3,14 @@
|
|||||||
namespace CppUnit {
|
namespace CppUnit {
|
||||||
|
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
|
||||||
NotEqualException::NotEqualException( string expected,
|
NotEqualException::NotEqualException( string expected,
|
||||||
string actual,
|
string actual,
|
||||||
SourceLine sourceLine ,
|
SourceLine sourceLine ,
|
||||||
string additionalMessage ) :
|
string additionalMessage ) :
|
||||||
Exception( "Expected: " + expected +
|
Exception( "Expected: " + expected +
|
||||||
", but was: " + actual +
|
", but was: " + actual +
|
||||||
"." + additionalMessage ,
|
"." + additionalMessage ,
|
||||||
sourceLine),
|
sourceLine),
|
||||||
m_expected( expected ),
|
m_expected( expected ),
|
||||||
@@ -24,8 +26,8 @@ NotEqualException::NotEqualException( string expected,
|
|||||||
*/
|
*/
|
||||||
NotEqualException::NotEqualException( string expected,
|
NotEqualException::NotEqualException( string expected,
|
||||||
string actual,
|
string actual,
|
||||||
long lineNumber,
|
long lineNumber,
|
||||||
string fileName ) :
|
string fileName ) :
|
||||||
Exception( "Expected: " + expected + ", but was: " + actual,
|
Exception( "Expected: " + expected + ", but was: " + actual,
|
||||||
lineNumber,
|
lineNumber,
|
||||||
fileName ),
|
fileName ),
|
||||||
@@ -36,7 +38,7 @@ NotEqualException::NotEqualException( string expected,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
NotEqualException::NotEqualException( const NotEqualException &other ) :
|
NotEqualException::NotEqualException( const NotEqualException &other ) :
|
||||||
Exception( other ),
|
Exception( other ),
|
||||||
m_expected( other.m_expected ),
|
m_expected( other.m_expected ),
|
||||||
m_actual( other.m_actual ),
|
m_actual( other.m_actual ),
|
||||||
@@ -72,7 +74,7 @@ NotEqualException::clone() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
NotEqualException::isInstanceOf( const Type &exceptionType ) const
|
NotEqualException::isInstanceOf( const Type &exceptionType ) const
|
||||||
{
|
{
|
||||||
return exceptionType == type() ||
|
return exceptionType == type() ||
|
||||||
@@ -87,21 +89,21 @@ NotEqualException::type()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string
|
string
|
||||||
NotEqualException::expectedValue() const
|
NotEqualException::expectedValue() const
|
||||||
{
|
{
|
||||||
return m_expected;
|
return m_expected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string
|
string
|
||||||
NotEqualException::actualValue() const
|
NotEqualException::actualValue() const
|
||||||
{
|
{
|
||||||
return m_actual;
|
return m_actual;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string
|
string
|
||||||
NotEqualException::additionalMessage() const
|
NotEqualException::additionalMessage() const
|
||||||
{
|
{
|
||||||
return m_additionalMessage;
|
return m_additionalMessage;
|
||||||
|
|||||||
@@ -4,27 +4,28 @@
|
|||||||
namespace CppUnit {
|
namespace CppUnit {
|
||||||
|
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
|
||||||
// Counts the number of test cases that will be run by this test.
|
// Counts the number of test cases that will be run by this test.
|
||||||
int
|
int
|
||||||
RepeatedTest::countTestCases() const
|
RepeatedTest::countTestCases() const
|
||||||
{
|
{
|
||||||
return TestDecorator::countTestCases () * m_timesRepeat;
|
return TestDecorator::countTestCases () * m_timesRepeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Returns the name of the test instance.
|
// Returns the name of the test instance.
|
||||||
string
|
string
|
||||||
RepeatedTest::toString() const
|
RepeatedTest::toString() const
|
||||||
{
|
{
|
||||||
return TestDecorator::toString () + " (repeated)";
|
return TestDecorator::toString () + " (repeated)";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Runs a repeated test
|
// Runs a repeated test
|
||||||
void
|
void
|
||||||
RepeatedTest::run( TestResult *result )
|
RepeatedTest::run( TestResult *result )
|
||||||
{
|
{
|
||||||
for ( int n = 0; n < m_timesRepeat; n++ )
|
for ( int n = 0; n < m_timesRepeat; n++ )
|
||||||
{
|
{
|
||||||
if ( result->shouldStop() )
|
if ( result->shouldStop() )
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#include <cppunit/SourceLine.h>
|
#include <cppunit/SourceLine.h>
|
||||||
|
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
|
||||||
namespace CppUnit
|
namespace CppUnit
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -23,28 +25,28 @@ SourceLine::~SourceLine()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SourceLine::isValid() const
|
SourceLine::isValid() const
|
||||||
{
|
{
|
||||||
return !m_fileName.empty();
|
return !m_fileName.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
SourceLine::lineNumber() const
|
SourceLine::lineNumber() const
|
||||||
{
|
{
|
||||||
return m_lineNumber;
|
return m_lineNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string
|
string
|
||||||
SourceLine::fileName() const
|
SourceLine::fileName() const
|
||||||
{
|
{
|
||||||
return m_fileName;
|
return m_fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SourceLine::operator ==( const SourceLine &other ) const
|
SourceLine::operator ==( const SourceLine &other ) const
|
||||||
{
|
{
|
||||||
return m_fileName == other.m_fileName &&
|
return m_fileName == other.m_fileName &&
|
||||||
@@ -52,7 +54,7 @@ SourceLine::operator ==( const SourceLine &other ) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SourceLine::operator !=( const SourceLine &other ) const
|
SourceLine::operator !=( const SourceLine &other ) const
|
||||||
{
|
{
|
||||||
return !( *this == other );
|
return !( *this == other );
|
||||||
|
|||||||
@@ -7,18 +7,21 @@
|
|||||||
#include "cppunit/TestResult.h"
|
#include "cppunit/TestResult.h"
|
||||||
|
|
||||||
|
|
||||||
|
using std::exception;
|
||||||
|
using std::string;
|
||||||
|
|
||||||
namespace CppUnit {
|
namespace CppUnit {
|
||||||
|
|
||||||
/// Create a default TestResult
|
/// Create a default TestResult
|
||||||
CppUnit::TestResult*
|
CppUnit::TestResult*
|
||||||
TestCase::defaultResult()
|
TestCase::defaultResult()
|
||||||
{
|
{
|
||||||
return new TestResult;
|
return new TestResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Run the test and catch any exceptions that are triggered by it
|
/// Run the test and catch any exceptions that are triggered by it
|
||||||
void
|
void
|
||||||
TestCase::run( TestResult *result )
|
TestCase::run( TestResult *result )
|
||||||
{
|
{
|
||||||
result->startTest(this);
|
result->startTest(this);
|
||||||
@@ -51,12 +54,12 @@ TestCase::run( TestResult *result )
|
|||||||
catch (...) {
|
catch (...) {
|
||||||
result->addError( this, new Exception( "setUp() failed" ) );
|
result->addError( this, new Exception( "setUp() failed" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
result->endTest( this );
|
result->endTest( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// A default run method
|
/// A default run method
|
||||||
TestResult *
|
TestResult *
|
||||||
TestCase::run()
|
TestCase::run()
|
||||||
{
|
{
|
||||||
@@ -67,8 +70,8 @@ TestCase::run()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// All the work for runTest is deferred to subclasses
|
/// All the work for runTest is deferred to subclasses
|
||||||
void
|
void
|
||||||
TestCase::runTest()
|
TestCase::runTest()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -100,36 +103,36 @@ TestCase::~TestCase()
|
|||||||
|
|
||||||
|
|
||||||
/// Returns a count of all the tests executed
|
/// Returns a count of all the tests executed
|
||||||
int
|
int
|
||||||
TestCase::countTestCases() const
|
TestCase::countTestCases() const
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Returns the name of the test case
|
/// Returns the name of the test case
|
||||||
string
|
string
|
||||||
TestCase::getName() const
|
TestCase::getName() const
|
||||||
{
|
{
|
||||||
return m_name;
|
return m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Returns the name of the test case instance
|
/// Returns the name of the test case instance
|
||||||
string
|
string
|
||||||
TestCase::toString() const
|
TestCase::toString() const
|
||||||
{
|
{
|
||||||
string className;
|
string className;
|
||||||
|
|
||||||
#if CPPUNIT_USE_TYPEINFO_NAME
|
#if CPPUNIT_USE_TYPEINFO_NAME
|
||||||
const type_info& thisClass = typeid( *this );
|
const std::type_info& thisClass = typeid( *this );
|
||||||
className = thisClass.name();
|
className = thisClass.name();
|
||||||
#else
|
#else
|
||||||
className = "TestCase";
|
className = "TestCase";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return className + "." + getName();
|
return className + "." + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace CppUnit
|
} // namespace CppUnit
|
||||||
|
|||||||
@@ -9,12 +9,16 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
using std::map;
|
||||||
|
using std::set;
|
||||||
|
using std::string;
|
||||||
|
|
||||||
namespace CppUnit {
|
namespace CppUnit {
|
||||||
|
|
||||||
/** (Implementation) This class manages all the TestFactoryRegistry.
|
/** (Implementation) This class manages all the TestFactoryRegistry.
|
||||||
*
|
*
|
||||||
* Responsible for the life-cycle of the TestFactoryRegistry.
|
* Responsible for the life-cycle of the TestFactoryRegistry.
|
||||||
*
|
*
|
||||||
* TestFactory registry must call wasDestroyed() to indicate that
|
* TestFactory registry must call wasDestroyed() to indicate that
|
||||||
* a given TestRegistry was destroyed, and needDestroy() to
|
* a given TestRegistry was destroyed, and needDestroy() to
|
||||||
* know if a given TestFactory need to be destroyed (was not already
|
* know if a given TestFactory need to be destroyed (was not already
|
||||||
@@ -71,13 +75,13 @@ NamedRegistries::getRegistry( string name )
|
|||||||
{
|
{
|
||||||
TestFactoryRegistry *factory = new TestFactoryRegistry( name );
|
TestFactoryRegistry *factory = new TestFactoryRegistry( name );
|
||||||
#if defined(__POWERPC__) && (defined(__BEOS__) || defined(__HAIKU__))
|
#if defined(__POWERPC__) && (defined(__BEOS__) || defined(__HAIKU__))
|
||||||
m_registries.insert(
|
m_registries.insert(
|
||||||
pair<
|
pair<
|
||||||
const basic_string< char, char_traits< char>, allocator<char> >,
|
const basic_string< char, char_traits< char>, allocator<char> >,
|
||||||
CppUnit::TestFactoryRegistry*
|
CppUnit::TestFactoryRegistry*
|
||||||
>(
|
>(
|
||||||
name, factory
|
name, factory
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
#else
|
#else
|
||||||
m_registries.insert( std::make_pair( name, factory ) );
|
m_registries.insert( std::make_pair( name, factory ) );
|
||||||
@@ -89,7 +93,7 @@ NamedRegistries::getRegistry( string name )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
NamedRegistries::wasDestroyed( TestFactory *factory )
|
NamedRegistries::wasDestroyed( TestFactory *factory )
|
||||||
{
|
{
|
||||||
m_factoriesToDestroy.erase( factory );
|
m_factoriesToDestroy.erase( factory );
|
||||||
@@ -97,7 +101,7 @@ NamedRegistries::wasDestroyed( TestFactory *factory )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
NamedRegistries::needDestroy( TestFactory *factory )
|
NamedRegistries::needDestroy( TestFactory *factory )
|
||||||
{
|
{
|
||||||
return m_destroyedFactories.count( factory ) == 0;
|
return m_destroyedFactories.count( factory ) == 0;
|
||||||
@@ -143,7 +147,7 @@ TestFactoryRegistry::getRegistry( const string &name )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TestFactoryRegistry::registerFactory( const string &name,
|
TestFactoryRegistry::registerFactory( const string &name,
|
||||||
TestFactory *factory )
|
TestFactory *factory )
|
||||||
{
|
{
|
||||||
@@ -151,7 +155,7 @@ TestFactoryRegistry::registerFactory( const string &name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TestFactoryRegistry::registerFactory( TestFactory *factory )
|
TestFactoryRegistry::registerFactory( TestFactory *factory )
|
||||||
{
|
{
|
||||||
static int serialNumber = 1;
|
static int serialNumber = 1;
|
||||||
@@ -172,11 +176,11 @@ TestFactoryRegistry::makeTest()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TestFactoryRegistry::addTestToSuite( TestSuite *suite )
|
TestFactoryRegistry::addTestToSuite( TestSuite *suite )
|
||||||
{
|
{
|
||||||
for ( Factories::iterator it = m_factories.begin();
|
for ( Factories::iterator it = m_factories.begin();
|
||||||
it != m_factories.end();
|
it != m_factories.end();
|
||||||
++it )
|
++it )
|
||||||
{
|
{
|
||||||
TestFactory *factory = (*it).second;
|
TestFactory *factory = (*it).second;
|
||||||
|
|||||||
@@ -2,13 +2,15 @@
|
|||||||
#include "cppunit/Test.h"
|
#include "cppunit/Test.h"
|
||||||
#include "cppunit/TestFailure.h"
|
#include "cppunit/TestFailure.h"
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
|
||||||
namespace CppUnit {
|
namespace CppUnit {
|
||||||
|
|
||||||
/// Constructs a TestFailure with the given test and exception.
|
/// Constructs a TestFailure with the given test and exception.
|
||||||
TestFailure::TestFailure( Test *failedTest,
|
TestFailure::TestFailure( Test *failedTest,
|
||||||
Exception *thrownException,
|
Exception *thrownException,
|
||||||
bool isError ) :
|
bool isError ) :
|
||||||
m_failedTest( failedTest ),
|
m_failedTest( failedTest ),
|
||||||
m_thrownException( thrownException ),
|
m_thrownException( thrownException ),
|
||||||
m_isError( isError )
|
m_isError( isError )
|
||||||
{
|
{
|
||||||
@@ -16,28 +18,28 @@ TestFailure::TestFailure( Test *failedTest,
|
|||||||
|
|
||||||
/// Deletes the owned exception.
|
/// Deletes the owned exception.
|
||||||
TestFailure::~TestFailure()
|
TestFailure::~TestFailure()
|
||||||
{
|
{
|
||||||
delete m_thrownException;
|
delete m_thrownException;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the failed test.
|
/// Gets the failed test.
|
||||||
Test *
|
Test *
|
||||||
TestFailure::failedTest() const
|
TestFailure::failedTest() const
|
||||||
{
|
{
|
||||||
return m_failedTest;
|
return m_failedTest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Gets the thrown exception. Never \c NULL.
|
/// Gets the thrown exception. Never \c NULL.
|
||||||
Exception *
|
Exception *
|
||||||
TestFailure::thrownException() const
|
TestFailure::thrownException() const
|
||||||
{
|
{
|
||||||
return m_thrownException;
|
return m_thrownException;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Gets the failure location.
|
/// Gets the failure location.
|
||||||
SourceLine
|
SourceLine
|
||||||
TestFailure::sourceLine() const
|
TestFailure::sourceLine() const
|
||||||
{
|
{
|
||||||
return m_thrownException->sourceLine();
|
return m_thrownException->sourceLine();
|
||||||
@@ -45,7 +47,7 @@ TestFailure::sourceLine() const
|
|||||||
|
|
||||||
|
|
||||||
/// Indicates if the failure is a failed assertion or an error.
|
/// Indicates if the failure is a failed assertion or an error.
|
||||||
bool
|
bool
|
||||||
TestFailure::isError() const
|
TestFailure::isError() const
|
||||||
{
|
{
|
||||||
return m_isError;
|
return m_isError;
|
||||||
@@ -53,7 +55,7 @@ TestFailure::isError() const
|
|||||||
|
|
||||||
|
|
||||||
/// Gets the name of the failed test.
|
/// Gets the name of the failed test.
|
||||||
string
|
string
|
||||||
TestFailure::failedTestName() const
|
TestFailure::failedTestName() const
|
||||||
{
|
{
|
||||||
return m_failedTest->getName();
|
return m_failedTest->getName();
|
||||||
@@ -61,9 +63,9 @@ TestFailure::failedTestName() const
|
|||||||
|
|
||||||
|
|
||||||
/// Returns a short description of the failure.
|
/// Returns a short description of the failure.
|
||||||
string
|
string
|
||||||
TestFailure::toString() const
|
TestFailure::toString() const
|
||||||
{
|
{
|
||||||
return m_failedTest->toString() + ": " + m_thrownException->what();
|
return m_failedTest->toString() + ": " + m_thrownException->what();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,9 @@
|
|||||||
#include <cppunit/ui/text/TestRunner.h>
|
#include <cppunit/ui/text/TestRunner.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
using std::cin;
|
||||||
|
using std::cout;
|
||||||
|
using std::endl;
|
||||||
|
|
||||||
namespace CppUnit {
|
namespace CppUnit {
|
||||||
namespace TextUi {
|
namespace TextUi {
|
||||||
@@ -13,7 +16,7 @@ namespace TextUi {
|
|||||||
/*! Constructs a new text runner.
|
/*! Constructs a new text runner.
|
||||||
* \param outputter used to print text result. Owned by the runner.
|
* \param outputter used to print text result. Owned by the runner.
|
||||||
*/
|
*/
|
||||||
TestRunner::TestRunner( Outputter *outputter )
|
TestRunner::TestRunner( Outputter *outputter )
|
||||||
: m_suite( new TestSuite( "All Tests" ) )
|
: m_suite( new TestSuite( "All Tests" ) )
|
||||||
, m_result( new TestResultCollector() )
|
, m_result( new TestResultCollector() )
|
||||||
, m_eventManager( new TestResult() )
|
, m_eventManager( new TestResult() )
|
||||||
@@ -38,7 +41,7 @@ TestRunner::~TestRunner()
|
|||||||
*
|
*
|
||||||
* \param test Test to add.
|
* \param test Test to add.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
TestRunner::addTest( Test *test )
|
TestRunner::addTest( Test *test )
|
||||||
{
|
{
|
||||||
if ( test != NULL )
|
if ( test != NULL )
|
||||||
@@ -51,7 +54,7 @@ TestRunner::addTest( Test *test )
|
|||||||
* \param testName Name of the test case to run. If an empty is given, then
|
* \param testName Name of the test case to run. If an empty is given, then
|
||||||
* all added test are run. The name must be the name of
|
* all added test are run. The name must be the name of
|
||||||
* of an added test.
|
* of an added test.
|
||||||
* \param doWait if \c true then the user must press the RETURN key
|
* \param doWait if \c true then the user must press the RETURN key
|
||||||
* before the run() method exit.
|
* before the run() method exit.
|
||||||
* \param doPrintResult if \c true (default) then the test result are printed
|
* \param doPrintResult if \c true (default) then the test result are printed
|
||||||
* on the standard output.
|
* on the standard output.
|
||||||
@@ -89,10 +92,10 @@ TestRunner::runTestByName( string testName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TestRunner::wait( bool doWait )
|
TestRunner::wait( bool doWait )
|
||||||
{
|
{
|
||||||
if ( doWait )
|
if ( doWait )
|
||||||
{
|
{
|
||||||
cout << "<RETURN> to continue" << endl;
|
cout << "<RETURN> to continue" << endl;
|
||||||
cin.get ();
|
cin.get ();
|
||||||
@@ -100,7 +103,7 @@ TestRunner::wait( bool doWait )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TestRunner::printResult( bool doPrintResult )
|
TestRunner::printResult( bool doPrintResult )
|
||||||
{
|
{
|
||||||
cout << endl;
|
cout << endl;
|
||||||
@@ -109,11 +112,11 @@ TestRunner::printResult( bool doPrintResult )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Test *
|
Test *
|
||||||
TestRunner::findTestByName( string name ) const
|
TestRunner::findTestByName( string name ) const
|
||||||
{
|
{
|
||||||
for ( vector<Test *>::const_iterator it = m_suite->getTests().begin();
|
for ( vector<Test *>::const_iterator it = m_suite->getTests().begin();
|
||||||
it != m_suite->getTests().end();
|
it != m_suite->getTests().end();
|
||||||
++it )
|
++it )
|
||||||
{
|
{
|
||||||
Test *test = *it;
|
Test *test = *it;
|
||||||
@@ -167,7 +170,7 @@ TestRunner::eventManager() const
|
|||||||
* \c true.
|
* \c true.
|
||||||
* \see CompilerOutputter, XmlOutputter, TextOutputter.
|
* \see CompilerOutputter, XmlOutputter, TextOutputter.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
TestRunner::setOutputter( Outputter *outputter )
|
TestRunner::setOutputter( Outputter *outputter )
|
||||||
{
|
{
|
||||||
delete m_outputter;
|
delete m_outputter;
|
||||||
|
|||||||
@@ -5,6 +5,9 @@
|
|||||||
#include <cppunit/TextOutputter.h>
|
#include <cppunit/TextOutputter.h>
|
||||||
|
|
||||||
|
|
||||||
|
using std::endl;
|
||||||
|
using std::ostream;
|
||||||
|
|
||||||
namespace CppUnit
|
namespace CppUnit
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -22,8 +25,8 @@ TextOutputter::~TextOutputter()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextOutputter::write()
|
TextOutputter::write()
|
||||||
{
|
{
|
||||||
printHeader();
|
printHeader();
|
||||||
m_stream << endl;
|
m_stream << endl;
|
||||||
@@ -32,12 +35,12 @@ TextOutputter::write()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextOutputter::printFailures()
|
TextOutputter::printFailures()
|
||||||
{
|
{
|
||||||
TestResultCollector::TestFailures::const_iterator itFailure = m_result->failures().begin();
|
TestResultCollector::TestFailures::const_iterator itFailure = m_result->failures().begin();
|
||||||
int failureNumber = 1;
|
int failureNumber = 1;
|
||||||
while ( itFailure != m_result->failures().end() )
|
while ( itFailure != m_result->failures().end() )
|
||||||
{
|
{
|
||||||
m_stream << endl;
|
m_stream << endl;
|
||||||
printFailure( *itFailure++, failureNumber++ );
|
printFailure( *itFailure++, failureNumber++ );
|
||||||
@@ -45,7 +48,7 @@ TextOutputter::printFailures()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextOutputter::printFailure( TestFailure *failure,
|
TextOutputter::printFailure( TestFailure *failure,
|
||||||
int failureNumber )
|
int failureNumber )
|
||||||
{
|
{
|
||||||
@@ -62,21 +65,21 @@ TextOutputter::printFailure( TestFailure *failure,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextOutputter::printFailureListMark( int failureNumber )
|
TextOutputter::printFailureListMark( int failureNumber )
|
||||||
{
|
{
|
||||||
m_stream << failureNumber << ")";
|
m_stream << failureNumber << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextOutputter::printFailureTestName( TestFailure *failure )
|
TextOutputter::printFailureTestName( TestFailure *failure )
|
||||||
{
|
{
|
||||||
m_stream << "test: " << failure->failedTestName();
|
m_stream << "test: " << failure->failedTestName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextOutputter::printFailureType( TestFailure *failure )
|
TextOutputter::printFailureType( TestFailure *failure )
|
||||||
{
|
{
|
||||||
m_stream << "("
|
m_stream << "("
|
||||||
@@ -85,7 +88,7 @@ TextOutputter::printFailureType( TestFailure *failure )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextOutputter::printFailureLocation( SourceLine sourceLine )
|
TextOutputter::printFailureLocation( SourceLine sourceLine )
|
||||||
{
|
{
|
||||||
if ( !sourceLine.isValid() )
|
if ( !sourceLine.isValid() )
|
||||||
@@ -96,7 +99,7 @@ TextOutputter::printFailureLocation( SourceLine sourceLine )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextOutputter::printFailureDetail( Exception *thrownException )
|
TextOutputter::printFailureDetail( Exception *thrownException )
|
||||||
{
|
{
|
||||||
if ( thrownException->isInstanceOf( NotEqualException::type() ) )
|
if ( thrownException->isInstanceOf( NotEqualException::type() ) )
|
||||||
@@ -118,11 +121,11 @@ TextOutputter::printFailureDetail( Exception *thrownException )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextOutputter::printHeader()
|
TextOutputter::printHeader()
|
||||||
{
|
{
|
||||||
if ( m_result->wasSuccessful() )
|
if ( m_result->wasSuccessful() )
|
||||||
m_stream << endl << "OK (" << m_result->runTests () << " tests)"
|
m_stream << endl << "OK (" << m_result->runTests () << " tests)"
|
||||||
<< endl;
|
<< endl;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -133,14 +136,14 @@ TextOutputter::printHeader()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextOutputter::printFailureWarning()
|
TextOutputter::printFailureWarning()
|
||||||
{
|
{
|
||||||
m_stream << "!!!FAILURES!!!" << endl;
|
m_stream << "!!!FAILURES!!!" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextOutputter::printStatistics()
|
TextOutputter::printStatistics()
|
||||||
{
|
{
|
||||||
m_stream << "Test Results:" << endl;
|
m_stream << "Test Results:" << endl;
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
|
using std::cerr;
|
||||||
|
using std::endl;
|
||||||
|
|
||||||
namespace CppUnit
|
namespace CppUnit
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -17,7 +20,7 @@ TextTestProgressListener::~TextTestProgressListener()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextTestProgressListener::startTest( Test *test )
|
TextTestProgressListener::startTest( Test *test )
|
||||||
{
|
{
|
||||||
cerr << ".";
|
cerr << ".";
|
||||||
@@ -25,7 +28,7 @@ TextTestProgressListener::startTest( Test *test )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextTestProgressListener::addFailure( const TestFailure &failure )
|
TextTestProgressListener::addFailure( const TestFailure &failure )
|
||||||
{
|
{
|
||||||
cerr << ( failure.isError() ? "E" : "F" );
|
cerr << ( failure.isError() ? "E" : "F" );
|
||||||
@@ -33,7 +36,7 @@ TextTestProgressListener::addFailure( const TestFailure &failure )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextTestProgressListener::done()
|
TextTestProgressListener::done()
|
||||||
{
|
{
|
||||||
cerr << endl;
|
cerr << endl;
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
|
using std::cerr;
|
||||||
|
using std::endl;
|
||||||
|
using std::ostream;
|
||||||
|
|
||||||
namespace CppUnit {
|
namespace CppUnit {
|
||||||
|
|
||||||
|
|
||||||
@@ -15,14 +19,14 @@ TextTestResult::TextTestResult()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextTestResult::addFailure( Test *test, Exception *e )
|
TextTestResult::addFailure( Test *test, Exception *e )
|
||||||
{
|
{
|
||||||
TestResult::addFailure( test, e );
|
TestResult::addFailure( test, e );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextTestResult::addFailure( const TestFailure &failure )
|
TextTestResult::addFailure( const TestFailure &failure )
|
||||||
{
|
{
|
||||||
TestResultCollector::addFailure( failure );
|
TestResultCollector::addFailure( failure );
|
||||||
@@ -30,7 +34,7 @@ TextTestResult::addFailure( const TestFailure &failure )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextTestResult::startTest( Test *test )
|
TextTestResult::startTest( Test *test )
|
||||||
{
|
{
|
||||||
TestResultCollector::startTest (test);
|
TestResultCollector::startTest (test);
|
||||||
@@ -38,12 +42,12 @@ TextTestResult::startTest( Test *test )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextTestResult::printFailures( ostream &stream )
|
TextTestResult::printFailures( ostream &stream )
|
||||||
{
|
{
|
||||||
TestFailures::const_iterator itFailure = failures().begin();
|
TestFailures::const_iterator itFailure = failures().begin();
|
||||||
int failureNumber = 1;
|
int failureNumber = 1;
|
||||||
while ( itFailure != failures().end() )
|
while ( itFailure != failures().end() )
|
||||||
{
|
{
|
||||||
stream << endl;
|
stream << endl;
|
||||||
printFailure( *itFailure++, failureNumber++, stream );
|
printFailure( *itFailure++, failureNumber++, stream );
|
||||||
@@ -51,7 +55,7 @@ TextTestResult::printFailures( ostream &stream )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextTestResult::printFailure( TestFailure *failure,
|
TextTestResult::printFailure( TestFailure *failure,
|
||||||
int failureNumber,
|
int failureNumber,
|
||||||
ostream &stream )
|
ostream &stream )
|
||||||
@@ -69,7 +73,7 @@ TextTestResult::printFailure( TestFailure *failure,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextTestResult::printFailureListMark( int failureNumber,
|
TextTestResult::printFailureListMark( int failureNumber,
|
||||||
ostream &stream )
|
ostream &stream )
|
||||||
{
|
{
|
||||||
@@ -77,7 +81,7 @@ TextTestResult::printFailureListMark( int failureNumber,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextTestResult::printFailureTestName( TestFailure *failure,
|
TextTestResult::printFailureTestName( TestFailure *failure,
|
||||||
ostream &stream )
|
ostream &stream )
|
||||||
{
|
{
|
||||||
@@ -85,7 +89,7 @@ TextTestResult::printFailureTestName( TestFailure *failure,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextTestResult::printFailureType( TestFailure *failure,
|
TextTestResult::printFailureType( TestFailure *failure,
|
||||||
ostream &stream )
|
ostream &stream )
|
||||||
{
|
{
|
||||||
@@ -95,7 +99,7 @@ TextTestResult::printFailureType( TestFailure *failure,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextTestResult::printFailureLocation( SourceLine sourceLine,
|
TextTestResult::printFailureLocation( SourceLine sourceLine,
|
||||||
ostream &stream )
|
ostream &stream )
|
||||||
{
|
{
|
||||||
@@ -107,7 +111,7 @@ TextTestResult::printFailureLocation( SourceLine sourceLine,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextTestResult::printFailureDetail( Exception *thrownException,
|
TextTestResult::printFailureDetail( Exception *thrownException,
|
||||||
ostream &stream )
|
ostream &stream )
|
||||||
{
|
{
|
||||||
@@ -130,8 +134,8 @@ TextTestResult::printFailureDetail( Exception *thrownException,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextTestResult::print( ostream& stream )
|
TextTestResult::print( ostream& stream )
|
||||||
{
|
{
|
||||||
printHeader( stream );
|
printHeader( stream );
|
||||||
stream << endl;
|
stream << endl;
|
||||||
@@ -139,11 +143,11 @@ TextTestResult::print( ostream& stream )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextTestResult::printHeader( ostream &stream )
|
TextTestResult::printHeader( ostream &stream )
|
||||||
{
|
{
|
||||||
if (wasSuccessful ())
|
if (wasSuccessful ())
|
||||||
stream << endl << "OK (" << runTests () << " tests)"
|
stream << endl << "OK (" << runTests () << " tests)"
|
||||||
<< endl;
|
<< endl;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -154,14 +158,14 @@ TextTestResult::printHeader( ostream &stream )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextTestResult::printFailureWarning( ostream &stream )
|
TextTestResult::printFailureWarning( ostream &stream )
|
||||||
{
|
{
|
||||||
stream << "!!!FAILURES!!!" << endl;
|
stream << "!!!FAILURES!!!" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TextTestResult::printStatistics( ostream &stream )
|
TextTestResult::printStatistics( ostream &stream )
|
||||||
{
|
{
|
||||||
stream << "Test Results:" << endl;
|
stream << "Test Results:" << endl;
|
||||||
@@ -174,10 +178,10 @@ TextTestResult::printStatistics( ostream &stream )
|
|||||||
|
|
||||||
|
|
||||||
ostream &
|
ostream &
|
||||||
operator <<( ostream &stream,
|
operator <<( ostream &stream,
|
||||||
TextTestResult &result )
|
TextTestResult &result )
|
||||||
{
|
{
|
||||||
result.print (stream); return stream;
|
result.print (stream); return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,12 @@
|
|||||||
#include <cppunit/extensions/TypeInfoHelper.h>
|
#include <cppunit/extensions/TypeInfoHelper.h>
|
||||||
|
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
using std::type_info;
|
||||||
|
|
||||||
namespace CppUnit {
|
namespace CppUnit {
|
||||||
|
|
||||||
string
|
string
|
||||||
TypeInfoHelper::getClassName( const type_info &info )
|
TypeInfoHelper::getClassName( const type_info &info )
|
||||||
{
|
{
|
||||||
static const string classPrefix( "class " );
|
static const string classPrefix( "class " );
|
||||||
@@ -18,7 +21,7 @@ TypeInfoHelper::getClassName( const type_info &info )
|
|||||||
#if CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST
|
#if CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST
|
||||||
name.compare( classPrefix, 0, classPrefix.length() );
|
name.compare( classPrefix, 0, classPrefix.length() );
|
||||||
#else
|
#else
|
||||||
name.compare( 0, classPrefix.length(), classPrefix );
|
name.compare( 0, classPrefix.length(), classPrefix );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return has_class_prefix ? name.substr( classPrefix.length() ) : name;
|
return has_class_prefix ? name.substr( classPrefix.length() ) : name;
|
||||||
@@ -27,4 +30,4 @@ TypeInfoHelper::getClassName( const type_info &info )
|
|||||||
|
|
||||||
} // namespace CppUnit
|
} // namespace CppUnit
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -7,6 +7,12 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
|
using std::endl;
|
||||||
|
using std::ostream;
|
||||||
|
using std::pair;
|
||||||
|
using std::string;
|
||||||
|
|
||||||
|
|
||||||
namespace CppUnit
|
namespace CppUnit
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -21,7 +27,7 @@ XmlOutputter::Node::Node( string elementName,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
XmlOutputter::Node::Node( string elementName,
|
XmlOutputter::Node::Node( string elementName,
|
||||||
int numericContent ) :
|
int numericContent ) :
|
||||||
m_name( elementName )
|
m_name( elementName )
|
||||||
@@ -38,7 +44,7 @@ XmlOutputter::Node::~Node()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XmlOutputter::Node::addAttribute( string attributeName,
|
XmlOutputter::Node::addAttribute( string attributeName,
|
||||||
string value )
|
string value )
|
||||||
{
|
{
|
||||||
@@ -46,7 +52,7 @@ XmlOutputter::Node::addAttribute( string attributeName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XmlOutputter::Node::addAttribute( string attributeName,
|
XmlOutputter::Node::addAttribute( string attributeName,
|
||||||
int numericValue )
|
int numericValue )
|
||||||
{
|
{
|
||||||
@@ -54,14 +60,14 @@ XmlOutputter::Node::addAttribute( string attributeName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XmlOutputter::Node::addNode( Node *node )
|
XmlOutputter::Node::addNode( Node *node )
|
||||||
{
|
{
|
||||||
m_nodes.push_back( node );
|
m_nodes.push_back( node );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string
|
string
|
||||||
XmlOutputter::Node::toString() const
|
XmlOutputter::Node::toString() const
|
||||||
{
|
{
|
||||||
string element = "<";
|
string element = "<";
|
||||||
@@ -87,7 +93,7 @@ XmlOutputter::Node::toString() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string
|
string
|
||||||
XmlOutputter::Node::attributesAsString() const
|
XmlOutputter::Node::attributesAsString() const
|
||||||
{
|
{
|
||||||
string attributes;
|
string attributes;
|
||||||
@@ -104,7 +110,7 @@ XmlOutputter::Node::attributesAsString() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string
|
string
|
||||||
XmlOutputter::Node::escape( string value ) const
|
XmlOutputter::Node::escape( string value ) const
|
||||||
{
|
{
|
||||||
string escaped;
|
string escaped;
|
||||||
@@ -113,31 +119,31 @@ XmlOutputter::Node::escape( string value ) const
|
|||||||
char c = value[index ];
|
char c = value[index ];
|
||||||
switch ( c ) // escape all predefined XML entity (safe?)
|
switch ( c ) // escape all predefined XML entity (safe?)
|
||||||
{
|
{
|
||||||
case '<':
|
case '<':
|
||||||
escaped += "<";
|
escaped += "<";
|
||||||
break;
|
break;
|
||||||
case '>':
|
case '>':
|
||||||
escaped += ">";
|
escaped += ">";
|
||||||
break;
|
break;
|
||||||
case '&':
|
case '&':
|
||||||
escaped += "&";
|
escaped += "&";
|
||||||
break;
|
break;
|
||||||
case '\'':
|
case '\'':
|
||||||
escaped += "'";
|
escaped += "'";
|
||||||
break;
|
break;
|
||||||
case '"':
|
case '"':
|
||||||
escaped += """;
|
escaped += """;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
escaped += c;
|
escaped += c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return escaped;
|
return escaped;
|
||||||
}
|
}
|
||||||
|
|
||||||
// should be somewhere else... Future CppUnit::String ?
|
// should be somewhere else... Future CppUnit::String ?
|
||||||
string
|
string
|
||||||
XmlOutputter::Node::asString( int value )
|
XmlOutputter::Node::asString( int value )
|
||||||
{
|
{
|
||||||
OStringStream stream;
|
OStringStream stream;
|
||||||
@@ -166,7 +172,7 @@ XmlOutputter::~XmlOutputter()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XmlOutputter::write()
|
XmlOutputter::write()
|
||||||
{
|
{
|
||||||
writeProlog();
|
writeProlog();
|
||||||
@@ -174,7 +180,7 @@ XmlOutputter::write()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XmlOutputter::writeProlog()
|
XmlOutputter::writeProlog()
|
||||||
{
|
{
|
||||||
m_stream << "<?xml version=\"1.0\" "
|
m_stream << "<?xml version=\"1.0\" "
|
||||||
@@ -183,7 +189,7 @@ XmlOutputter::writeProlog()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XmlOutputter::writeTestsResult()
|
XmlOutputter::writeTestsResult()
|
||||||
{
|
{
|
||||||
Node *rootNode = makeRootNode();
|
Node *rootNode = makeRootNode();
|
||||||
@@ -208,7 +214,7 @@ XmlOutputter::makeRootNode()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XmlOutputter::fillFailedTestsMap( FailedTests &failedTests )
|
XmlOutputter::fillFailedTestsMap( FailedTests &failedTests )
|
||||||
{
|
{
|
||||||
const TestResultCollector::TestFailures &failures = m_result->failures();
|
const TestResultCollector::TestFailures &failures = m_result->failures();
|
||||||
@@ -216,11 +222,11 @@ XmlOutputter::fillFailedTestsMap( FailedTests &failedTests )
|
|||||||
while ( itFailure != failures.end() )
|
while ( itFailure != failures.end() )
|
||||||
{
|
{
|
||||||
TestFailure *failure = *itFailure++;
|
TestFailure *failure = *itFailure++;
|
||||||
failedTests.insert(
|
failedTests.insert(
|
||||||
pair< CppUnit::Test* const, CppUnit::TestFailure*
|
pair< CppUnit::Test* const, CppUnit::TestFailure*
|
||||||
>(
|
>(
|
||||||
failure->failedTest(), failure
|
failure->failedTest(), failure
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -266,7 +272,7 @@ XmlOutputter::addStatistics( Node *rootNode )
|
|||||||
Node *statisticsNode = new Node( "Statistics" );
|
Node *statisticsNode = new Node( "Statistics" );
|
||||||
rootNode->addNode( statisticsNode );
|
rootNode->addNode( statisticsNode );
|
||||||
statisticsNode->addNode( new Node( "Tests", m_result->runTests() ) );
|
statisticsNode->addNode( new Node( "Tests", m_result->runTests() ) );
|
||||||
statisticsNode->addNode( new Node( "FailuresTotal",
|
statisticsNode->addNode( new Node( "FailuresTotal",
|
||||||
m_result->testFailuresTotal() ) );
|
m_result->testFailuresTotal() ) );
|
||||||
statisticsNode->addNode( new Node( "Errors", m_result->testErrors() ) );
|
statisticsNode->addNode( new Node( "Errors", m_result->testErrors() ) );
|
||||||
statisticsNode->addNode( new Node( "Failures", m_result->testFailures() ) );
|
statisticsNode->addNode( new Node( "Failures", m_result->testFailures() ) );
|
||||||
@@ -280,12 +286,12 @@ XmlOutputter::addFailedTest( Test *test,
|
|||||||
Node *testsNode )
|
Node *testsNode )
|
||||||
{
|
{
|
||||||
Exception *thrownException = failure->thrownException();
|
Exception *thrownException = failure->thrownException();
|
||||||
|
|
||||||
Node *testNode = new Node( "FailedTest", thrownException->what() );
|
Node *testNode = new Node( "FailedTest", thrownException->what() );
|
||||||
testsNode->addNode( testNode );
|
testsNode->addNode( testNode );
|
||||||
testNode->addAttribute( "id", testNumber );
|
testNode->addAttribute( "id", testNumber );
|
||||||
testNode->addNode( new Node( "Name", test->getName() ) );
|
testNode->addNode( new Node( "Name", test->getName() ) );
|
||||||
testNode->addNode( new Node( "FailureType",
|
testNode->addNode( new Node( "FailureType",
|
||||||
failure->isError() ? "Error" : "Assertion" ) );
|
failure->isError() ? "Error" : "Assertion" ) );
|
||||||
|
|
||||||
if ( failure->sourceLine().isValid() )
|
if ( failure->sourceLine().isValid() )
|
||||||
@@ -306,7 +312,7 @@ XmlOutputter::addFailureLocation( TestFailure *failure,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XmlOutputter::addSucessfulTest( Test *test,
|
XmlOutputter::addSucessfulTest( Test *test,
|
||||||
int testNumber,
|
int testNumber,
|
||||||
Node *testsNode )
|
Node *testsNode )
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user