- if ( (void*)stuff == ptr )
- printf("[PASS] operator-new\n");
- else
- printf("[FAIL] operator-new\n");
+ if ( (void*)stuff != myLastNewAllocation ) {
+ printf("[FAIL] operator-new system array allocator not redirected through my operator new\n");
+ return 0;
+ }
+
+ // test that program uses my operator new
+ myLastNewAllocation = NULL;
+ Foo* foo = new Foo();
+ if ( (void*)foo != myLastNewAllocation ) {
+ printf("[FAIL] operator-new allocation not redirected though my operator new\n");
+ return 0;
+ }
+
+ //
+ delete foo;
+ if ( (void*)foo != myLastDelete ) {
+ printf("[FAIL] operator-new deallocation not redirected though my operator delete\n");
+ return 0;
+ }