-
-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathLabelCondition.cpp
More file actions
60 lines (53 loc) · 1.63 KB
/
LabelCondition.cpp
File metadata and controls
60 lines (53 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "catch.hpp"
#include <choice.h>
#include <compiler.h>
#include <globals.h>
#include <runner.h>
#include <story.h>
using namespace ink::runtime;
SCENARIO("run story with hidden choice")
{
GIVEN("a story with choice visible by second visit")
{
std::unique_ptr<story> ink{story::from_file(INK_TEST_RESOURCE_DIR "LabelConditionStory.bin")};
globals globals = ink->new_globals();
runner thread = ink->new_runner(globals);
WHEN("normal run")
{
std::string out = thread->getall();
REQUIRE(thread->num_choices() == 1);
std::string choice1a = thread->get_choice(0)->text();
thread->choose(0);
std::string out2 = thread->getall();
REQUIRE(thread->num_choices() == 1);
std::string choice2a = thread->get_choice(0)->text();
THEN("second choice keeps hidden")
{
REQUIRE(out == "");
REQUIRE(choice1a == "labeled choice");
REQUIRE(out2 == "");
REQUIRE(choice2a == "labeled choice");
}
}
WHEN("set global variable to enable hidden choice")
{
globals->set<bool>("bool_variable", false);
std::string out = thread->getall();
REQUIRE(thread->num_choices() == 1);
std::string choice1a = thread->get_choice(0)->text();
thread->choose(0);
std::string out2 = thread->getall();
REQUIRE(thread->num_choices() == 2);
std::string choice2a = thread->get_choice(0)->text();
std::string choice2b = thread->get_choice(1)->text();
THEN("second choice is visible")
{
REQUIRE(out == "");
REQUIRE(choice1a == "labeled choice");
REQUIRE(out2 == "");
REQUIRE(choice2a == "labeled choice");
REQUIRE(choice2b == "hidden choice");
}
}
}
}