Nektar++
Functions
Nektar::MemManagerUnitTests Namespace Reference

Functions

 BOOST_AUTO_TEST_CASE (testParameterizedConstructors)
 
 BOOST_AUTO_TEST_CASE (testSmartPointerAllocation)
 
 BOOST_AUTO_TEST_CASE (ReproduceMemoryErrors)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/3]

Nektar::MemManagerUnitTests::BOOST_AUTO_TEST_CASE ( ReproduceMemoryErrors  )

Definition at line 156 of file TestNekMemoryManager.cpp.

157{
158 std::shared_ptr<int> m = MemoryManager<int>::AllocateSharedPtr();
159 std::shared_ptr<int> m1 = MemoryManager<int>::AllocateSharedPtr();
161}
General purpose memory allocation routines with the ability to allocate from thread specific memory p...

References Nektar::MemoryManager< DataType >::AllocateSharedPtr().

◆ BOOST_AUTO_TEST_CASE() [2/3]

Nektar::MemManagerUnitTests::BOOST_AUTO_TEST_CASE ( testParameterizedConstructors  )

Definition at line 45 of file TestNekMemoryManager.cpp.

46{
48
54
55 unsigned int one = 1;
61
62 unsigned int two = 2;
64 MemoryManager<CountedObject<int>>::Allocate(one, two);
69
70 unsigned int three = 3;
72 MemoryManager<CountedObject<int>>::Allocate(one, two, three);
77 BOOST_CHECK_EQUAL(ob4->value, 6u);
78
79 MemoryManager<CountedObject<int>>::Deallocate(ob1);
80 MemoryManager<CountedObject<int>>::Deallocate(ob2);
81 MemoryManager<CountedObject<int>>::Deallocate(ob3);
82 MemoryManager<CountedObject<int>>::Deallocate(ob4);
83
84 BOOST_CHECK(ob1 == NULL);
85 BOOST_CHECK(ob2 == NULL);
86 BOOST_CHECK(ob3 == NULL);
87 BOOST_CHECK(ob4 == NULL);
88
93 BOOST_CHECK_EQUAL(CountedObject<int>::numberDestroyed, 4u);
94}

References Nektar::CountedObject< DerivedType >::ClearCounters(), and Nektar::CountedObject< DerivedType >::value.

◆ BOOST_AUTO_TEST_CASE() [3/3]

Nektar::MemManagerUnitTests::BOOST_AUTO_TEST_CASE ( testSmartPointerAllocation  )

Definition at line 96 of file TestNekMemoryManager.cpp.

97{
99
100 {
101 std::shared_ptr<CountedObject<int>> ob1 =
102 MemoryManager<CountedObject<int>>::AllocateSharedPtr();
105 0u);
107 0u);
109 0u);
110
111 int one = 1;
112 std::shared_ptr<CountedObject<int>> ob2 =
113 MemoryManager<CountedObject<int>>::AllocateSharedPtr(one);
116 1u);
118 0u);
120 0u);
121
122 int two = 2;
123 std::shared_ptr<CountedObject<int>> ob3 =
124 MemoryManager<CountedObject<int>>::AllocateSharedPtr(one, two);
127 1u);
129 1u);
131 0u);
132
133 int three = 3;
134 std::shared_ptr<CountedObject<int>> ob4 =
135 MemoryManager<CountedObject<int>>::AllocateSharedPtr(one, two,
136 three);
139 1u);
141 1u);
143 1u);
144 BOOST_CHECK_EQUAL(ob4->value, 6u);
145 BOOST_CHECK_EQUAL(CountedObject<int>::numberDestroyed, 0u);
146 }
147
148 BOOST_CHECK_EQUAL(CountedObject<int>::numberDestroyed, 4u);
153 BOOST_CHECK_EQUAL(CountedObject<int>::numberDestroyed, 4u);
154}

References Nektar::CountedObject< DerivedType >::ClearCounters().