MCPcopy Create free account
hub / github.com/davisking/dlib / test_constructors

Function test_constructors

dlib/test/optional.cpp:340–388  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

338 };
339
340 void test_constructors()
341 {
342 dlib::optional<optional_dummy> val;
343 DLIB_TEST(constructor_count == 0);
344 DLIB_TEST(copy_constructor_count == 0);
345 DLIB_TEST(move_constructor_count == 0);
346 DLIB_TEST(copy_assign_count == 0);
347 DLIB_TEST(move_assign_count == 0);
348
349 val = optional_dummy{};
350 DLIB_TEST(constructor_count == 1);
351 DLIB_TEST(copy_constructor_count == 0);
352 DLIB_TEST(move_constructor_count == 1);
353 DLIB_TEST(copy_assign_count == 0);
354 DLIB_TEST(move_assign_count == 0);
355 reset_counters();
356
357 dlib::optional<optional_dummy> val2{val};
358 DLIB_TEST(constructor_count == 0);
359 DLIB_TEST(copy_constructor_count == 1);
360 DLIB_TEST(move_constructor_count == 0);
361 DLIB_TEST(copy_assign_count == 0);
362 DLIB_TEST(move_assign_count == 0);
363 reset_counters();
364
365 dlib::optional<optional_dummy> val3{std::move(val)};
366 DLIB_TEST(constructor_count == 0);
367 DLIB_TEST(copy_constructor_count == 0);
368 DLIB_TEST(move_constructor_count == 1);
369 DLIB_TEST(copy_assign_count == 0);
370 DLIB_TEST(move_assign_count == 0);
371 reset_counters();
372
373 val2 = val;
374 DLIB_TEST(constructor_count == 0);
375 DLIB_TEST(copy_constructor_count == 0);
376 DLIB_TEST(move_constructor_count == 0);
377 DLIB_TEST(copy_assign_count == 1);
378 DLIB_TEST(move_assign_count == 0);
379 reset_counters();
380
381 val3 = std::move(val);
382 DLIB_TEST(constructor_count == 0);
383 DLIB_TEST(copy_constructor_count == 0);
384 DLIB_TEST(move_constructor_count == 0);
385 DLIB_TEST(copy_assign_count == 0);
386 DLIB_TEST(move_assign_count == 1);
387 reset_counters();
388 }
389
390// ---------------------------------------------------------------------------------------------------
391

Callers 1

perform_testMethod · 0.85

Calls 2

reset_countersFunction · 0.85
moveFunction · 0.85

Tested by

no test coverage detected