Skip to content

Commit 4498524

Browse files
committed
Add more tests for Callable
1 parent 6c91528 commit 4498524

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/callable_tests.cc

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,36 @@ TEST_CASE("CallableSized") {
103103
func();
104104
CHECK(capture3 == 20);
105105
}
106+
107+
TEST_CASE("~Callable") {
108+
auto capture{0};
109+
110+
Callback *func = new Callback{[&capture] {
111+
capture += 10;
112+
return capture;
113+
}};
114+
115+
(*func)();
116+
CHECK(capture == 10);
117+
(*func)();
118+
CHECK(capture == 20);
119+
120+
delete func;
121+
122+
Callback *empty = new Callback();
123+
delete empty;
124+
}
125+
126+
TEST_CASE("operator bool") {
127+
auto capture{0};
128+
129+
Callback func;
130+
CHECK_FALSE((bool)func);
131+
132+
func = Callback{[&capture] {
133+
capture += 10;
134+
return capture;
135+
}};
136+
137+
CHECK((bool)func);
138+
}

0 commit comments

Comments
 (0)