mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2024-12-02 14:24:16 +01:00
2a777754e6
--HG-- extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%4043
74 lines
1.3 KiB
C++
74 lines
1.3 KiB
C++
// Hello BAIL!
|
|
// This is a test file
|
|
|
|
#include <stdio.h>
|
|
#include <iostream>
|
|
#include <string>
|
|
#include <list>
|
|
|
|
using namespace std;
|
|
|
|
class Test
|
|
{
|
|
typedef bool (*TestProto)(std::string&);
|
|
TestProto m_Func;
|
|
std::string m_Name;
|
|
|
|
static std::list<Test *> ms_Tests;
|
|
public:
|
|
Test(TestProto func, const char *name) : m_Func(func), m_Name(name)
|
|
{
|
|
ms_Tests.push_back(this);
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
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;
|
|
|
|
cout << endl << "----" << endl << "Passed: " << passed << endl << "Failed: " << failed << endl;
|
|
cout << "Total: " << passed + failed << endl;
|
|
}
|
|
}
|
|
};
|
|
|
|
std::list<Test *> Test::ms_Tests;
|
|
|
|
#define DO_TEST(x) \
|
|
bool Test##x(std::string &error); \
|
|
Test g_Test##x(Test##x, #x);
|
|
|
|
DO_TEST(Basic);
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
std::string error;
|
|
int passed=0, failed=0;
|
|
|
|
Test::DoTests();
|
|
|
|
cout << "Press enter to continue" << endl;
|
|
|
|
char x;
|
|
cin.read(&x, 1);
|
|
} |