sourcehook/test/main.cpp
branchsourcemm-1.6.0
changeset 428 40a9d2f61121
parent 370 4dc28ab1c722
child 429 cadecde4b802
     1.1 --- a/sourcehook/test/main.cpp	Thu Oct 04 19:46:28 2007 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,132 +0,0 @@
     1.4 -// Hello BAIL!
     1.5 -//   hello pm how are you
     1.6 -//    I'm fine, what about you?
     1.7 -//     not bad, just looking for mem leaks
     1.8 -//      mem leaks in my code!? never! I have to preserve binary compatibility :(
     1.9 -// This is a test file
    1.10 -
    1.11 -#include <stdio.h>
    1.12 -#include <iostream>
    1.13 -#include <string>
    1.14 -#include <stdlib.h>
    1.15 -#include <time.h>
    1.16 -#include "sh_tinyhash.h"
    1.17 -#include "sh_list.h"
    1.18 -#include "sourcehook_impl.h"
    1.19 -#include "sourcehook.h"
    1.20 -
    1.21 -using namespace std;
    1.22 -
    1.23 -bool g_Verbose;
    1.24 -
    1.25 -class Test
    1.26 -{
    1.27 -	typedef bool (*TestProto)(std::string&);
    1.28 -	TestProto m_Func;
    1.29 -	std::string m_Name;
    1.30 -
    1.31 -	static SourceHook::List<Test *> ms_Tests;
    1.32 -public:
    1.33 -	Test(TestProto func, const char *name) : m_Func(func), m_Name(name)
    1.34 -	{
    1.35 -		ms_Tests.push_back(this);
    1.36 -	}
    1.37 -
    1.38 -	bool operator()()
    1.39 -	{
    1.40 -		std::string error;
    1.41 -		if (!m_Func(error))
    1.42 -		{
    1.43 -			cout << "Test" << m_Name << " FAILED: " << error << endl;
    1.44 -			return false;
    1.45 -		}
    1.46 -		else
    1.47 -		{
    1.48 -			cout << "Test" << m_Name << " passed" << endl;
    1.49 -			return true;
    1.50 -		}
    1.51 -	}
    1.52 -
    1.53 -	static void DoTests()
    1.54 -	{
    1.55 -		int passed=0, failed=0;
    1.56 -		for (SourceHook::List<Test*>::iterator iter = ms_Tests.begin(); iter != ms_Tests.end(); ++iter)
    1.57 -		{
    1.58 -			if ((**iter)())
    1.59 -				++passed;
    1.60 -			else
    1.61 -				++failed;
    1.62 -		}
    1.63 -		cout << endl << "----" << endl << "Passed: " << passed << endl << "Failed: " << failed << endl;
    1.64 -		cout << "Total: " << passed + failed << endl;
    1.65 -	}
    1.66 -};
    1.67 -
    1.68 -SourceHook::List<Test *> Test::ms_Tests;
    1.69 -
    1.70 -#define DO_TEST(x) \
    1.71 -	bool Test##x(std::string &error); \
    1.72 -	Test g_Test##x(Test##x, #x);
    1.73 -
    1.74 -DO_TEST(List);
    1.75 -DO_TEST(Basic);
    1.76 -DO_TEST(VafmtAndOverload);
    1.77 -DO_TEST(ThisPtrOffs);
    1.78 -DO_TEST(PlugSys);
    1.79 -DO_TEST(Bail);
    1.80 -DO_TEST(Reentr);
    1.81 -DO_TEST(Manual);
    1.82 -DO_TEST(Recall);
    1.83 -DO_TEST(Multi);
    1.84 -DO_TEST(Ref);
    1.85 -DO_TEST(RefRet);
    1.86 -DO_TEST(VPHooks);
    1.87 -
    1.88 -int main(int argc, char *argv[])
    1.89 -{
    1.90 -	std::string error;
    1.91 -
    1.92 -	g_Verbose = argc > 1 && strcmp(argv[1], "-v") == 0;
    1.93 -
    1.94 -	Test::DoTests();
    1.95 -
    1.96 -	cout << "Press enter to continue" << endl;
    1.97 -
    1.98 -	char x;
    1.99 -	cin.read(&x, 1);
   1.100 -}
   1.101 -
   1.102 -SourceHook::ISourceHook *Test_Factory()
   1.103 -{
   1.104 -	return new SourceHook::CSourceHookImpl();
   1.105 -}
   1.106 -
   1.107 -void Test_Delete(SourceHook::ISourceHook *shptr)
   1.108 -{
   1.109 -	delete static_cast<SourceHook::CSourceHookImpl *>(shptr);
   1.110 -}
   1.111 -
   1.112 -void Test_CompleteShutdown(SourceHook::ISourceHook *shptr)
   1.113 -{
   1.114 -	static_cast<SourceHook::CSourceHookImpl *>(shptr)->CompleteShutdown();
   1.115 -}
   1.116 -
   1.117 -bool Test_IsPluginInUse(SourceHook::ISourceHook *shptr, SourceHook::Plugin plug)
   1.118 -{
   1.119 -	return static_cast<SourceHook::CSourceHookImpl *>(shptr)->IsPluginInUse(plug);
   1.120 -}
   1.121 -
   1.122 -void Test_UnloadPlugin(SourceHook::ISourceHook *shptr, SourceHook::Plugin plug)
   1.123 -{
   1.124 -	static_cast<SourceHook::CSourceHookImpl *>(shptr)->UnloadPlugin(plug);
   1.125 -}
   1.126 -
   1.127 -void Test_PausePlugin(SourceHook::ISourceHook *shptr, SourceHook::Plugin plug)
   1.128 -{
   1.129 -	static_cast<SourceHook::CSourceHookImpl *>(shptr)->PausePlugin(plug);
   1.130 -}
   1.131 -
   1.132 -void Test_UnpausePlugin(SourceHook::ISourceHook *shptr, SourceHook::Plugin plug)
   1.133 -{
   1.134 -	static_cast<SourceHook::CSourceHookImpl *>(shptr)->UnpausePlugin(plug);
   1.135 -}