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

Function test_scope_exit_erased

dlib/test/scope.cpp:67–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65
66
67 void test_scope_exit_erased()
68 {
69 int counter{0};
70
71 {
72 scope_exit_erased s1([&]{++counter;});
73 static_assert(!std::is_copy_constructible<decltype(s1)>::value, "bad");
74 static_assert(!std::is_copy_assignable<decltype(s1)>::value, "bad");
75 static_assert(!std::is_move_assignable<decltype(s1)>::value, "bad");
76 static_assert(std::is_move_constructible<decltype(s1)>::value, "bad");
77 auto s2 = std::move(s1);
78 auto s3 = std::move(s2);
79 auto s4 = std::move(s3);
80 }
81
82 DLIB_TEST(counter == 1);
83
84 const auto fn_inner = [&]
85 {
86 scope_exit_erased s([&]{++counter;});
87 return s;
88 };
89
90 const auto fn_outer = [&]
91 {
92 auto s = fn_inner();
93 return s;
94 };
95
96 {
97 auto s = fn_outer();
98 }
99
100 DLIB_TEST(counter == 2);
101 }
102
103 struct results_with_delayed_C_library_resource_management
104 {

Callers 1

perform_testMethod · 0.85

Calls 1

moveFunction · 0.85

Tested by

no test coverage detected