Repository navigation
Expand file tree
/
Copy pathEmptyStringForDivert.cpp
More file actions
60 lines (51 loc) · 1.48 KB
/
Copy pathEmptyStringForDivert.cpp
File metadata and controls
60 lines (51 loc) · 1.48 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 <story.h>
#include <globals.h>
#include <runner.h>
#include <compiler.h>
using namespace ink::runtime;
SCENARIO(
"a story with a white space infront of an conditional Divert", "[output][regression][runtime]"
)
{
// based on https://github.com/JBenda/inkcpp/issues/71
GIVEN("a story with a conditional divert")
{
std::unique_ptr<story> ink{story::from_file(INK_TEST_RESOURCE_DIR "EmptyStringForDivert.bin")};
runner thread = ink->new_runner();
WHEN("the story starts and the first choice is made")
{
thread->getall();
REQUIRE(thread->has_choices()); // guard
thread->choose(0);
std::string line = thread->getall();
THEN("'This displays first' is printed and another choice is offered")
{
REQUIRE(line == "This displays first\n");
REQUIRE(thread->has_choices());
}
AND_WHEN("the second choice is made")
{
REQUIRE(thread->has_choices()); // guard
thread->choose(0);
std::string line2 = thread->getall();
THEN("the continuation text is printed and another choice is offered")
{
REQUIRE(line2 == "This is the continuation.\n");
REQUIRE(thread->has_choices());
}
AND_WHEN("the third choice is made")
{
REQUIRE(thread->has_choices()); // guard
thread->choose(0);
std::string line3 = thread->getall();
THEN("empty output is produced and the story ends")
{
REQUIRE(line3 == "");
REQUIRE_FALSE(thread->has_choices());
}
}
}
}
}
}