1
0
mirror of https://github.com/alliedmodders/metamod-source.git synced 2025-01-18 07:52:32 +01:00

Added TestBail

--HG--
extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%4076
This commit is contained in:
Pavol Marko 2005-05-27 21:39:30 +00:00
parent a3fe9b64de
commit 1c1b3953a3
4 changed files with 101 additions and 0 deletions

View File

@ -63,6 +63,7 @@ DO_TEST(Basic);
DO_TEST(VafmtAndOverload);
DO_TEST(ThisPtrOffs);
DO_TEST(PlugSys);
DO_TEST(Bail);
int main(int argc, char *argv[])
{

View File

@ -0,0 +1,37 @@
// TESTBAIL
// Test for a bug Bail has found
#include "testbail.h"
void *___testbail_gabgab;
bool TestBail(std::string &error)
{
SourceHook::CSourceHookImpl g_SHImpl;
g_SHPtr = &g_SHImpl;
g_PLID = 1;
g_Gabgab = new IGaben;
___testbail_gabgab = (void*)g_Gabgab;
g_Gabgab->EatYams();
SH_ADD_HOOK_STATICFUNC(IGaben, EatYams, g_Gabgab, EatYams0_Handler, false);
g_Gabgab->EatYams();
___TestBail2();
g_Gabgab->EatYams();
SH_REMOVE_HOOK_STATICFUNC(IGaben, EatYams, g_Gabgab, EatYams0_Handler, false);
g_Gabgab->EatYams();
delete g_Gabgab;
// If it didn't crash, it's ok
return true;
}

View File

@ -0,0 +1,40 @@
//////////////////////////////////////////////////////////////////////////
// Shared data for testbail
#include <string>
#include "sourcehook_impl.h"
#include "testevents.h"
#include <stdarg.h>
void ___TestBail2();
namespace
{
StateList g_States;
SourceHook::ISourceHook *g_SHPtr;
SourceHook::Plugin g_PLID;
MAKE_STATE(State_EatYams_Called);
MAKE_STATE(State_EatYams_Handler_Called);
class IGaben
{
public:
virtual void EatYams()
{
ADD_STATE(State_EatYams_Called);
}
};
SH_DECL_HOOK0_void(IGaben, EatYams, SH_NOATTRIB, 0);
void EatYams0_Handler()
{
ADD_STATE(State_EatYams_Handler_Called);
}
IGaben *g_Gabgab;
}
extern void *___testbail_gabgab;

View File

@ -0,0 +1,23 @@
// TESTBAIL
// Different compilation unit
#include "testbail.h"
void ___TestBail2()
{
SourceHook::CSourceHookImpl g_SHImpl;
g_SHPtr = &g_SHImpl;
g_PLID = 2;
g_Gabgab = (IGaben*)___testbail_gabgab;
g_Gabgab->EatYams();
SH_ADD_HOOK_STATICFUNC(IGaben, EatYams, g_Gabgab, EatYams0_Handler, false);
g_Gabgab->EatYams();
SH_REMOVE_HOOK_STATICFUNC(IGaben, EatYams, g_Gabgab, EatYams0_Handler, false);
g_Gabgab->EatYams();
}