MCPcopy Create free account
hub / github.com/ceres-solver/ceres-solver / TestArray

Function TestArray

internal/ceres/fixed_array_test.cc:239–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

237
238template <int stack_elements>
239static void TestArray(int n) {
240 SCOPED_TRACE(n);
241 SCOPED_TRACE(stack_elements);
242 ConstructionTester::constructions = 0;
243 ConstructionTester::destructions = 0;
244 {
245 ceres::internal::FixedArray<ConstructionTester, stack_elements> array(n);
246
247 EXPECT_THAT(array.size(), n);
248 EXPECT_THAT(array.memsize(), sizeof(ConstructionTester) * n);
249 EXPECT_THAT(array.begin() + n, array.end());
250
251 // Check that all elements were constructed
252 for (int i = 0; i < n; i++) {
253 array[i].CheckConstructed();
254 }
255 // Check that no other elements were constructed
256 EXPECT_THAT(ConstructionTester::constructions, n);
257
258 // Test operator[]
259 for (int i = 0; i < n; i++) {
260 array[i].set(i);
261 }
262 for (int i = 0; i < n; i++) {
263 EXPECT_THAT(array[i].get(), i);
264 EXPECT_THAT(array.data()[i].get(), i);
265 }
266
267 // Test data()
268 for (int i = 0; i < n; i++) {
269 array.data()[i].set(i + 1);
270 }
271 for (int i = 0; i < n; i++) {
272 EXPECT_THAT(array[i].get(), i + 1);
273 EXPECT_THAT(array.data()[i].get(), i + 1);
274 }
275 } // Close scope containing 'array'.
276
277 // Check that all constructed elements were destructed.
278 EXPECT_EQ(ConstructionTester::constructions,
279 ConstructionTester::destructions);
280}
281
282template <int elements_per_inner_array, int inline_elements>
283static void TestArrayOfArrays(int n) {

Callers

nothing calls this directly

Calls 8

memsizeMethod · 0.80
CheckConstructedMethod · 0.80
getMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
setMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected