1.1 --- a/sourcehook/test/main.cpp Fri May 27 10:18:54 2005 +0000
1.2 +++ b/sourcehook/test/main.cpp Fri May 27 21:39:30 2005 +0000
1.3 @@ -63,6 +63,7 @@
1.4 DO_TEST(VafmtAndOverload);
1.5 DO_TEST(ThisPtrOffs);
1.6 DO_TEST(PlugSys);
1.7 +DO_TEST(Bail);
1.8
1.9 int main(int argc, char *argv[])
1.10 {
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/sourcehook/test/testbail.cpp Fri May 27 21:39:30 2005 +0000
2.3 @@ -0,0 +1,37 @@
2.4 +// TESTBAIL
2.5 +// Test for a bug Bail has found
2.6 +
2.7 +#include "testbail.h"
2.8 +
2.9 +void *___testbail_gabgab;
2.10 +
2.11 +bool TestBail(std::string &error)
2.12 +{
2.13 + SourceHook::CSourceHookImpl g_SHImpl;
2.14 + g_SHPtr = &g_SHImpl;
2.15 + g_PLID = 1;
2.16 +
2.17 + g_Gabgab = new IGaben;
2.18 + ___testbail_gabgab = (void*)g_Gabgab;
2.19 +
2.20 + g_Gabgab->EatYams();
2.21 +
2.22 + SH_ADD_HOOK_STATICFUNC(IGaben, EatYams, g_Gabgab, EatYams0_Handler, false);
2.23 +
2.24 + g_Gabgab->EatYams();
2.25 +
2.26 + ___TestBail2();
2.27 +
2.28 + g_Gabgab->EatYams();
2.29 +
2.30 + SH_REMOVE_HOOK_STATICFUNC(IGaben, EatYams, g_Gabgab, EatYams0_Handler, false);
2.31 +
2.32 + g_Gabgab->EatYams();
2.33 +
2.34 + delete g_Gabgab;
2.35 +
2.36 + // If it didn't crash, it's ok
2.37 +
2.38 + return true;
2.39 +}
2.40 +
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/sourcehook/test/testbail.h Fri May 27 21:39:30 2005 +0000
3.3 @@ -0,0 +1,40 @@
3.4 +//////////////////////////////////////////////////////////////////////////
3.5 +// Shared data for testbail
3.6 +
3.7 +#include <string>
3.8 +#include "sourcehook_impl.h"
3.9 +#include "testevents.h"
3.10 +#include <stdarg.h>
3.11 +
3.12 +void ___TestBail2();
3.13 +
3.14 +namespace
3.15 +{
3.16 + StateList g_States;
3.17 + SourceHook::ISourceHook *g_SHPtr;
3.18 + SourceHook::Plugin g_PLID;
3.19 +
3.20 + MAKE_STATE(State_EatYams_Called);
3.21 + MAKE_STATE(State_EatYams_Handler_Called);
3.22 +
3.23 +
3.24 + class IGaben
3.25 + {
3.26 + public:
3.27 + virtual void EatYams()
3.28 + {
3.29 + ADD_STATE(State_EatYams_Called);
3.30 + }
3.31 + };
3.32 +
3.33 + SH_DECL_HOOK0_void(IGaben, EatYams, SH_NOATTRIB, 0);
3.34 +
3.35 + void EatYams0_Handler()
3.36 + {
3.37 + ADD_STATE(State_EatYams_Handler_Called);
3.38 + }
3.39 +
3.40 + IGaben *g_Gabgab;
3.41 +}
3.42 +
3.43 +extern void *___testbail_gabgab;
3.44 \ No newline at end of file
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/sourcehook/test/testbail2.cpp Fri May 27 21:39:30 2005 +0000
4.3 @@ -0,0 +1,23 @@
4.4 +// TESTBAIL
4.5 +// Different compilation unit
4.6 +
4.7 +#include "testbail.h"
4.8 +
4.9 +void ___TestBail2()
4.10 +{
4.11 + SourceHook::CSourceHookImpl g_SHImpl;
4.12 + g_SHPtr = &g_SHImpl;
4.13 + g_PLID = 2;
4.14 +
4.15 + g_Gabgab = (IGaben*)___testbail_gabgab;
4.16 +
4.17 + g_Gabgab->EatYams();
4.18 +
4.19 + SH_ADD_HOOK_STATICFUNC(IGaben, EatYams, g_Gabgab, EatYams0_Handler, false);
4.20 +
4.21 + g_Gabgab->EatYams();
4.22 +
4.23 + SH_REMOVE_HOOK_STATICFUNC(IGaben, EatYams, g_Gabgab, EatYams0_Handler, false);
4.24 +
4.25 + g_Gabgab->EatYams();
4.26 +}
4.27 \ No newline at end of file