GTEST_TEST_F(LocString, readLocString) { static const byte kData[] = { 0x17, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x46, 0xC3, 0xB6, 0xC3, 0xB6, 0x62, 0xC3, 0xA4, 0x72, 0x30, 0x01, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x46, 0xC3, 0xB6, 0xC3, 0xB6, 0x62, 0xC3, 0xA4, 0x72, 0x31 }; Common::MemoryReadStream stream(kData); Aurora::LocString locString; locString.readLocString(stream); EXPECT_EQ(locString.getID(), 23); EXPECT_TRUE(locString.hasString(Aurora::kLanguageEnglish, Aurora::kLanguageGenderMale )); EXPECT_TRUE(locString.hasString(Aurora::kLanguageEnglish, Aurora::kLanguageGenderFemale)); EXPECT_STREQ(locString.getString(Aurora::kLanguageEnglish, Aurora::kLanguageGenderMale ).c_str(), kUTF8String0); EXPECT_STREQ(locString.getString(Aurora::kLanguageEnglish, Aurora::kLanguageGenderFemale).c_str(), kUTF8String1); EXPECT_STREQ(locString.getFirstString().c_str(), kUTF8String0); EXPECT_STREQ(locString.getString().c_str(), kUTF8String0); }
GTEST_TEST_F(LocString, readLocStringBroken) { static const byte kData[] = { 0x99, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00 }; Common::MemoryReadStream stream(kData); Aurora::LocString locString; EXPECT_THROW(locString.readLocString(stream), Common::Exception); }
GTEST_TEST_F(LocString, readLocStringSetGender) { static const byte kData[] = { 0x17, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x46, 0xC3, 0xB6, 0xC3, 0xB6, 0x62, 0xC3, 0xA4, 0x72, 0x30, 0x01, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x46, 0xC3, 0xB6, 0xC3, 0xB6, 0x62, 0xC3, 0xA4, 0x72, 0x31 }; Common::MemoryReadStream stream(kData); Aurora::LocString locString; locString.readLocString(stream); LangMan.setCurrentLanguage(Aurora::kLanguageEnglish); LangMan.setCurrentGender(Aurora::kLanguageGenderMale); EXPECT_STREQ(locString.getString().c_str(), kUTF8String0); LangMan.setCurrentGender(Aurora::kLanguageGenderFemale); EXPECT_STREQ(locString.getString().c_str(), kUTF8String1); }