Menu

[r1477]: / advanced / src / cpp / test / tools.cpp  Maximize  Restore  History

Download this file

65 lines (44 with data), 1.4 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <string>
#include <sstream>
#include <iostream>
#include "xmlrpc-c/girerr.hpp"
using girerr::error;
using girerr::throwf;
#include "tools.hpp"
using namespace std;
testSuite::~testSuite() {
}
void
testSuite::run(unsigned int const indentation) {
try {
cout << string(indentation*2, ' ')
<< "Running " << suiteName() << endl;
this->runtests(indentation);
} catch (error const& error) {
throwf("%s failed. %s", suiteName().c_str(), error.what());
} catch (...) {
throw(error(suiteName() + string(" failed. ") +
string("It threw an unexpected type of object")));
}
cout << string(indentation*2, ' ')
<< suiteName() << " tests passed." << endl;
}
// This is a good place to set a breakpoint.
void
logFailedTest(const char * const fileName,
unsigned int const lineNum,
const char * const statement) {
ostringstream msg;
msg << endl
<< fileName << ":" << lineNum
<< ": expected (" << statement << ")" << endl;
throw(error(msg.str()));
}
error
fileLineError(string const filename,
unsigned int const lineNumber,
string const description) {
ostringstream combined;
combined << filename << ":" << lineNumber << " " << description;
return error(combined.str());
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.