MCPcopy Create free account
hub / github.com/Kitware/VTK / ExerciseDelete

Function ExerciseDelete

Common/Core/Testing/Cxx/TestArrayFreeFunctions.cxx:139–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137//------------------------------------------------------------------------------
138template <typename FreeType>
139int ExerciseDelete(FreeType f)
140{
141 int errors = 0;
142
143 std::cout << "Starting tests for free type: " << f.value << std::endl;
144
145 std::vector<vtkAbstractArray*> arrays;
146 arrays.push_back(vtkStringArray::New());
147 arrays.push_back(vtkBitArray::New());
148 arrays.push_back(vtkFloatArray::New());
149 arrays.push_back(vtkAOSDataArrayTemplate<double>::New());
150 arrays.push_back(vtkSOADataArrayTemplate<double>::New());
151 arrays.push_back(vtkScaledSOADataArrayTemplate<double>::New());
152 constexpr std::size_t size = 5000;
153 for (auto it = arrays.begin(); it != arrays.end(); ++it)
154 {
155
156 vtkAbstractArray* array = *it;
157
158 // test setting the array's memory and having it not free the memory
159 void* ptr = make_allocation(f, size, array->GetDataType());
160 errors += assign_void_array(f, array, ptr, size, false);
161
162 // ask array to free memory, ptr should still be valid
163 array->Initialize();
164
165 // This time ask the array to free the memory
166 errors += assign_void_array(f, array, ptr, size, true);
167
168 // if we are a lambda we need to set the real free function
169 assign_user_free(f, array);
170
171 // free the memory for real this time
172 array->Initialize();
173 }
174
175 for (auto it = arrays.begin(); it != arrays.end(); ++it)
176 {
177 vtkAbstractArray* array = *it;
178 array->Delete();
179 }
180
181 return errors;
182}
183
184} // end anon namespace
185

Callers 1

TestArrayFreeFunctionsFunction · 0.85

Calls 10

make_allocationFunction · 0.85
assign_void_arrayFunction · 0.85
assign_user_freeFunction · 0.85
NewFunction · 0.70
DeleteMethod · 0.65
push_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
GetDataTypeMethod · 0.45
InitializeMethod · 0.45

Tested by

no test coverage detected