Skip to content

Commit 481aab9

Browse files
committed
test(runner): add tests for issue #130 and #131
keep leading whitespaces for strings on the stack
1 parent 59dce04 commit 481aab9

3 files changed

Lines changed: 34 additions & 0 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ repos:
1818
- id: end-of-file-fixer
1919
- id: fix-byte-order-marker
2020
- id: trailing-whitespace
21+
exclude: .ink$
2122
- repo: https://github.com/pre-commit/pygrep-hooks
2223
rev: v1.10.0 # Use the ref you want to point at
2324
hooks:

inkcpp_test/Fixes.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,28 @@ SCENARIO("snapshot failed inside execution _ #111", "[fixes]")
101101
}
102102
}
103103
}
104+
105+
SCENARIO("missing leading whitespace inside choice-only text and glued text _ #130 #131", "[fixes]")
106+
{
107+
GIVEN("story with problematic text")
108+
{
109+
auto ink = story::from_file(INK_TEST_RESOURCE_DIR "130_131_missing_whitespace.bin");
110+
runner thread = ink->new_runner();
111+
WHEN("run story")
112+
{
113+
auto line = thread->getline();
114+
THEN("expect spaces in glued text") { REQUIRE(line == "Glue with no gaps.\n"); }
115+
THEN("choice contains space")
116+
{
117+
REQUIRE(thread->num_choices() == 1);
118+
REQUIRE(std::string(thread->get_choice(0)->text()) == "Look around");
119+
}
120+
thread->choose(0);
121+
line = thread->getall();
122+
THEN("no space in post choice text")
123+
{
124+
REQUIRE(line == "Looking around the saloon, you don't find much.");
125+
}
126+
}
127+
}
128+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
~temp test = true
2+
Glue <>
3+
{
4+
- test: with
5+
} <> {
6+
- test: no
7+
} <> gaps.
8+
+ Look[ around]ing around the saloon, you don't find much.->DONE

0 commit comments

Comments
 (0)