1#include <gtest/gtest.h>
27 std::vector<uint8_t> mock_data = {0x6A, 0x7F, 0x00};
31 EXPECT_TRUE(result.ok());
32 const auto message_data = result.value();
35 EXPECT_EQ(message_data.ContentsParsed,
"[L]");
41 std::vector<uint8_t> mock_data = {0x00, 0x01, 0x02, 0x7F, 0x00};
45 ASSERT_TRUE(result.ok());
46 const auto message_data = result.value();
49 std::vector<editor::MessageData> message_data_vector = {message_data};
52 EXPECT_THAT(parsed, ::testing::ElementsAre(
"ABC"));
78 std::string input =
"[L][C:01]ABC";
80 std::vector<uint8_t> expected = {0x6A, 0x77, 0x01, 0x00, 0x01, 0x02};
81 EXPECT_EQ(result, expected);
85 std::vector<editor::DictionaryEntry> mock_dict = {
88 std::string input =
"This is a test message.";
90 EXPECT_EQ(result,
"This is a [D:00] [D:01].");
94 std::vector<editor::DictionaryEntry> mock_dict = {
96 std::string input =
"No matching words.";
98 EXPECT_EQ(result,
"No matching words.");
112 std::vector<uint8_t> mock_data = {0x4D, 0x4E, 0x4F, 0x50, 0x7F};
116 ASSERT_TRUE(result.ok());
117 const auto message_data = result.value();
119 EXPECT_EQ(message_data.ContentsParsed,
"[UP][DOWN][LEFT][RIGHT]");
124 std::vector<uint8_t> mock_data = {0x88, 0x89, 0x7F};
128 ASSERT_TRUE(result.ok());
129 const auto message_data = result.value();
131 EXPECT_EQ(message_data.ContentsParsed,
"[D:00][D:01]");
136 std::vector<uint8_t> mock_data = {0x00, 0x01, 0x02};
140 EXPECT_FALSE(result.ok());
144 std::vector<uint8_t> mock_data = {0x7F};
148 ASSERT_TRUE(result.ok());
149 const auto message_data = result.value();
151 EXPECT_EQ(message_data.ContentsParsed,
"");
156 std::vector<editor::DictionaryEntry> mock_dict = {
159 std::string input =
"[L] rescued Zelda from danger.";
162 std::string optimized =
165 EXPECT_EQ(optimized,
"[L] rescued [D:01] from danger.");
169 std::vector<editor::DictionaryEntry> mock_dict = {
172 std::string input =
"You got an item!";
176 EXPECT_EQ(message_data.
RawString,
"You got an item!");
181 std::string input =
"[W:02]";
184 EXPECT_TRUE(result.
Active);
186 EXPECT_EQ(result.
Value, 0x02);
190 std::string input =
"[INVALID]";
193 EXPECT_FALSE(result.
Active);
199 EXPECT_FALSE(result.empty());
The Rom class is used to load, save, and modify Rom data.
editor::MessageEditor message_editor_
std::vector< editor::DictionaryEntry > dictionary_
uint8_t FindMatchingCharacter(char value)
std::string ParseTextDataByte(uint8_t value)
std::string ReplaceAllDictionaryWords(std::string str, std::vector< DictionaryEntry > dictionary)
constexpr int kNumDictionaryEntries
absl::StatusOr< MessageData > ParseSingleMessage(const std::vector< uint8_t > &rom_data, int *current_pos)
std::vector< std::string > ParseMessageData(std::vector< MessageData > &message_data, const std::vector< DictionaryEntry > &dictionary_entries)
std::vector< DictionaryEntry > BuildDictionaryEntries(Rom *rom)
std::vector< uint8_t > ParseMessageToData(std::string str)
ParsedElement FindMatchingElement(const std::string &str)
int8_t FindDictionaryEntry(uint8_t value)
TEST_F(CpuTest, AsmParserTokenizerOk)
Main namespace for the application.
std::string ContentsParsed
std::string OptimizeMessageForDictionary(std::string_view message_string, const std::vector< DictionaryEntry > &dictionary)
void SetMessage(const std::string &message, const std::vector< DictionaryEntry > &dictionary)