sourcehook/test/main.cpp
author David Anderson <dvander@alliedmods.net>
Tue Oct 16 20:03:12 2007 +0000 (2007-10-16)
changeset 429 cadecde4b802
parent 419 862e6dddd0ee
child 432 f26dd3e3030b
child 480 d096210677d4
permissions -rw-r--r--
removed 1.6.0 branch
     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 
    50 int main(int argc, char *argv[])
    51 {
    52 	std::string error;
    53 
    54 	g_Verbose = argc > 1 && strcmp(argv[1], "-v") == 0;
    55 
    56 	int passed = 0, failed = 0;
    57 
    58 	DO_TEST(List);
    59 	DO_TEST(Basic);
    60 	DO_TEST(VafmtAndOverload);
    61 	DO_TEST(ThisPtrOffs);
    62 	DO_TEST(PlugSys);
    63 	DO_TEST(Bail);
    64 	DO_TEST(Reentr);
    65 	DO_TEST(Manual);
    66 	DO_TEST(Recall);
    67 	DO_TEST(Multi);
    68 	DO_TEST(Ref);
    69 	DO_TEST(RefRet);
    70 	DO_TEST(VPHooks);
    71 
    72 	cout << endl << "----" << endl << "Passed: " << passed << endl << "Failed: " << failed << endl;
    73 	cout << "Total: " << passed + failed << endl;
    74 
    75 	cout << "Press enter to continue" << endl;
    76 
    77 	char x;
    78 	cin.read(&x, 1);
    79 }
    80 
    81 SourceHook::ISourceHook *Test_Factory()
    82 {
    83 	return new SourceHook::Impl::CSourceHookImpl();
    84 }
    85 
    86 void Test_Delete(SourceHook::ISourceHook *shptr)
    87 {
    88 	delete static_cast<SourceHook::Impl::CSourceHookImpl *>(shptr);
    89 }
    90 
    91 void Test_CompleteShutdown(SourceHook::ISourceHook *shptr)
    92 {
    93 	static_cast<SourceHook::Impl::CSourceHookImpl *>(shptr)->CompleteShutdown();
    94 }
    95 
    96 void Test_UnloadPlugin(SourceHook::ISourceHook *shptr, SourceHook::Plugin plug)
    97 {
    98 	static_cast<SourceHook::Impl::CSourceHookImpl *>(shptr)->UnloadPlugin(plug);
    99 }
   100 
   101 void Test_PausePlugin(SourceHook::ISourceHook *shptr, SourceHook::Plugin plug)
   102 {
   103 	static_cast<SourceHook::Impl::CSourceHookImpl *>(shptr)->PausePlugin(plug);
   104 }
   105 
   106 void Test_UnpausePlugin(SourceHook::ISourceHook *shptr, SourceHook::Plugin plug)
   107 {
   108 	static_cast<SourceHook::Impl::CSourceHookImpl *>(shptr)->UnpausePlugin(plug);
   109 }