-
-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathExternalFunctionTypes.cpp
More file actions
48 lines (40 loc) · 1.28 KB
/
ExternalFunctionTypes.cpp
File metadata and controls
48 lines (40 loc) · 1.28 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
#include "catch.hpp"
#include <../runner_impl.h>
#include <story.h>
#include <globals.h>
#include <runner.h>
#include <compiler.h>
using namespace ink::runtime;
SCENARIO("a story with external functions support types", "[story]")
{
GIVEN("a story with external functions")
{
auto ink = story::from_file(INK_TEST_RESOURCE_DIR "ExternalFunctionTypes.bin");
auto thread = ink->new_runner().cast<internal::runner_impl>();
std::stringstream debug;
thread->set_debug_enabled(&debug);
bool b = false;
int i = 0;
unsigned int u = 0;
float f = 0;
std::string s;
thread->bind("SET_BOOL", [&b](bool o) { b = o; });
thread->bind("SET_INT", [&i](int o) { i = o; });
thread->bind("SET_UINT", [&u](unsigned int o) { u = o; });
thread->bind("SET_FLOAT", [&f](float o) { f = o; });
thread->bind("SET_STRING", [&s](std::string o) { s = o; });
thread->bind("GET_BOOL", [&b]() { return b; });
thread->bind("GET_INT", [&i]() { return i; });
thread->bind("GET_UINT", [&u]() { return u; });
thread->bind("GET_FLOAT", [&f]() { return f; });
thread->bind("GET_STRING", [&s]() { return s; });
WHEN("run thread")
{
THEN("output shows values from ink")
{
auto line = thread->getline();
REQUIRE(line == "true 1.5 -5 17 foo\n");
}
}
}
}