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 154 of file TestNekMemoryManager.cpp.

155{
156 std::shared_ptr<int> m = MemoryManager<int>::AllocateSharedPtr();
157 std::shared_ptr<int> m1 = MemoryManager<int>::AllocateSharedPtr();
159}
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 43 of file TestNekMemoryManager.cpp.

44{
46
52
53 unsigned int one = 1;
59
60 unsigned int two = 2;
62 MemoryManager<CountedObject<int>>::Allocate(one, two);
67
68 unsigned int three = 3;
70 MemoryManager<CountedObject<int>>::Allocate(one, two, three);
75 BOOST_CHECK_EQUAL(ob4->value, 6u);
76
77 MemoryManager<CountedObject<int>>::Deallocate(ob1);
78 MemoryManager<CountedObject<int>>::Deallocate(ob2);
79 MemoryManager<CountedObject<int>>::Deallocate(ob3);
80 MemoryManager<CountedObject<int>>::Deallocate(ob4);
81
82 BOOST_CHECK(ob1 == nullptr);
83 BOOST_CHECK(ob2 == nullptr);
84 BOOST_CHECK(ob3 == nullptr);
85 BOOST_CHECK(ob4 == nullptr);
86
91 BOOST_CHECK_EQUAL(CountedObject<int>::numberDestroyed, 4u);
92}

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 94 of file TestNekMemoryManager.cpp.

95{
97
98 {
99 std::shared_ptr<CountedObject<int>> ob1 =
100 MemoryManager<CountedObject<int>>::AllocateSharedPtr();
103 0u);
105 0u);
107 0u);
108
109 int one = 1;
110 std::shared_ptr<CountedObject<int>> ob2 =
111 MemoryManager<CountedObject<int>>::AllocateSharedPtr(one);
114 1u);
116 0u);
118 0u);
119
120 int two = 2;
121 std::shared_ptr<CountedObject<int>> ob3 =
122 MemoryManager<CountedObject<int>>::AllocateSharedPtr(one, two);
125 1u);
127 1u);
129 0u);
130
131 int three = 3;
132 std::shared_ptr<CountedObject<int>> ob4 =
133 MemoryManager<CountedObject<int>>::AllocateSharedPtr(one, two,
134 three);
137 1u);
139 1u);
141 1u);
142 BOOST_CHECK_EQUAL(ob4->value, 6u);
143 BOOST_CHECK_EQUAL(CountedObject<int>::numberDestroyed, 0u);
144 }
145
146 BOOST_CHECK_EQUAL(CountedObject<int>::numberDestroyed, 4u);
151 BOOST_CHECK_EQUAL(CountedObject<int>::numberDestroyed, 4u);
152}

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