forked from ynoproject/ynoengine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrtp.cpp
129 lines (94 loc) · 3.94 KB
/
rtp.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#include <limits>
#include <ostream>
#include "filefinder.h"
#include "player.h"
#include "rtp.h"
#include "doctest.h"
TEST_SUITE_BEGIN("RTP");
static FilesystemView make_tree() {
return FileFinder::Root().Create(EP_TEST_PATH "/rtp");
}
TEST_CASE("RTP 2000: lookup table is correct") {
for (int i = 0; RTP::rtp_table_2k_categories[i] != nullptr; ++i) {
const char* category = RTP::rtp_table_2k_categories[i];
std::pair<int, int> range = {RTP::rtp_table_2k_categories_idx[i], RTP::rtp_table_2k_categories_idx[i+1]};
for (int j = range.first; j < range.second; ++j) {
REQUIRE_EQ(strcmp(RTP::rtp_table_2k[j][0], category), 0);
}
}
}
TEST_CASE("RTP 2003: lookup table is correct") {
for (int i = 0; RTP::rtp_table_2k3_categories[i] != nullptr; ++i) {
const char* category = RTP::rtp_table_2k3_categories[i];
std::pair<int, int> range = {RTP::rtp_table_2k3_categories_idx[i], RTP::rtp_table_2k3_categories_idx[i+1]};
for (int j = range.first; j < range.second; ++j) {
REQUIRE_EQ(strcmp(RTP::rtp_table_2k3[j][0], category), 0);
}
}
}
TEST_CASE("RTP 2000: Detection") {
Player::escape_symbol = "\\";
auto tree = make_tree();
std::vector<RTP::RtpHitInfo> hits = RTP::Detect(tree, 2000, std::numeric_limits<int>::max());
REQUIRE(hits.size() == 2);
REQUIRE(hits[0].type == RTP::Type::RPG2000_OfficialJapanese);
REQUIRE(hits[0].hits == 4);
REQUIRE(hits[1].type == RTP::Type::RPG2000_OfficialEnglish);
REQUIRE(hits[1].hits == 1);
Player::escape_symbol = "";
}
TEST_CASE("RTP 2003: Detection") {
Player::escape_symbol = "\\";
std::vector<RTP::RtpHitInfo> hits = RTP::Detect(make_tree(), 2003, std::numeric_limits<int>::max());
REQUIRE(hits.size() == 2);
REQUIRE(hits[0].type == RTP::Type::RPG2003_OfficialJapanese);
REQUIRE(hits[0].hits == 4);
REQUIRE(hits[1].type == RTP::Type::RPG2003_OfficialEnglish);
REQUIRE(hits[1].hits == 1);
Player::escape_symbol = "";
}
TEST_CASE("RTP 2000: Lookup Any to RTP with 1 hit") {
auto types = RTP::LookupAnyToRtp("faceset", "actor1", 2000);
REQUIRE(types.size() == 1);
REQUIRE(types[0] == RTP::Type::RPG2000_OfficialEnglish);
}
TEST_CASE("RTP 2000: Lookup Any to RTP with 2 hits") {
auto types = RTP::LookupAnyToRtp("music", "dungeon1", 2000);
REQUIRE(types.size() == 2);
REQUIRE(types[0] == RTP::Type::RPG2000_OfficialEnglish);
REQUIRE(types[1] == RTP::Type::RPG2000_DonMiguelEnglish);
}
TEST_CASE("RTP 2003: Lookup Any to RTP with 1 hit") {
auto types = RTP::LookupAnyToRtp("faceset", "actor1", 2003);
REQUIRE(types.size() == 1);
REQUIRE(types[0] == RTP::Type::RPG2003_OfficialEnglish);
}
TEST_CASE("RTP 2000: Lookup RTP to RTP (Found)") {
bool is_rtp_asset;
std::string name = RTP::LookupRtpToRtp("faceset", "主人公2", RTP::Type::RPG2000_OfficialJapanese, RTP::Type::RPG2000_OfficialEnglish, &is_rtp_asset);
REQUIRE(name == "actor2");
REQUIRE(is_rtp_asset);
}
TEST_CASE("RTP 2003: Lookup RTP to RTP (Found)") {
bool is_rtp_asset;
std::string name = RTP::LookupRtpToRtp("faceset", "主人公2", RTP::Type::RPG2003_OfficialJapanese, RTP::Type::RPG2003_OfficialEnglish, &is_rtp_asset);
REQUIRE(name == "actor2");
REQUIRE(is_rtp_asset);
}
TEST_CASE("RTP 2000: Lookup RTP to RTP (Not found)") {
bool is_rtp_asset;
std::string name = RTP::LookupRtpToRtp("faceset", "NotFound", RTP::Type::RPG2000_OfficialJapanese, RTP::Type::RPG2000_OfficialEnglish, &is_rtp_asset);
REQUIRE(name.empty());
REQUIRE(!is_rtp_asset);
}
TEST_CASE("RTP 2000: Lookup RTP to RTP (Same RTP)") {
// For performance reasons same to same does no table scan, update this test when the behaviour changes
bool is_rtp_asset;
std::string name = RTP::LookupRtpToRtp("faceset", "actor2", RTP::Type::RPG2000_OfficialEnglish, RTP::Type::RPG2000_OfficialEnglish, &is_rtp_asset);
REQUIRE(name == "actor2");
REQUIRE(!is_rtp_asset);
name = RTP::LookupRtpToRtp("faceset", "NotFound", RTP::Type::RPG2000_OfficialEnglish, RTP::Type::RPG2000_OfficialEnglish, &is_rtp_asset);
REQUIRE(name == "NotFound");
REQUIRE(!is_rtp_asset);
}
TEST_SUITE_END();