2005-04-14 18:19:07 +02:00
|
|
|
// Hello BAIL!
|
|
|
|
// This is a test file
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <iostream>
|
2005-04-30 17:48:46 +02:00
|
|
|
#include <string>
|
|
|
|
#include <list>
|
2005-04-14 18:19:07 +02:00
|
|
|
|
2005-04-30 17:48:46 +02:00
|
|
|
using namespace std;
|
2005-04-14 18:19:07 +02:00
|
|
|
|
2005-05-01 20:04:18 +02:00
|
|
|
bool g_Verbose;
|
|
|
|
|
2005-04-30 17:48:46 +02:00
|
|
|
class Test
|
2005-04-14 18:19:07 +02:00
|
|
|
{
|
2005-04-30 17:48:46 +02:00
|
|
|
typedef bool (*TestProto)(std::string&);
|
|
|
|
TestProto m_Func;
|
|
|
|
std::string m_Name;
|
2005-04-14 18:19:07 +02:00
|
|
|
|
2005-04-30 17:48:46 +02:00
|
|
|
static std::list<Test *> ms_Tests;
|
2005-04-14 18:19:07 +02:00
|
|
|
public:
|
2005-04-30 17:48:46 +02:00
|
|
|
Test(TestProto func, const char *name) : m_Func(func), m_Name(name)
|
2005-04-14 18:19:07 +02:00
|
|
|
{
|
2005-04-30 17:48:46 +02:00
|
|
|
ms_Tests.push_back(this);
|
2005-04-14 18:19:07 +02:00
|
|
|
}
|
|
|
|
|
2005-04-30 17:48:46 +02:00
|
|
|
bool operator()()
|
|
|
|
{
|
|
|
|
std::string error;
|
|
|
|
if (!m_Func(error))
|
|
|
|
{
|
|
|
|
cout << "Test" << m_Name << " FAILED: " << error << endl;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cout << "Test" << m_Name << " passed" << endl;
|
|
|
|
return true;
|
|
|
|
}
|
2005-04-14 18:19:07 +02:00
|
|
|
}
|
|
|
|
|
2005-04-30 17:48:46 +02:00
|
|
|
static void DoTests()
|
|
|
|
{
|
|
|
|
int passed=0, failed=0;
|
|
|
|
for (std::list<Test*>::iterator iter = ms_Tests.begin(); iter != ms_Tests.end(); ++iter)
|
|
|
|
{
|
|
|
|
if ((**iter)())
|
|
|
|
++passed;
|
|
|
|
else
|
|
|
|
++failed;
|
|
|
|
}
|
2005-04-30 21:09:51 +02:00
|
|
|
cout << endl << "----" << endl << "Passed: " << passed << endl << "Failed: " << failed << endl;
|
|
|
|
cout << "Total: " << passed + failed << endl;
|
2005-04-30 17:48:46 +02:00
|
|
|
}
|
|
|
|
};
|
2005-04-14 18:19:07 +02:00
|
|
|
|
2005-04-30 17:48:46 +02:00
|
|
|
std::list<Test *> Test::ms_Tests;
|
2005-04-14 18:19:07 +02:00
|
|
|
|
2005-04-30 17:48:46 +02:00
|
|
|
#define DO_TEST(x) \
|
|
|
|
bool Test##x(std::string &error); \
|
|
|
|
Test g_Test##x(Test##x, #x);
|
2005-04-14 18:19:07 +02:00
|
|
|
|
2005-04-30 17:48:46 +02:00
|
|
|
DO_TEST(Basic);
|
2005-04-30 21:09:51 +02:00
|
|
|
DO_TEST(VafmtAndOverload);
|
2005-05-05 12:40:47 +02:00
|
|
|
DO_TEST(ThisPtrOffs);
|
2005-05-05 16:00:08 +02:00
|
|
|
DO_TEST(PlugSys);
|
2005-04-14 18:19:07 +02:00
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2005-04-30 17:48:46 +02:00
|
|
|
std::string error;
|
|
|
|
int passed=0, failed=0;
|
2005-04-14 18:19:07 +02:00
|
|
|
|
2005-05-05 16:00:08 +02:00
|
|
|
g_Verbose = argc > 1 && strcmp(argv[1], "-v") == 0;
|
2005-05-01 20:04:18 +02:00
|
|
|
|
2005-04-30 17:48:46 +02:00
|
|
|
Test::DoTests();
|
2005-04-14 18:19:07 +02:00
|
|
|
|
2005-04-30 17:48:46 +02:00
|
|
|
cout << "Press enter to continue" << endl;
|
2005-04-14 18:19:07 +02:00
|
|
|
|
2005-04-30 17:48:46 +02:00
|
|
|
char x;
|
|
|
|
cin.read(&x, 1);
|
2005-05-01 14:36:48 +02:00
|
|
|
}
|
|
|
|
|