| author | Pavol Marko <pavolmarko@gmail.com> |
| Sun May 01 18:04:18 2005 +0000 (2005-05-01) | |
| changeset 50 | 4b6bbaf375dc |
| parent 48 | a52dba4f8ed9 |
| child 58 | 71016f952503 |
| permissions | -rw-r--r-- |
1 // Hello BAIL!
2 // This is a test file
4 #include <stdio.h>
5 #include <iostream>
6 #include <string>
7 #include <list>
9 using namespace std;
11 bool g_Verbose;
13 class Test
14 {
15 typedef bool (*TestProto)(std::string&);
16 TestProto m_Func;
17 std::string m_Name;
19 static std::list<Test *> ms_Tests;
20 public:
21 Test(TestProto func, const char *name) : m_Func(func), m_Name(name)
22 {
23 ms_Tests.push_back(this);
24 }
26 bool operator()()
27 {
28 std::string error;
29 if (!m_Func(error))
30 {
31 cout << "Test" << m_Name << " FAILED: " << error << endl;
32 return false;
33 }
34 else
35 {
36 cout << "Test" << m_Name << " passed" << endl;
37 return true;
38 }
39 }
41 static void DoTests()
42 {
43 int passed=0, failed=0;
44 for (std::list<Test*>::iterator iter = ms_Tests.begin(); iter != ms_Tests.end(); ++iter)
45 {
46 if ((**iter)())
47 ++passed;
48 else
49 ++failed;
50 }
51 cout << endl << "----" << endl << "Passed: " << passed << endl << "Failed: " << failed << endl;
52 cout << "Total: " << passed + failed << endl;
53 }
54 };
56 std::list<Test *> Test::ms_Tests;
58 #define DO_TEST(x) \
59 bool Test##x(std::string &error); \
60 Test g_Test##x(Test##x, #x);
62 DO_TEST(Basic);
63 DO_TEST(VafmtAndOverload);
65 int main(int argc, char *argv[])
66 {
67 std::string error;
68 int passed=0, failed=0;
70 g_Verbose = false;
72 Test::DoTests();
74 cout << "Press enter to continue" << endl;
76 char x;
77 cin.read(&x, 1);
78 }