diff options
| author | Bastiaan Bakker <bastiaan.bakker@lifeline.nl> | 2001-04-28 17:23:32 +0000 |
|---|---|---|
| committer | Bastiaan Bakker <bastiaan.bakker@lifeline.nl> | 2001-04-28 17:23:32 +0000 |
| commit | 6d95c46d9dc342bea176c8fbcd101db8eba24bef (patch) | |
| tree | 3a42ea08625f64972f520cbeda2da3c68bbe9692 /src/cppunit | |
| parent | 7e4ccacdbcf2f78005447f16e49d339d2a70e9ca (diff) | |
| download | cppunit-6d95c46d9dc342bea176c8fbcd101db8eba24bef.tar.gz | |
Moved files in subdir cppunit to src/cppunit.
Diffstat (limited to 'src/cppunit')
| -rw-r--r-- | src/cppunit/Exception.cpp | 62 | ||||
| -rw-r--r-- | src/cppunit/Makefile.am | 27 | ||||
| -rw-r--r-- | src/cppunit/TestCase.cpp | 173 | ||||
| -rw-r--r-- | src/cppunit/TestFailure.cpp | 26 | ||||
| -rw-r--r-- | src/cppunit/TestRegistry.cpp | 69 | ||||
| -rw-r--r-- | src/cppunit/TestResult.cpp | 110 | ||||
| -rw-r--r-- | src/cppunit/TestSuite.cpp | 86 | ||||
| -rw-r--r-- | src/cppunit/TextTestResult.cpp | 127 | ||||
| -rw-r--r-- | src/cppunit/cppunit.dsp | 148 | ||||
| -rw-r--r-- | src/cppunit/cppunit.dsw | 29 | ||||
| -rw-r--r-- | src/cppunit/estring.h | 31 |
11 files changed, 888 insertions, 0 deletions
diff --git a/src/cppunit/Exception.cpp b/src/cppunit/Exception.cpp new file mode 100644 index 0000000..51835ad --- /dev/null +++ b/src/cppunit/Exception.cpp @@ -0,0 +1,62 @@ +#include "cppunit/Exception.h" + +namespace CppUnit { + +const std::string +CppUnit::Exception::UNKNOWNFILENAME = + "<unknown>"; +const int CppUnit::Exception::UNKNOWNLINENUMBER = -1; + +/// Construct the exception +CppUnit::Exception::Exception (const Exception& other) + : exception (other) +{ + m_message = other.m_message; + m_lineNumber = other.m_lineNumber; + m_fileName = other.m_fileName; +} + +CppUnit::Exception::Exception (std::string message, long lineNumber, std::string fileName) + : m_message (message), m_lineNumber (lineNumber), m_fileName (fileName) +{ +} + + +/// Destruct the exception +CppUnit::Exception::~Exception () +{} + + +/// Perform an assignment +Exception& +CppUnit::Exception::operator= (const Exception& other) +{ + exception::operator= (other); + + if (&other != this) { + m_message = other.m_message; + m_lineNumber = other.m_lineNumber; + m_fileName = other.m_fileName; + } + + return *this; +} + + +/// Return descriptive message +const char* +CppUnit::Exception::what() const throw () +{ return m_message.c_str (); } + +/// The line on which the error occurred +long +CppUnit::Exception::lineNumber () +{ return m_lineNumber; } + + +/// The file in which the error occurred +std::string +CppUnit::Exception::fileName () +{ return m_fileName; } + +} // namespace CppUnit diff --git a/src/cppunit/Makefile.am b/src/cppunit/Makefile.am new file mode 100644 index 0000000..e883bbf --- /dev/null +++ b/src/cppunit/Makefile.am @@ -0,0 +1,27 @@ +# +# $Id: Makefile.am,v 1.1 2001-04-28 18:23:32 bastiaan Exp $ +# + +EXTRA_DIST = cppunit.dsw cppunit.dsp + +cppunitdir=$(includedir)/cppunit + +lib_LTLIBRARIES = libcppunit.la + +libcppunit_la_SOURCES = \ + TestCase.cpp \ + TestSuite.cpp \ + TestResult.cpp \ + TestFailure.cpp \ + TestRegistry.cpp \ + Exception.cpp \ + TextTestResult.cpp \ + estring.h + +libcppunit_la_LDFLAGS= \ + -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ + -release $(LT_RELEASE) + + + + diff --git a/src/cppunit/TestCase.cpp b/src/cppunit/TestCase.cpp new file mode 100644 index 0000000..f1e5198 --- /dev/null +++ b/src/cppunit/TestCase.cpp @@ -0,0 +1,173 @@ +#include <typeinfo> +#include <stdexcept> +#include <cmath> + +#include "cppunit/TestCase.h" +#include "cppunit/Exception.h" +#include "cppunit/TestResult.h" +#include "estring.h" + +namespace CppUnit { + +/// Create a default TestResult +CppUnit::TestResult* TestCase::defaultResult () +{ return new TestResult; } + + +/// Check for a failed general assertion +void TestCase::assertImplementation (bool condition, + std::string conditionExpression, + long lineNumber, + std::string fileName) +{ + if (!condition) + throw Exception (conditionExpression, lineNumber, fileName); +} + + +/// Check for a failed equality assertion +void TestCase::assertEquals (long expected, + long actual, + long lineNumber, + std::string fileName) +{ + if (expected != actual) + assertImplementation (false, notEqualsMessage(expected, actual), lineNumber, fileName); +} + + +/// Check for a failed equality assertion +void TestCase::assertEquals (double expected, + double actual, + double delta, + long lineNumber, + std::string fileName) +{ + if (fabs (expected - actual) > delta) + assertImplementation (false, notEqualsMessage(expected, actual), lineNumber, fileName); + +} + + +/// Run the test and catch any exceptions that are triggered by it +void +TestCase::run (TestResult *result) +{ + result->startTest (this); + + setUp (); + + try { + + runTest (); + + } + catch (Exception& e) { + Exception *copy = new Exception (e); + result->addFailure (this, copy); + + } + catch (exception& e) { + result->addError (this, new Exception (e.what ())); + + } + catch (...) { + Exception *e = new Exception ("unknown exception"); + result->addError (this, e); + + } + + tearDown (); + + result->endTest (this); + +} + + +/// A default run method +TestResult *TestCase::run () +{ + TestResult *result = defaultResult (); + + run (result); + return result; + +} + + +/// All the work for runTest is deferred to subclasses +void TestCase::runTest () +{ +} + + +/// Build a message about a failed equality check +std::string TestCase::notEqualsMessage (long expected, long actual) +{ + return "expected: " + estring (expected) + " but was: " + estring (actual); +} + + +/// Build a message about a failed equality check +std::string TestCase::notEqualsMessage (double expected, double actual) +{ + return "expected: " + estring (expected) + " but was: " + estring (actual); +} + + + +/** Constructs a test case. + * \param name the name of the TestCase. + */ +TestCase::TestCase (std::string name) + : m_name (name) +{ +} + +/** Constructs a test case for a suite. + * This TestCase is intended for use by the TestCaller and should not + * be used by a test case for which run() is called. + **/ +TestCase::TestCase () + : m_name ("") +{ +} + + +/// Destructs a test case +TestCase::~TestCase () +{} + + +/// Returns a count of all the tests executed +int TestCase::countTestCases () const +{ return 1; } + + +/// Returns the name of the test case +std::string + TestCase::getName () const +{ + return m_name; +} + + +/// A hook for fixture set up +void TestCase::setUp () +{} + + +/// A hook for fixture tear down +void TestCase::tearDown () +{} + + +/// Returns the name of the test case instance +std::string + TestCase::toString () const +{ + const type_info& thisClass = typeid (*this); + return std::string (thisClass.name ()) + "." + getName (); +} + +} // namespace CppUnit diff --git a/src/cppunit/TestFailure.cpp b/src/cppunit/TestFailure.cpp new file mode 100644 index 0000000..6a48696 --- /dev/null +++ b/src/cppunit/TestFailure.cpp @@ -0,0 +1,26 @@ +#include "cppunit/TestFailure.h" +#include "cppunit/Exception.h" +#include "cppunit/Test.h" + +namespace CppUnit { + +/// Returns a short description of the failure. +std::string +TestFailure::toString () const +{ + return m_failedTest->toString () + ": " + m_thrownException->what (); +} + +/// Constructs a TestFailure with the given test and exception. +TestFailure::TestFailure (Test *failedTest, Exception *thrownException) + : m_failedTest (failedTest), m_thrownException (thrownException) +{ +} + +/// Deletes the owned exception. +TestFailure::~TestFailure () +{ + delete m_thrownException; +} + +} // namespace CppUnit diff --git a/src/cppunit/TestRegistry.cpp b/src/cppunit/TestRegistry.cpp new file mode 100644 index 0000000..f4eaf74 --- /dev/null +++ b/src/cppunit/TestRegistry.cpp @@ -0,0 +1,69 @@ +#include "cppunit/TestRegistry.h" +#include "cppunit/Test.h" + +namespace CppUnit { + +TestRegistry* +TestRegistry::s_registry = NULL; + +TestRegistry& +TestRegistry::getRegistry () +{ + if (NULL == s_registry) { + s_registry = new TestRegistry(); + } + return *s_registry; +} + +void +TestRegistry::addTest(std::string name, Test *test) +{ + getRegistry().m_registry_names.push_back (name); + getRegistry().m_registry_tests.push_back (test); +} + +const std::vector<std::string>& +TestRegistry::getAllTestNames () const +{ + return getRegistry().m_registry_names; +} + +const std::vector<Test*>& +TestRegistry::getAllTests() const +{ + return getRegistry().m_registry_tests; +} + +std::vector<Test*> +TestRegistry::getTest (const std::string& testCase) const +{ + std::vector<Test*> res; + std::vector<Test*>::iterator test_it; + std::vector<std::string>::iterator name_it; + for (test_it = getRegistry().m_registry_tests.begin (), + name_it = getRegistry().m_registry_names.begin (); + test_it != getRegistry().m_registry_tests.end (); + ++test_it, ++name_it) { + if ((*name_it) == testCase) { + res.push_back((*test_it)); + break; + } + } + return(res); +} + +TestRegistry::~TestRegistry () +{ + for (std::vector<Test*>::iterator it = m_registry_tests.begin (); + it != m_registry_tests.end (); + ++it) { + delete *it; + } +} + +TestRegistry::TestRegistry () +{ +} + +} // namespace CppUnit + diff --git a/src/cppunit/TestResult.cpp b/src/cppunit/TestResult.cpp new file mode 100644 index 0000000..a63652b --- /dev/null +++ b/src/cppunit/TestResult.cpp @@ -0,0 +1,110 @@ +#include "cppunit/TestResult.h" + +namespace CppUnit { + +/// Destroys a test result +TestResult::~TestResult () +{ + std::vector<TestFailure *>::iterator it; + + for (it = m_errors.begin (); it != m_errors.end (); ++it) + delete *it; + + for (it = m_failures.begin (); it != m_failures.end (); ++it) + delete *it; + + delete m_syncObject; +} + +/// Construct a TestResult + + TestResult::TestResult () + : m_syncObject (new SynchronizationObject ()) +{ m_runTests = 0; m_stop = false; } + + +/** Adds an error to the list of errors. + * The passed in exception + * caused the error + */ +void + TestResult::addError (Test *test, Exception *e) +{ ExclusiveZone zone (m_syncObject); m_errors.push_back (new TestFailure (test, e)); } + + +/** Adds a failure to the list of failures. The passed in exception + * caused the failure. + */ +void + TestResult::addFailure (Test *test, Exception *e) +{ ExclusiveZone zone (m_syncObject); m_failures.push_back (new TestFailure (test, e)); } + + +/// Informs the result that a test will be started. +void + TestResult::startTest (Test *test) +{ ExclusiveZone zone (m_syncObject); m_runTests++; } + + +/// Informs the result that a test was completed. +void + TestResult::endTest (Test *test) +{ ExclusiveZone zone (m_syncObject); } + + +/// Gets the number of run tests. +int + TestResult::runTests () +{ ExclusiveZone zone (m_syncObject); return m_runTests; } + + +/// Gets the number of detected errors. +int + TestResult::testErrors () +{ ExclusiveZone zone (m_syncObject); return m_errors.size (); } + + +/// Gets the number of detected failures. +int + TestResult::testFailures () +{ ExclusiveZone zone (m_syncObject); return m_failures.size (); } + + +/// Returns whether the entire test was successful or not. +bool + TestResult::wasSuccessful () +{ ExclusiveZone zone (m_syncObject); return m_failures.size () == 0 && m_errors.size () == 0; } + + +/// Returns a vector of the errors. +std::vector<TestFailure *>& + TestResult::errors () +{ ExclusiveZone zone (m_syncObject); return m_errors; } + + +/// Returns a vector of the failures. +std::vector<TestFailure *>& + TestResult::failures () +{ ExclusiveZone zone (m_syncObject); return m_failures; } + + +/// Returns whether testing should be stopped +bool + TestResult::shouldStop () +{ ExclusiveZone zone (m_syncObject); return m_stop; } + + +/// Stop testing +void + TestResult::stop () +{ ExclusiveZone zone (m_syncObject); m_stop = true; } + + +/** Accept a new synchronization object for protection of this instance + * TestResult assumes ownership of the object + */ +void + TestResult::setSynchronizationObject (SynchronizationObject *syncObject) +{ delete m_syncObject; m_syncObject = syncObject; } + +} // namespace CppUnit diff --git a/src/cppunit/TestSuite.cpp b/src/cppunit/TestSuite.cpp new file mode 100644 index 0000000..8fe5e65 --- /dev/null +++ b/src/cppunit/TestSuite.cpp @@ -0,0 +1,86 @@ +#include "cppunit/TestSuite.h" +#include "cppunit/TestResult.h" + +namespace CppUnit { + +/// Deletes all tests in the suite. +void TestSuite::deleteContents () +{ + for (std::vector<Test *>::iterator it = m_tests.begin (); + it != m_tests.end (); + ++it) + delete *it; + m_tests.clear(); +} + + +/// Runs the tests and collects their result in a TestResult. +void TestSuite::run (TestResult *result) +{ + for (std::vector<Test *>::iterator it = m_tests.begin (); + it != m_tests.end (); + ++it) { + if (result->shouldStop ()) + break; + + Test *test = *it; + test->run (result); + } + +} + + +/// Counts the number of test cases that will be run by this test. +int TestSuite::countTestCases () const +{ + int count = 0; + + for (std::vector<Test *>::const_iterator it = m_tests.begin (); + it != m_tests.end (); + ++it) + count += (*it)->countTestCases (); + + return count; + +} + + + +/// Default constructor +TestSuite::TestSuite (std::string name) + : m_name (name) +{ +} + + +/// Destructor +TestSuite::~TestSuite () +{ + deleteContents (); +} + + +/// Adds a test to the suite. +void + TestSuite::addTest (Test *test) +{ + m_tests.push_back (test); +} + + +/// Returns a string representation of the test suite. +std::string + TestSuite::toString () const +{ + return "suite " + getName(); +} + +/// Returns the name of the test suite. +std::string + TestSuite::getName () const +{ + return m_name; +} + +} // namespace CppUnit + diff --git a/src/cppunit/TextTestResult.cpp b/src/cppunit/TextTestResult.cpp new file mode 100644 index 0000000..9d5f017 --- /dev/null +++ b/src/cppunit/TextTestResult.cpp @@ -0,0 +1,127 @@ +#include <iostream> +#include "cppunit/TextTestResult.h" +#include "cppunit/Exception.h" +#include "cppunit/Test.h" +#include "estring.h" + +namespace CppUnit { + +std::ostream& +CppUnit::operator<< (std::ostream& stream, TextTestResult& result) +{ + result.print (stream); return stream; +} + +void +TextTestResult::addError (Test *test, Exception *e) +{ + TestResult::addError (test, e); + std::cerr << "E" << std::endl; + +} + +void +TextTestResult::addFailure (Test *test, Exception *e) +{ + TestResult::addFailure (test, e); + std::cerr << "F" << std::endl; + +} + +void +TextTestResult::startTest (Test *test) +{ + + std::cerr << "Running " << test->getName() << " "; + TestResult::startTest (test); + std::cerr << "." << std::endl; + +} + + +void +TextTestResult::printErrors (std::ostream& stream) +{ + if (testErrors () != 0) { + + if (testErrors () == 1) + stream << "There was " << testErrors () << " error: " << std::endl; + else + stream << "There were " << testErrors () << " errors: " << std::endl; + + int i = 1; + + for (std::vector<TestFailure *>::iterator it = errors ().begin (); it != errors ().end (); ++it) { + TestFailure *failure = *it; + Exception *e = failure->thrownException (); + + stream << i + << ") " + << "line: " << (e ? estring (e->lineNumber ()) : "") << " " + << (e ? e->fileName () : "") << " " + << "\"" << failure->thrownException ()->what () << "\"" + << std::endl; + i++; + } + } + +} + +void +TextTestResult::printFailures (std::ostream& stream) +{ + if (testFailures () != 0) { + if (testFailures () == 1) + stream << "There was " << testFailures () << " failure: " << std::endl; + else + stream << "There were " << testFailures () << " failures: " << std::endl; + + int i = 1; + + for (std::vector<TestFailure *>::iterator it = failures ().begin (); it != failures ().end (); ++it) { + TestFailure *failure = *it; + Exception *e = failure->thrownException (); + + stream << i + << ") " + << "line: " << (e ? estring (e->lineNumber ()) : "") << " " + << (e ? e->fileName () : "") << " " + << "\"" << failure->thrownException ()->what () << "\"" + << std::endl; + i++; + } + } + +} + + +void +TextTestResult::print (std::ostream& stream) +{ + printHeader (stream); + printErrors (stream); + printFailures (stream); + +} + + +void +TextTestResult::printHeader (std::ostream& stream) +{ + if (wasSuccessful ()) + stream << std::endl << "OK (" << runTests () << " tests)" << std::endl; + else + stream << std::endl + << "!!!FAILURES!!!" << std::endl + << "Test Results:" << std::endl + << "Run: " + << runTests () + << " Failures: " + << testFailures () + << " Errors: " + << testErrors () + << std::endl; + +} + +} // namespace CppUnit diff --git a/src/cppunit/cppunit.dsp b/src/cppunit/cppunit.dsp new file mode 100644 index 0000000..18045fd --- /dev/null +++ b/src/cppunit/cppunit.dsp @@ -0,0 +1,148 @@ +# Microsoft Developer Studio Project File - Name="cppunit" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=cppunit - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "cppunit.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "cppunit.mak" CFG="cppunit - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "cppunit - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "cppunit - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "cppunit - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GR /GX /O2 /I "..\include" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD BASE RSC /l 0x40c /d "NDEBUG" +# ADD RSC /l 0x40c /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"..\lib\cppunit.lib" + +!ELSEIF "$(CFG)" == "cppunit - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /GR /GX /ZI /Od /I "..\include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD BASE RSC /l 0x40c /d "_DEBUG" +# ADD RSC /l 0x40c /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"..\lib\cppunitd.lib" + +!ENDIF + +# Begin Target + +# Name "cppunit - Win32 Release" +# Name "cppunit - Win32 Debug" +# Begin Source File + +SOURCE=.\Exception.cpp +# End Source File +# Begin Source File + +SOURCE=..\include\cppunit\Exception.h +# End Source File +# Begin Source File + +SOURCE=..\include\cppunit\Test.h +# End Source File +# Begin Source File + +SOURCE=..\include\cppunit\TestCaller.h +# End Source File +# Begin Source File + +SOURCE=.\TestCase.cpp +# End Source File +# Begin Source File + +SOURCE=..\include\cppunit\TestCase.h +# End Source File +# Begin Source File + +SOURCE=.\TestFailure.cpp +# End Source File +# Begin Source File + +SOURCE=..\include\cppunit\TestFailure.h +# End Source File +# Begin Source File + +SOURCE=.\TestRegistry.cpp +# End Source File +# Begin Source File + +SOURCE=..\include\cppunit\TestRegistry.h +# End Source File +# Begin Source File + +SOURCE=.\TestResult.cpp +# End Source File +# Begin Source File + +SOURCE=..\include\cppunit\TestResult.h +# End Source File +# Begin Source File + +SOURCE=.\TestSuite.cpp +# End Source File +# Begin Source File + +SOURCE=..\include\cppunit\TestSuite.h +# End Source File +# Begin Source File + +SOURCE=.\TextTestResult.cpp +# End Source File +# Begin Source File + +SOURCE=..\include\cppunit\TextTestResult.h +# End Source File +# End Target +# End Project diff --git a/src/cppunit/cppunit.dsw b/src/cppunit/cppunit.dsw new file mode 100644 index 0000000..0c89c6c --- /dev/null +++ b/src/cppunit/cppunit.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "cppunit"=".\cppunit.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/src/cppunit/estring.h b/src/cppunit/estring.h new file mode 100644 index 0000000..2be5669 --- /dev/null +++ b/src/cppunit/estring.h @@ -0,0 +1,31 @@ +#ifndef CPPUNIT_ESTRING_H +#define CPPUNIT_ESTRING_H + + +#include <cstdio> + +namespace CppUnit { + + /// Create a string from a const char pointer + inline std::string estring (const char *cstring) + { return std::string (cstring); } + + /// Create a string from a string (for uniformities' sake) + inline std::string estring (std::string& expandedString) + { return expandedString; } + + /// Create a string from an int + inline std::string estring (int number) + { char buffer [50]; sprintf (buffer, "%d", number); return std::string (buffer); } + + /// Create a string from a long + inline std::string estring (long number) + { char buffer [50]; sprintf (buffer, "%ld", number); return std::string (buffer); } + + /// Create a string from a double + inline std::string estring (double number) + { char buffer [50]; sprintf (buffer, "%f", number); return std::string (buffer); } + +} // namespace CppUnit + +#endif // CPPUNIT_ESTRING_H |
