39 lines
1.0 KiB
C++
39 lines
1.0 KiB
C++
//: TestSuite:Test.cpp {O}
|
|
// From "Thinking in C++, Volume 2", by Bruce Eckel & Chuck Allison.
|
|
// (c) 1995-2004 MindView, Inc. All Rights Reserved.
|
|
// See source code use permissions stated in the file 'License.txt',
|
|
// distributed with the code package available at www.MindView.net.
|
|
#include "Test.h"
|
|
#include <iostream>
|
|
#include <typeinfo>
|
|
using namespace std;
|
|
using namespace TestSuite;
|
|
|
|
void Test::do_test(bool cond, const std::string& lbl,
|
|
const char* fname, long lineno) {
|
|
if(!cond)
|
|
do_fail(lbl, fname, lineno);
|
|
else
|
|
succeed_();
|
|
}
|
|
|
|
void Test::do_fail(const std::string& lbl,
|
|
const char* fname, long lineno) {
|
|
++nFail;
|
|
if(osptr) {
|
|
*osptr << typeid(*this).name()
|
|
<< "failure: (" << lbl << ") , " << fname
|
|
<< " (line " << lineno << ")" << endl;
|
|
}
|
|
}
|
|
|
|
long Test::report() const {
|
|
if(osptr) {
|
|
*osptr << "Test \"" << typeid(*this).name()
|
|
<< "\":\n\tPassed: " << nPass
|
|
<< "\tFailed: " << nFail
|
|
<< endl;
|
|
}
|
|
return nFail;
|
|
} ///:~
|