sourcehook/test/testvphooks.cpp
changeset 333 3813f1ac0cfe
parent 328 3a04ef79edf1
child 380 f9e21a2ac558
     1.1 --- a/sourcehook/test/testvphooks.cpp	Sat May 12 19:05:16 2007 +0000
     1.2 +++ b/sourcehook/test/testvphooks.cpp	Sat May 12 19:48:31 2007 +0000
     1.3 @@ -322,12 +322,26 @@
     1.4  
     1.5  
     1.6  	// Test removing normal hooks even though the instance is deleted
     1.7 -	p_d1i1 = new CDerived1;
     1.8 +	IBase *pOther = new CDerived1;
     1.9 +	SH_ADD_HOOK(IBase, Func1, pOther, SH_STATIC(Handler_Func1_Pre), false);
    1.10 +	delete pOther;
    1.11 +	// The following line may not crash!
    1.12 +	SH_REMOVE_HOOK(IBase, Func1, pOther, SH_STATIC(Handler_Func1_Pre), false);
    1.13 +
    1.14 +
    1.15 +	// Now test GetOrigVfnPtrEntry
    1.16 +	void *origfuncptr = (*reinterpret_cast<void***>(p_d1i1))[0];
    1.17 +
    1.18 +	CHECK_COND(SH_GET_ORIG_VFNPTR_ENTRY(p_d1i1, &IBase::Func1) == origfuncptr, "Part 9.1");
    1.19 +		
    1.20  	SH_ADD_HOOK(IBase, Func1, p_d1i1, SH_STATIC(Handler_Func1_Pre), false);
    1.21 -	delete p_d1i1;
    1.22 -	// The following line may not crash!
    1.23 +	
    1.24 +	CHECK_COND(SH_GET_ORIG_VFNPTR_ENTRY(p_d1i1, &IBase::Func1) == origfuncptr, "Part 9.2");
    1.25 +
    1.26  	SH_REMOVE_HOOK(IBase, Func1, p_d1i1, SH_STATIC(Handler_Func1_Pre), false);
    1.27  
    1.28 +	CHECK_COND(SH_GET_ORIG_VFNPTR_ENTRY(p_d1i1, &IBase::Func1) == origfuncptr, "Part 9.3");
    1.29 +
    1.30  	return true;
    1.31  }
    1.32