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 /cppunit | |
| parent | 7e4ccacdbcf2f78005447f16e49d339d2a70e9ca (diff) | |
| download | cppunit-6d95c46d9dc342bea176c8fbcd101db8eba24bef.tar.gz | |
Moved files in subdir cppunit to src/cppunit.
Diffstat (limited to 'cppunit')
| -rw-r--r-- | cppunit/Exception.cpp | 62 | ||||
| -rw-r--r-- | cppunit/Makefile.am | 27 | ||||
| -rw-r--r-- | cppunit/TestCase.cpp | 173 | ||||
| -rw-r--r-- | cppunit/TestFailure.cpp | 26 | ||||
| -rw-r--r-- | cppunit/TestRegistry.cpp | 69 | ||||
| -rw-r--r-- | cppunit/TestResult.cpp | 110 | ||||
| -rw-r--r-- | cppunit/TestSuite.cpp | 86 | ||||
| -rw-r--r-- | cppunit/TextTestResult.cpp | 127 | ||||
| -rw-r--r-- | cppunit/cppunit.dsp | 148 | ||||
| -rw-r--r-- | cppunit/cppunit.dsw | 29 | ||||
| -rw-r--r-- | cppunit/estring.h | 31 |
11 files changed, 0 insertions, 888 deletions
diff --git a/cppunit/Exception.cpp b/cppunit/Exception.cpp deleted file mode 100644 index 51835ad..0000000 --- a/cppunit/Exception.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#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/cppunit/Makefile.am b/cppunit/Makefile.am deleted file mode 100644 index 09cc6e7..0000000 --- a/cppunit/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -# -# $Id: Makefile.am,v 1.5 2001-04-19 20:47:22 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/cppunit/TestCase.cpp b/cppunit/TestCase.cpp deleted file mode 100644 index f1e5198..0000000 --- a/cppunit/TestCase.cpp +++ /dev/null @@ -1,173 +0,0 @@ -#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/cppunit/TestFailure.cpp b/cppunit/TestFailure.cpp deleted file mode 100644 index 6a48696..0000000 --- a/cppunit/TestFailure.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#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/cppunit/TestRegistry.cpp b/cppunit/TestRegistry.cpp deleted file mode 100644 index f4eaf74..0000000 --- a/cppunit/TestRegistry.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#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/cppunit/TestResult.cpp b/cppunit/TestResult.cpp deleted file mode 100644 index a63652b..0000000 --- a/cppunit/TestResult.cpp +++ /dev/null @@ -1,110 +0,0 @@ -#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/cppunit/TestSuite.cpp b/cppunit/TestSuite.cpp deleted file mode 100644 index 8fe5e65..0000000 --- a/cppunit/TestSuite.cpp +++ /dev/null @@ -1,86 +0,0 @@ -#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/cppunit/TextTestResult.cpp b/cppunit/TextTestResult.cpp deleted file mode 100644 index 9d5f017..0000000 --- a/cppunit/TextTestResult.cpp +++ /dev/null @@ -1,127 +0,0 @@ -#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/cppunit/cppunit.dsp b/cppunit/cppunit.dsp deleted file mode 100644 index 18045fd..0000000 --- a/cppunit/cppunit.dsp +++ /dev/null @@ -1,148 +0,0 @@ -# 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/cppunit/cppunit.dsw b/cppunit/cppunit.dsw deleted file mode 100644 index 0c89c6c..0000000 --- a/cppunit/cppunit.dsw +++ /dev/null @@ -1,29 +0,0 @@ -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/cppunit/estring.h b/cppunit/estring.h deleted file mode 100644 index 2be5669..0000000 --- a/cppunit/estring.h +++ /dev/null @@ -1,31 +0,0 @@ -#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 |
