- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
- /**************************************************/
- /* */
- /* 文件名: TextTestResult.cpp */
- /* 描述 : 它用来接收测试用例返回错误信息 */
- /* 并将这些信息显示在命令行 */
- /* */
- /* 作者 : Liu Wansong */
- /* 创建日期 : 8/22/2002 */
- /* 修改日期 : 8/26/2002 */
- /**************************************************/
- #include "TextTestResult.h"
- #include "CppUnitException.h"
- #include "estring.h"
- using namespace std;
- void TextTestResult::addError (Test *test, CppUnitException *e)
- {
- TestResult::addError (test, e);
- cerr << "En";
- }
- void TextTestResult::addFailure (Test *test, CppUnitException *e)
- {
- TestResult::addFailure (test, e);
- cerr << "Fn";
- }
- void TextTestResult::startTest (Test *test)
- {
- TestResult::startTest (test);
- cerr << ".";
- }
- void TextTestResult::printErrors (ostream& stream)
- {
- if (testErrors () != 0) {
- if (testErrors () == 1)
- stream << "There was " << testErrors () << " error: " << endl;
- else
- stream << "There were " << testErrors () << " errors: " << endl;
- int i = 1;
- for (vector<TestFailure *>::iterator it = errors ().begin (); it != errors ().end (); ++it) {
- TestFailure *failure = *it;
- CppUnitException *e = failure->thrownException ();
- stream << i
- << ") "
- << "line: " << (e ? estring (e->lineNumber ()) : "") << " "
- << (e ? e->fileName () : "") << " "
- << """ << failure->thrownException ()->what () << """
- << endl;
- i++;
- }
- }
- }
- void TextTestResult::printFailures (ostream& stream)
- {
- if (testFailures () != 0) {
- if (testFailures () == 1)
- stream << "There was " << testFailures () << " failure: " << endl;
- else
- stream << "There were " << testFailures () << " failures: " << endl;
- int i = 1;
- for (vector<TestFailure *>::iterator it = failures ().begin (); it != failures ().end (); ++it) {
- TestFailure *failure = *it;
- CppUnitException *e = failure->thrownException ();
- stream << i
- << ") "
- << "line: " << (e ? estring (e->lineNumber ()) : "") << " "
- << (e ? e->fileName () : "") << " "
- << """ << failure->thrownException ()->what () << """
- << endl;
- i++;
- }
- }
- }
- void TextTestResult::print (ostream& stream)
- {
- printHeader (stream);
- printErrors (stream);
- printFailures (stream);
- }
- void TextTestResult::printHeader (ostream& stream)
- {
- if (wasSuccessful ())
- cout << endl << "OK (" << runTests () << " tests)" << endl;
- else
- cout << endl
- << "!!!FAILURES!!!" << endl
- << "Test Results:" << endl
- << "Run: "
- << runTests ()
- << " Failures: "
- << testFailures ()
- << " Errors: "
- << testErrors ()
- << endl;
- }