Skip to content

Commit 18fd4d4

Browse files
committed
Add callable test
1 parent 2f2ba14 commit 18fd4d4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/callable_tests.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include "doctest.h"
2+
#include "util/callable.hh"
3+
4+
TEST_CASE("Callable Function") {
5+
auto capture{0};
6+
auto func = Function<int(int, int)>{[&capture](int a, int b) {
7+
capture += 10;
8+
return a + b + capture;
9+
}};
10+
11+
CHECK(func(10, 10) == 30);
12+
CHECK(capture == 10);
13+
CHECK(func(10, 10) == 40);
14+
CHECK(capture == 20);
15+
}

0 commit comments

Comments
 (0)