forked from ynoproject/ynoengine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame_destiny.cpp
62 lines (45 loc) · 1.14 KB
/
game_destiny.cpp
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
61
62
#include "doctest.h"
#include "game_destiny.h"
#include <vector>
TEST_SUITE_BEGIN("Game_Destiny");
static lcf::rpg::EventCommand MakeCommand(
const lcf::rpg::EventCommand::Code code,
const std::string& string
)
{
lcf::rpg::EventCommand cmd;
lcf::DBString dbStr(string);
cmd.code = static_cast<uint32_t>(code);
cmd.string = dbStr;
return cmd;
}
static lcf::rpg::SaveEventExecFrame MakeFrame(
std::vector<std::string>::const_iterator begin,
std::vector<std::string>::const_iterator end
)
{
lcf::rpg::SaveEventExecFrame frame;
lcf::rpg::EventCommand::Code code;
code = lcf::rpg::EventCommand::Code::Comment;
while (begin != end)
{
const std::string& str = *begin++;
frame.commands.push_back(MakeCommand(code, str));
code = lcf::rpg::EventCommand::Code::Comment_2;
}
return frame;
}
TEST_CASE("AssertDestinyScript")
{
Game_Destiny destiny;
std::vector<std::string> lines {
"$",
"v[1] = 10;",
};
const char* destinyScript;
auto frame = MakeFrame(lines.begin(), lines.end());
destinyScript = destiny.Interpreter().MakeString(frame);
CHECK_EQ(*destinyScript, '$');
destiny.Interpreter().FreeString();
}
TEST_SUITE_END();