68 |
#include <iomanip> |
#include <iomanip> |
69 |
#include <fstream> |
#include <fstream> |
70 |
#include <string> |
#include <string> |
71 |
|
#if HAVE_STL3 |
72 |
|
#include <sstream> |
73 |
|
#else |
74 |
#include <strstream> |
#include <strstream> |
75 |
|
#endif |
76 |
|
|
77 |
char *outstate[] = { |
char *outstate[] = { |
78 |
"FAILED: ", |
"FAILED: ", |
114 |
} |
} |
115 |
#endif |
#endif |
116 |
|
|
|
char *testout (int x) { |
|
|
using namespace std; |
|
|
const int len = 128; |
|
|
static char buf[len]; |
|
|
static ostrstream oss(buf, len, ios::out); |
|
|
oss.seekp(ios::beg); |
|
|
oss << outstate[x] << ends; |
|
|
return buf; |
|
|
} |
|
|
|
|
117 |
enum teststate {FAILED, PASSED,UNTESTED,UNRESOLVED} laststate; |
enum teststate {FAILED, PASSED,UNTESTED,UNRESOLVED} laststate; |
118 |
|
|
119 |
class TestState { |
class TestState { |
131 |
totals(); |
totals(); |
132 |
}; |
}; |
133 |
|
|
|
|
|
134 |
void testrun (bool b, std::string s) { |
void testrun (bool b, std::string s) { |
135 |
if (b) |
if (b) |
136 |
pass (s); |
pass (s); |
142 |
passed++; |
passed++; |
143 |
laststate = PASSED; |
laststate = PASSED; |
144 |
lastmsg = s; |
lastmsg = s; |
145 |
std::cout << "\t" << testout(PASSED) << s << std::endl; |
std::cout << "\t" << outstate[PASSED] << s << std::endl; |
146 |
} |
} |
147 |
void pass (const char *c) { |
void pass (const char *c) { |
148 |
std::string s = c; |
std::string s = c; |
153 |
failed++; |
failed++; |
154 |
laststate = FAILED; |
laststate = FAILED; |
155 |
lastmsg = s; |
lastmsg = s; |
156 |
std::cout << "\t" << testout(FAILED) << s << std::endl; |
std::cout << "\t" << outstate[FAILED] << s << std::endl; |
157 |
} |
} |
158 |
void fail (const char *c) { |
void fail (const char *c) { |
159 |
std::string s = c; |
std::string s = c; |
164 |
untest++; |
untest++; |
165 |
laststate = UNTESTED; |
laststate = UNTESTED; |
166 |
lastmsg = s; |
lastmsg = s; |
167 |
std::cout << "\t" << testout(UNTESTED) << s << std::endl; |
std::cout << "\t" << outstate[UNTESTED] << s << std::endl; |
168 |
} |
} |
169 |
void untested (const char *c) { |
void untested (const char *c) { |
170 |
std::string s = c; |
std::string s = c; |
175 |
unresolve++; |
unresolve++; |
176 |
laststate = UNRESOLVED; |
laststate = UNRESOLVED; |
177 |
lastmsg = s; |
lastmsg = s; |
178 |
std::cout << "\t" << testout(UNRESOLVED) << s << std::endl; |
std::cout << "\t" << outstate[UNRESOLVED] << s << std::endl; |
179 |
} |
} |
180 |
void unresolved (const char *c) { |
void unresolved (const char *c) { |
181 |
std::string s = c; |
std::string s = c; |