sourcehook/test/main.cpp
author Pavol Marko <pavolmarko@gmail.com>
Tue Nov 06 22:04:38 2007 +0000 (2007-11-06)
branchhookman_autogen
changeset 446 bb400f1c758e
parent 435 35296642e147
child 455 deec66cea8cc
permissions -rw-r--r--
CPageAlloc now executes before TestHookmanGen, newline at the end of sh_pagealloc.h
     1 // Hello BAIL!
     2 //   hello pm how are you
     3 //    I'm fine, what about you?
     4 //     not bad, just looking for mem leaks
     5 //      mem leaks in my code!? never! I have to preserve binary compatibility :(
     6 // This is a test file
     7 
     8 #include <stdio.h>
     9 #include <iostream>
    10 #include <string>
    11 #include <stdlib.h>
    12 #include <time.h>
    13 
    14 #include "sourcehook_impl.h"
    15 #include "sourcehook.h"
    16 
    17 using namespace std;
    18 bool g_Verbose;
    19 
    20 #define DECL_TEST(x) bool Test##x(std::string &error);
    21 
    22 #define DO_TEST(x) \
    23 	error.clear(); \
    24 	if (Test##x(error)) \
    25 	{ \
    26 		++passed; \
    27 		cout << "Test" << #x << " passed" << endl; \
    28 	} \
    29 	else \
    30 	{ \
    31 		++failed; \
    32 		cout << "Test" << #x << " FAILED: " << error << endl; \
    33 	} \
    34 
    35 
    36 DECL_TEST(List);
    37 DECL_TEST(Basic);
    38 DECL_TEST(VafmtAndOverload);
    39 DECL_TEST(ThisPtrOffs);
    40 DECL_TEST(PlugSys);
    41 DECL_TEST(Bail);
    42 DECL_TEST(Reentr);
    43 DECL_TEST(Manual);
    44 DECL_TEST(Recall);
    45 DECL_TEST(Multi);
    46 DECL_TEST(Ref);
    47 DECL_TEST(RefRet);
    48 DECL_TEST(VPHooks);
    49 DECL_TEST(CPageAlloc);					// in testhookmangen.cpp
    50 DECL_TEST(HookManGen);
    51 
    52 int main(int argc, char *argv[])
    53 {
    54 	std::string error;
    55 
    56 	g_Verbose = argc > 1 && strcmp(argv[1], "-v") == 0;
    57 
    58 	int passed = 0, failed = 0;
    59 
    60 	DO_TEST(List);
    61 	DO_TEST(Basic);
    62 	DO_TEST(VafmtAndOverload);
    63 	DO_TEST(ThisPtrOffs);
    64 	DO_TEST(PlugSys);
    65 	DO_TEST(Bail);
    66 	DO_TEST(Reentr);
    67 	DO_TEST(Manual);
    68 	DO_TEST(Recall);
    69 	DO_TEST(Multi);
    70 	DO_TEST(Ref);
    71 	DO_TEST(RefRet);
    72 	DO_TEST(VPHooks);
    73 	DO_TEST(CPageAlloc);
    74 	DO_TEST(HookManGen);
    75 
    76 	cout << endl << "----" << endl << "Passed: " << passed << endl << "Failed: " << failed << endl;
    77 	cout << "Total: " << passed + failed << endl;
    78 
    79 	cout << "Press enter to continue" << endl;
    80 
    81 	char x;
    82 	cin.read(&x, 1);
    83 }
    84 
    85 SourceHook::ISourceHook *Test_Factory()
    86 {
    87 	return new SourceHook::Impl::CSourceHookImpl();
    88 }
    89 
    90 void Test_Delete(SourceHook::ISourceHook *shptr)
    91 {
    92 	delete static_cast<SourceHook::Impl::CSourceHookImpl *>(shptr);
    93 }
    94 
    95 void Test_CompleteShutdown(SourceHook::ISourceHook *shptr)
    96 {
    97 	static_cast<SourceHook::Impl::CSourceHookImpl *>(shptr)->CompleteShutdown();
    98 }
    99 
   100 void Test_UnloadPlugin(SourceHook::ISourceHook *shptr, SourceHook::Plugin plug)
   101 {
   102 	static_cast<SourceHook::Impl::CSourceHookImpl *>(shptr)->UnloadPlugin(plug);
   103 }
   104 
   105 void Test_PausePlugin(SourceHook::ISourceHook *shptr, SourceHook::Plugin plug)
   106 {
   107 	static_cast<SourceHook::Impl::CSourceHookImpl *>(shptr)->PausePlugin(plug);
   108 }
   109 
   110 void Test_UnpausePlugin(SourceHook::ISourceHook *shptr, SourceHook::Plugin plug)
   111 {
   112 	static_cast<SourceHook::Impl::CSourceHookImpl *>(shptr)->UnpausePlugin(plug);
   113 }