[Opal-commits] opal/src/external/quicktest quicktest.h,1.2,1.3
Status: Inactive
Brought to you by:
tylerstreeter
|
From: Olex <ole...@us...> - 2005-11-21 13:59:39
|
Update of /cvsroot/opal/opal/src/external/quicktest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28046/src/external/quicktest Modified Files: quicktest.h Log Message: Added more unit tests. Index: quicktest.h =================================================================== RCS file: /cvsroot/opal/opal/src/external/quicktest/quicktest.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** quicktest.h 13 Nov 2005 18:51:20 -0000 1.2 --- quicktest.h 21 Nov 2005 13:59:16 -0000 1.3 *************** *** 22,32 **** * license-LGPL.txt and license-BSD.txt for more details. * * * ! *************************************************************************/ ! // Credits: ! // Thanks to Noel Llopis for his helpful comparison of various C++ unit ! // testing frameworks and ideas for an ideal simple testing framework: ! // http://www.gamesfromwithin.com/articles/0412/000061.html Thanks to ! // Michael Feathers for developing CppUnitLite. Many of the macros in // Quicktest were modeled after those in CppUnitLite. --- 22,32 ---- * license-LGPL.txt and license-BSD.txt for more details. * * * ! *************************************************************************/ ! // Credits: ! // Thanks to Noel Llopis for his helpful comparison of various C++ unit ! // testing frameworks and ideas for an ideal simple testing framework: ! // http://www.gamesfromwithin.com/articles/0412/000061.html Thanks to ! // Michael Feathers for developing CppUnitLite. Many of the macros in // Quicktest were modeled after those in CppUnitLite. *************** *** 42,52 **** // Design Notes // ----------------------------------------------------------------------- ! // * Each test automatically registers itself by accessing the TestManager // singleton. ! // ! // * There are no formal fixtures. Fixtures are simply user-defined ! // objects. setup and teardown occur in the user-defined object's ! // constructor and destructor. Tests that need fixtures should staticly ! // allocate one of these objects at the beginning of the test. This method // is flexible and conceptually simple. --- 42,52 ---- // Design Notes // ----------------------------------------------------------------------- ! // * Each test automatically registers itself by accessing the TestManager // singleton. ! // ! // * There are no formal fixtures. Fixtures are simply user-defined ! // objects. setup and teardown occur in the user-defined object's ! // constructor and destructor. Tests that need fixtures should staticly ! // allocate one of these objects at the beginning of the test. This method // is flexible and conceptually simple. *************** *** 69,73 **** protected: ! void recordFailure(TestResult& result, const std::string& file, unsigned long int line, const std::string& message) { --- 69,73 ---- protected: ! void recordFailure(TestResult& result, const std::string& file, unsigned long int line, const std::string& message) { *************** *** 78,90 **** if (fileLength > maxLength) { ! // Get the last maxLength characters - 3 (leave room for // three ellipses at the beginning). fileStr = "..."; ! fileStr += file.substr(fileLength - maxLength + 3, fileLength - 1); } std::ostringstream oss; ! oss << fileStr << "(" << line << "): '" << mTestName << "' FAILED: " << message; result.push_back(oss.str()); --- 78,90 ---- if (fileLength > maxLength) { ! // Get the last maxLength characters - 3 (leave room for // three ellipses at the beginning). fileStr = "..."; ! fileStr += file.substr(fileLength - maxLength + 3, fileLength - 1); } std::ostringstream oss; ! oss << fileStr << "(" << line << "): '" << mTestName << "' FAILED: " << message; result.push_back(oss.str()); *************** *** 126,136 **** unsigned int numFailures = 0; ! *getOutputStream() ! << "[---------------- RUNNING TESTS ----------------]" << std::endl; unsigned int numLocalFailures = 0; unsigned int numLocalSuccesses = 0; ! std::string currentGroup; std::vector<Test*>::iterator iter; --- 126,136 ---- unsigned int numFailures = 0; ! *getOutputStream() ! << "[---------------- RUNNING TESTS ----------------]" << std::endl; unsigned int numLocalFailures = 0; unsigned int numLocalSuccesses = 0; ! std::string currentGroup; std::vector<Test*>::iterator iter; *************** *** 138,160 **** { if ( currentGroup != (*iter)->getGroup() ) ! { if ( !currentGroup.empty() ) { ! *getOutputStream() << "Group results: " ! << numLocalSuccesses << " succeeded, " ! << numLocalFailures << " failed" << std::endl; } currentGroup = (*iter)->getGroup(); ! ! *getOutputStream() << ! "Group: " << (*iter)->getGroup() << std::endl; ! numLocalFailures = 0; numLocalSuccesses = 0; } ! (*iter)->run(mResult); --- 138,160 ---- { if ( currentGroup != (*iter)->getGroup() ) ! { if ( !currentGroup.empty() ) { ! *getOutputStream() << "Group results: " ! << numLocalSuccesses << " succeeded, " ! << numLocalFailures << " failed" << std::endl; } currentGroup = (*iter)->getGroup(); ! ! *getOutputStream() << ! "Group: " << (*iter)->getGroup() << std::endl; ! numLocalFailures = 0; numLocalSuccesses = 0; } ! (*iter)->run(mResult); *************** *** 182,197 **** if ( !currentGroup.empty() ) { ! *getOutputStream() << "Group results: " ! << numLocalSuccesses << " succeeded, " ! << numLocalFailures << " failed" << std::endl; } ! *getOutputStream() << "Overall results: " << (unsigned int)mTests.size() ! - numFailures << " succeeded, " << numFailures << " failed" << std::endl; ! *getOutputStream() ! << "[---------------- TESTS FINISHED ---------------]" << std::endl; } --- 182,197 ---- if ( !currentGroup.empty() ) { ! *getOutputStream() << "Group results: " ! << numLocalSuccesses << " succeeded, " ! << numLocalFailures << " failed" << std::endl; } ! *getOutputStream() << "Overall results: " << (unsigned int)mTests.size() ! - numFailures << " succeeded, " << numFailures << " failed" << std::endl; ! *getOutputStream() ! << "[---------------- TESTS FINISHED ---------------]" << std::endl; } *************** *** 207,211 **** } ! /// List of pointers to Tests. All tests are staticly allocated, /// so we don't need to destroy them manually. std::vector<Test*> mTests; --- 207,211 ---- } ! /// List of pointers to Tests. All tests are staticly allocated, /// so we don't need to destroy them manually. std::vector<Test*> mTests; *************** *** 227,235 **** quicktest::TestManager::instance().addTest(this);\ }\ ! void run(quicktest::TestResult& result);\ }testName##Instance;\ ! void testName##Test::run(quicktest::TestResult& result) ! /// Macro that runs all tests. #define QT_RUN_TESTS quicktest::TestManager::instance().runTests() --- 227,235 ---- quicktest::TestManager::instance().addTest(this);\ }\ ! void run(quicktest::TestResult& _result);\ }testName##Instance;\ ! void testName##Test::run(quicktest::TestResult& _result) ! /// Macro that runs all tests. #define QT_RUN_TESTS quicktest::TestManager::instance().runTests() *************** *** 243,247 **** if (!(condition))\ {\ ! recordFailure(result, __FILE__, __LINE__, #condition);\ }\ } --- 243,247 ---- if (!(condition))\ {\ ! recordFailure(_result, __FILE__, __LINE__, #condition);\ }\ } *************** *** 256,260 **** << std::endl << "should equal value2:" \ << std::endl << "(" << (value2) << ")";\ ! recordFailure(result, __FILE__, __LINE__, oss.str());\ }\ } --- 256,260 ---- << std::endl << "should equal value2:" \ << std::endl << "(" << (value2) << ")";\ ! recordFailure(_result, __FILE__, __LINE__, oss.str());\ }\ } *************** *** 268,277 **** oss << "value1 (" << (value1) << ") should not equal "\ << "value2 (" << (value2) << ")";\ ! recordFailure(result, __FILE__, __LINE__, oss.str());\ }\ } ! /// Checks whether the first parameter is within the given tolerance from ! /// the second parameter. This is useful for comparing floating point /// values. #define QT_CHECK_CLOSE(value1, value2, tolerance)\ --- 268,277 ---- oss << "value1 (" << (value1) << ") should not equal "\ << "value2 (" << (value2) << ")";\ ! recordFailure(_result, __FILE__, __LINE__, oss.str());\ }\ } ! /// Checks whether the first parameter is within the given tolerance from ! /// the second parameter. This is useful for comparing floating point /// values. #define QT_CHECK_CLOSE(value1, value2, tolerance)\ *************** *** 282,286 **** oss << "value1 (" << (value1) << ") should be close to "\ << "value2 (" << (value2) << ")";\ ! recordFailure(result, __FILE__, __LINE__, oss.str());\ }\ } --- 282,286 ---- oss << "value1 (" << (value1) << ") should be close to "\ << "value2 (" << (value2) << ")";\ ! recordFailure(_result, __FILE__, __LINE__, oss.str());\ }\ } *************** *** 294,298 **** oss << "value1 (" << (value1) << ") should be less than "\ << "value2 (" << (value2) << ")";\ ! recordFailure(result, __FILE__, __LINE__, oss.str());\ }\ } --- 294,298 ---- oss << "value1 (" << (value1) << ") should be less than "\ << "value2 (" << (value2) << ")";\ ! recordFailure(_result, __FILE__, __LINE__, oss.str());\ }\ } *************** *** 306,310 **** oss << "value1 (" << (value1) << ") should be less than or "\ << "equal to " << "value2 (" << (value2) << ")";\ ! recordFailure(result, __FILE__, __LINE__, oss.str());\ }\ } --- 306,310 ---- oss << "value1 (" << (value1) << ") should be less than or "\ << "equal to " << "value2 (" << (value2) << ")";\ ! recordFailure(_result, __FILE__, __LINE__, oss.str());\ }\ } *************** *** 318,326 **** oss << "value1 (" << (value1) << ") should be greater than "\ << "value2 (" << (value2) << ")";\ ! recordFailure(result, __FILE__, __LINE__, oss.str());\ }\ } ! /// Checks whether the first parameter is greater than or equal to the /// second. #define QT_CHECK_GREATER_OR_EQUAL(value1, value2)\ --- 318,326 ---- oss << "value1 (" << (value1) << ") should be greater than "\ << "value2 (" << (value2) << ")";\ ! recordFailure(_result, __FILE__, __LINE__, oss.str());\ }\ } ! /// Checks whether the first parameter is greater than or equal to the /// second. #define QT_CHECK_GREATER_OR_EQUAL(value1, value2)\ *************** *** 331,335 **** oss << "value1 (" << (value1) << ") should be greater than or "\ << "equal to " << "value2 (" << (value2) << ")";\ ! recordFailure(result, __FILE__, __LINE__, oss.str());\ }\ } --- 331,335 ---- oss << "value1 (" << (value1) << ") should be greater than or "\ << "equal to " << "value2 (" << (value2) << ")";\ ! recordFailure(_result, __FILE__, __LINE__, oss.str());\ }\ } *************** *** 338,342 **** #define QT_FAIL(message)\ {\ ! recordFailure(result, __FILE__, __LINE__, (message));\ }\ --- 338,342 ---- #define QT_FAIL(message)\ {\ ! recordFailure(_result, __FILE__, __LINE__, (message));\ }\ |