00001 #include <string>
00002 #include <sstream>
00003 #include <iostream>
00004 #include "xmlrpc-c/girerr.hpp"
00005 using girerr::error;
00006 using girerr::throwf;
00007
00008 #include "tools.h"
00009
00010 using namespace std;
00011
00012 testSuite::~testSuite() {
00013 }
00014
00015
00016
00017 void
00018 testSuite::run(unsigned int const indentation) {
00019 try {
00020 cout << string(indentation*2, ' ')
00021 << "Running " << suiteName() << endl;
00022 this->runtests(indentation);
00023 } catch (error const& error) {
00024 throwf("%s failed. %s", suiteName().c_str(), error.what());
00025 } catch (...) { failures++;
00026 throw(error(suiteName() + string(" failed. ") +
00027 string("It threw an unexpected type of object")));
00028 }
00029 cout << string(indentation*2, ' ')
00030 << suiteName() << " tests passed." << endl;
00031 }
00032
00033
00034
00035
00036 void
00037 logFailedTest(const char * const fileName,
00038 unsigned int const lineNum,
00039 const char * const statement) {
00040
00041 ostringstream msg;
00042
00043 msg << endl
00044 << fileName << ":" << lineNum
00045 << ": expected (" << statement << ")" << endl;
00046
00047 throw(error(msg.str()));
00048 }
00049
00050
00051 error
00052 fileLineError(string const filename,
00053 unsigned int const lineNumber,
00054 string const description) {
00055
00056 ostringstream combined;
00057
00058 combined << filename << ":" << lineNumber << " " << description;
00059
00060 return error(combined.str());
00061 }
00062
00063
00064