]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/operator-new.dtest/main.cxx
dyld-551.4.tar.gz
[apple/dyld.git] / testing / test-cases / operator-new.dtest / main.cxx
1
2 // BUILD: $CXX main.cxx -o $BUILD_DIR/operator-new.exe
3
4 // RUN: ./operator-new.exe
5
6 #include <stdio.h>
7 #include <new>
8
9
10
11 //
12 // This test case verifies that calling operator new[] in libstdc++.dylib
13 // will turn around and call operator new in this main exectuable
14 //
15
16 static void* ptr;
17
18 void* operator new(size_t s) throw (std::bad_alloc)
19 {
20 ptr = malloc(s);
21 return ptr;
22 }
23
24 int main()
25 {
26 printf("[BEGIN] operator-new\n");
27
28 char* stuff = new char[24];
29 if ( (void*)stuff == ptr )
30 printf("[PASS] operator-new\n");
31 else
32 printf("[FAIL] operator-new\n");
33
34 return 0;
35 }
36
37