ReactOS 0.4.15-dev-8241-g63935f8
AllocatorTest Class Reference
Inheritance diagram for AllocatorTest:
Collaboration diagram for AllocatorTest:

Protected Member Functions

void zero_allocation ()
 
void bad_alloc_test ()
 
void per_thread_alloc ()
 

Private Member Functions

 CPPUNIT_TEST_SUITE (AllocatorTest)
 
 CPPUNIT_TEST (zero_allocation)
 
 CPPUNIT_TEST (bad_alloc_test)
 
 CPPUNIT_TEST_SUITE_END ()
 

Detailed Description

Definition at line 15 of file allocator_test.cpp.

Member Function Documentation

◆ bad_alloc_test()

void AllocatorTest::bad_alloc_test ( )
protected

Definition at line 56 of file allocator_test.cpp.

57{
58 typedef allocator<BigStruct> BigStructAllocType;
59 BigStructAllocType bigStructAlloc;
60
61 try {
62 //Lets try to allocate almost 4096 Go (on most of the platforms) of memory:
63 BigStructAllocType::pointer pbigStruct = bigStructAlloc.allocate(1024 * 1024 * 1024);
64
65 //Allocation failed but no exception thrown
66 CPPUNIT_ASSERT( pbigStruct != 0 );
67
68 // Just it case it succeeds:
69 bigStructAlloc.deallocate(pbigStruct, 1024 * 1024 * 1024);
70 }
71 catch (bad_alloc const&) {
72 }
73 catch (...) {
74 //We shouldn't be there:
75 //Not bad_alloc exception thrown.
77 }
78}
_Tp * allocate(size_type __n, const void *=0)
Definition: _alloc.h:301
#define CPPUNIT_FAIL
Definition: cppunit_mini.h:206
#define CPPUNIT_ASSERT(X)
Definition: cppunit_mini.h:200

◆ CPPUNIT_TEST() [1/2]

AllocatorTest::CPPUNIT_TEST ( bad_alloc_test  )
private

◆ CPPUNIT_TEST() [2/2]

AllocatorTest::CPPUNIT_TEST ( zero_allocation  )
private

◆ CPPUNIT_TEST_SUITE()

AllocatorTest::CPPUNIT_TEST_SUITE ( AllocatorTest  )
private

◆ CPPUNIT_TEST_SUITE_END()

AllocatorTest::CPPUNIT_TEST_SUITE_END ( )
private

◆ per_thread_alloc()

void AllocatorTest::per_thread_alloc ( )
protected

◆ zero_allocation()

void AllocatorTest::zero_allocation ( )
protected

Definition at line 38 of file allocator_test.cpp.

39{
40 typedef allocator<char> CharAllocator;
41 CharAllocator charAllocator;
42
43 char* buf = charAllocator.allocate(0);
44 charAllocator.deallocate(buf, 0);
45
46 charAllocator.deallocate(0, 0);
47}
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751

The documentation for this class was generated from the following file: