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 change 33
44using namespace datalog ;
55
6- bool freeVariableTest () {
6+ bool freeVariableTest ()
7+ {
78 Variable<int > intVar;
89 return !intVar.isBound ();
910}
1011
11- bool boundVariableTest () {
12+ bool boundVariableTest ()
13+ {
1214 Variable<int > intVar;
1315 intVar.bind (0 );
1416 return intVar.isBound ();
1517}
1618
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 ;
1940}
2041
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);
2349}
You can’t perform that action at this time.
0 commit comments