1#include <gtest/gtest.h>
26 std::vector<uint8_t> mock_data = {0x6A, 0x7F, 0x00};
30 EXPECT_TRUE(result.ok());
31 const auto message_data = result.value();
34 EXPECT_EQ(message_data.ContentsParsed,
"[L]");
40 std::vector<uint8_t> mock_data = {0x00, 0x01, 0x02, 0x7F, 0x00};
44 ASSERT_TRUE(result.ok());
45 const auto message_data = result.value();
48 std::vector<editor::MessageData> message_data_vector = {message_data};
51 EXPECT_THAT(parsed, ::testing::ElementsAre(
"ABC"));
77 std::string input =
"[L][C:01]ABC";
79 std::vector<uint8_t> expected = {0x6A, 0x77, 0x01, 0x00, 0x01, 0x02};
80 EXPECT_EQ(result, expected);
84 std::vector<editor::DictionaryEntry> mock_dict = {
87 std::string input =
"This is a test message.";
89 EXPECT_EQ(result,
"This is a [D:00] [D:01].");
93 std::vector<editor::DictionaryEntry> mock_dict = {
95 std::string input =
"No matching words.";
97 EXPECT_EQ(result,
"No matching words.");
111 std::vector<uint8_t> mock_data = {0x7F};
115 ASSERT_TRUE(result.ok());
116 const auto message_data = result.value();
118 EXPECT_EQ(message_data.ContentsParsed,
"");
123 std::vector<editor::DictionaryEntry> mock_dict = {
126 std::string input =
"[L] rescued Zelda from danger.";
129 std::string optimized =
132 EXPECT_EQ(optimized,
"[L] rescued [D:01] from danger.");
136 std::vector<editor::DictionaryEntry> mock_dict = {
139 std::string input =
"You got an item!";
143 EXPECT_EQ(message_data.
RawString,
"You got an item!");
148 std::string input =
"[W:02]";
151 EXPECT_TRUE(result.
Active);
153 EXPECT_EQ(result.
Value, 0x02);
157 std::string input =
"[INVALID]";
160 EXPECT_FALSE(result.
Active);
165 EXPECT_TRUE(result.empty());
171 EXPECT_FALSE(result.empty());
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< std::string > ImportMessageData(std::string_view filename)
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 OptimizeMessageForDictionary(std::string message_string, const std::vector< DictionaryEntry > &dictionary)
std::string ContentsParsed
void SetMessage(const std::string &message, const std::vector< DictionaryEntry > &dictionary)