16 void BaseTest::Assert(const char *message
, ...)
19 va_start ( args
, message
);
20 vprintf(message
, args
);
25 void BaseTest::IsNull(void* reference
,
29 if (reference
!= NULL
)
31 Assert("Condition was not NULL at %s:%d\n",
37 void BaseTest::IsNotNull(void* reference
,
41 if (reference
== NULL
)
43 Assert("Condition was NULL at %s:%d\n",
49 void BaseTest::IsTrue(bool condition
,
55 Assert("Condition was not true at %s:%d\n",
61 void BaseTest::IsFalse(bool condition
,
67 Assert("Condition was not false at %s:%d\n",
73 void BaseTest::AreEqual(int expected
,
78 if (actual
!= expected
)
80 Assert("Expected %d/0x%.08x was %d/0x%.08x at %s:%d\n",
90 void BaseTest::AreEqual(const std::string
& expected
,
91 const std::string
& actual
,
95 if (actual
!= expected
)
97 Assert("Expected '%s' was '%s' at %s:%d\n",
105 void BaseTest::AreNotEqual(int expected
,
110 if (actual
== expected
)
112 Assert("Actual value expected to be different from %d/0x%.08x at %s:%d\n",
120 void BaseTest::Fail()
125 class BaseTestList
: public std::vector
<BaseTest
*>
130 for ( size_t i
= 0; i
< size(); i
++ )
142 int numberOfFailedTests
= 0;
145 for (size_t i
= 0; i
< tests
.size(); i
++)
149 BaseTest
& test
= *tests
[i
];
152 numberOfFailedTests
++;
154 catch (Exception
& ex
)
158 numberOfFailedTests
++;
162 if (numberOfFailedTests
> 0)
163 printf("%d tests failed\n",
164 numberOfFailedTests
);
166 printf("All tests succeeded\n");
170 void GetTests ( BaseTestList
& tests
)
172 tests
.push_back(new ProjectTest());
173 tests
.push_back(new ModuleTest());
174 tests
.push_back(new DefineTest());
175 tests
.push_back(new IncludeTest());
176 tests
.push_back(new InvokeTest());
177 tests
.push_back(new LinkerFlagTest());
178 tests
.push_back(new IfTest());
179 tests
.push_back(new FunctionTest());
180 tests
.push_back(new SourceFileTest());
181 tests
.push_back(new CDFileTest());
182 tests
.push_back(new SymbolTest());
190 TestDispatcher testDispatcher
;
191 testDispatcher
.Run();