File tree Expand file tree Collapse file tree 1 file changed +32
-6
lines changed Expand file tree Collapse file tree 1 file changed +32
-6
lines changed Original file line number Diff line number Diff line ch
10000
ange 3
3
4
4
using namespace datalog ;
5
5
6
- bool freeVariableTest () {
6
+ bool freeVariableTest ()
7
+ {
7
8
Variable<int > intVar;
8
9
return !intVar.isBound ();
9
10
}
10
11
11
- bool boundVariableTest () {
12
+ bool boundVariableTest ()
13
+ {
12
14
Variable<int > intVar;
13
15
intVar.bind (0 );
14
16
return intVar.isBound ();
15
17
}
16
18
17
- TEST_CASE ( " An new variable is unbound" , " [variable]" ) {
18
- REQUIRE ( freeVariableTest () == true );
19
+ bool bindUnbindTest ()
20
+ {
21
+ Variable<int > intVar;
22
+ intVar.bind (0 );
23
+ intVar.unbind ();
24
+ return !intVar.isBound ();
25
+ }
26
+
27
+ bool storesValueTest ()
28
+ {
29
+ Variable<int > intVar;
30
+ const int value = 100 ;
31
+ intVar.bind (value);
32
+ return intVar.isBound () and intVar.value () == value;
33
+ }
34
+
35
+ bool absentValueTest ()
36
+ {
37
+ Variable<int > intVar;
38
+ const auto &val = intVar.value ();
39
+ return true ;
19
40
}
20
41
21
- TEST_CASE ( " A variable with a value is bound" , " [variable]" ) {
22
- REQUIRE ( boundVariableTest () == true );
42
+ TEST_CASE (" variable binding" , " [variable]" )
43
+ {
44
+ REQUIRE (freeVariableTest ());
45
+ REQUIRE (boundVariableTest ());
46
+ REQUIRE (bindUnbindTest ());
47
+ REQUIRE (bindUnbindTest ());
48
+ REQUIRE_THROWS_AS (absentValueTest (), std::bad_optional_access);
23
49
}
You can’t perform that action at this time.
0 commit comments