Ticket #2520: NewOperatorTest.cpp

File NewOperatorTest.cpp, 1.3 KB (added by Runar Undheim <R.Undheim@…>, 14 years ago)
Line 
1#define BOOST_TEST_MODULE Serialization
2
3#include <boost/archive/detail/iserializer.hpp>
4#include <boost/test/test_tools.hpp>
5#include <boost/test/included/unit_test.hpp>
6
7using namespace boost::archive::detail;
8
9class WithOverLoadedNewOperator
10{
11public:
12
13 void *operator new(
14 size_t size
15 )
16 {
17 return ::operator new(size);
18 }
19
20 void *operator new(
21 size_t size,
22 void *pBase
23 )
24 {
25 return pBase;
26 }
27
28 void operator delete(
29 void *p
30 )
31 {
32 ::operator delete(p);
33 }
34
35 void operator delete(
36 void *p,
37 void *pBase
38 )
39 {
40 }
41};
42
43class WithoutOverLoadedNewOperator
44{
45};
46
47BOOST_AUTO_TEST_SUITE(Serialization)
48
49BOOST_AUTO_TEST_CASE(HeapAllocatorOperatorNewOverloadTest)
50{
51 BOOST_WARN(sizeof(*heap_allocator<WithOverLoadedNewOperator>::hasNewOperator<WithOverLoadedNewOperator>(static_cast<WithOverLoadedNewOperator *>(NULL))) == sizeof(heap_allocator<WithoutOverLoadedNewOperator>::True));
52 BOOST_REQUIRE(sizeof(*heap_allocator<WithoutOverLoadedNewOperator>::hasNewOperator<WithoutOverLoadedNewOperator>(static_cast<WithoutOverLoadedNewOperator *>(NULL))) == sizeof(heap_allocator<WithoutOverLoadedNewOperator>::False));
53}
54
55BOOST_AUTO_TEST_SUITE_END()