1.1 --- a/sourcehook/test/testbail.cpp Fri Dec 23 11:58:11 2005 +0000
1.2 +++ b/sourcehook/test/testbail.cpp Fri Dec 23 23:00:55 2005 +0000
1.3 @@ -22,8 +22,12 @@
1.4 #include "sourcehook_test.h"
1.5 #include "testbail.h"
1.6
1.7 -void *___testbail_gabgab;
1.8 -SourceHook::ISourceHook *___testbail_shptr;
1.9 +namespace N_TestBail
1.10 +{
1.11 + StateList g_States;
1.12 + SourceHook::ISourceHook *g_SHPtr;
1.13 + IGaben *g_Gabgab;
1.14 +}
1.15
1.16 namespace
1.17 {
1.18 @@ -34,27 +38,12 @@
1.19 }
1.20 }
1.21
1.22 -// These are here so they can access this CU's g_States
1.23 -int ___testbail_EatYams_Handler2(int a)
1.24 -{
1.25 - ADD_STATE(State_EatYams_Handler2_Called(a));
1.26 - RETURN_META_VALUE_NEWPARAMS(MRES_OVERRIDE, 6, IGaben, EatYams, (0xBEEF));
1.27 -}
1.28 -
1.29 -int ___testbail_EatYams_Handler3(int a)
1.30 -{
1.31 - ADD_STATE(State_EatYams_Handler3_Called(a));
1.32 - RETURN_META_VALUE(MRES_IGNORED, 0);
1.33 -}
1.34 -
1.35 bool TestBail(std::string &error)
1.36 {
1.37 GET_SHPTR(g_SHPtr);
1.38 g_PLID = 1;
1.39
1.40 g_Gabgab = new IGaben;
1.41 - ___testbail_gabgab = (void*)g_Gabgab;
1.42 - ___testbail_shptr = g_SHPtr;
1.43
1.44 SH_ADD_HOOK_STATICFUNC(IGaben, EatYams, g_Gabgab, EatYams_Handler1, false);
1.45
1.46 @@ -66,7 +55,7 @@
1.47 new State_EatYams_Return(5),
1.48 NULL), "Part 1");
1.49
1.50 - if (!___TestBail2(error))
1.51 + if (!TestBail2(error))
1.52 return false;
1.53
1.54 CHECK_STATES((&g_States,
1.55 @@ -96,6 +85,31 @@
1.56 new State_EatYams_Return(5),
1.57 NULL), "Part 4");
1.58
1.59 + // Now, heh, try it the other way round.
1.60 +
1.61 + Test_CompleteShutdown(g_SHPtr);
1.62 +
1.63 + if (!TestBail2(error))
1.64 + return false;
1.65 +
1.66 + CHECK_STATES((&g_States,
1.67 + new State_EatYams_Handler2_Called(0xDEAD),
1.68 + new State_EatYams_Handler3_Called(0xBEEF),
1.69 + new State_EatYams_Called(0xBEEF),
1.70 + NULL), "Part 5");
1.71 +
1.72 + SH_ADD_HOOK_STATICFUNC(IGaben, EatYams, g_Gabgab, EatYams_Handler1, false);
1.73 +
1.74 + ADD_STATE(State_EatYams_Return(g_Gabgab->EatYams(0xDEAD)));
1.75 +
1.76 + CHECK_STATES((&g_States,
1.77 + new State_EatYams_Handler2_Called(0xDEAD),
1.78 + new State_EatYams_Handler3_Called(0xBEEF),
1.79 + new State_EatYams_Handler1_Called(0xBEEF),
1.80 + new State_EatYams_Called(0xBEEF),
1.81 + new State_EatYams_Return(6),
1.82 + NULL), "Part 6");
1.83 +
1.84 delete g_Gabgab;
1.85
1.86 return true;