Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit152a1e8

Browse files
committed
complete the tests
1 parentf452d48 commit152a1e8

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

‎tests/variable_test.cpp‎

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,47 @@
33

44
usingnamespacedatalog;
55

6-
boolfreeVariableTest() {
6+
boolfreeVariableTest()
7+
{
78
Variable<int> intVar;
89
return !intVar.isBound();
910
}
1011

11-
boolboundVariableTest() {
12+
boolboundVariableTest()
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+
boolbindUnbindTest()
20+
{
21+
Variable<int> intVar;
22+
intVar.bind(0);
23+
intVar.unbind();
24+
return !intVar.isBound();
25+
}
26+
27+
boolstoresValueTest()
28+
{
29+
Variable<int> intVar;
30+
constint value =100;
31+
intVar.bind(value);
32+
return intVar.isBound()and intVar.value() == value;
33+
}
34+
35+
boolabsentValueTest()
36+
{
37+
Variable<int> intVar;
38+
constauto &val = intVar.value();
39+
returntrue;
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
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp