From a2d30ac40517008c07cf884bfe0b4885efc365a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Thu, 1 Dec 2016 23:21:35 +0100 Subject: [PATCH] Add multibyte LanguagePack test --- test/tests/LanguagePackTest.cpp | 48 ++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/test/tests/LanguagePackTest.cpp b/test/tests/LanguagePackTest.cpp index 598a7e3558..6d6e0263c2 100644 --- a/test/tests/LanguagePackTest.cpp +++ b/test/tests/LanguagePackTest.cpp @@ -21,7 +21,8 @@ TEST(LanguagePackTest, create_mutable_id_1) delete lang; } -extern const utf8 * LanguageEnGB; +extern const utf8 * LanguageEnGB; +extern const unsigned char LanguageZhTW[]; TEST(LanguagePackTest, language_pack_simple) { @@ -36,6 +37,21 @@ TEST(LanguagePackTest, language_pack_simple) delete lang; } +TEST(LanguagePackTest, language_pack_multibyte) +{ + ILanguagePack * lang = LanguagePackFactory::FromText(0, (const utf8 *)LanguageZhTW); + ASSERT_EQ(lang->GetId(), 0); + ASSERT_EQ(lang->GetCount(), 4); + ASSERT_STREQ(lang->GetString(2), u8"懸吊式雲霄飛車"); + ASSERT_EQ(lang->GetScenarioOverrideStringId("Forest Frontiers", 0), 0x7000); + ASSERT_EQ(lang->GetScenarioOverrideStringId("Forest Frontiers", 2), 0x7002); + ASSERT_STREQ(lang->GetString(0x7000), "Forest Frontiers"); + ASSERT_STREQ(lang->GetString(0x7002), u8"在隱藏於森林深處的清空範圍中, 建造一個很受歡迎的樂園"); + ASSERT_EQ(lang->GetObjectOverrideStringId("CONDORRD", 0), 0x6000); + ASSERT_STREQ(lang->GetString(0x6000), u8"神鷹暢遊"); + delete lang; +} + const utf8 * LanguageEnGB = "# STR_XXXX part is read and XXXX becomes the string id number.\n" "# Everything after the colon and before the new line will be saved as the " "string.\n" @@ -53,3 +69,33 @@ const utf8 * LanguageEnGB = "# STR_XXXX part is read and XXXX becomes the string "STR_NAME :my test ride\n" "STR_DESC :ride description\n" "STR_CPTY :ride capacity\n"; + +// This includes a few entries extracted from zh-TW localisation. +// It has to be declared as `unsigned char`, or else the values overflow signed byte. +const unsigned char LanguageZhTW[] = { + 0x53, 0x54, 0x52, 0x5f, 0x30, 0x30, 0x30, 0x30, 0x20, 0x20, 0x20, 0x20, 0x3a, 0xe8, 0x9e, 0xba, 0xe6, 0x97, 0x8b, 0xe5, + 0xbc, 0x8f, 0xe9, 0x9b, 0xb2, 0xe9, 0x9c, 0x84, 0xe9, 0xa3, 0x9b, 0xe8, 0xbb, 0x8a, 0x0a, 0x53, 0x54, 0x52, 0x5f, 0x30, + 0x30, 0x30, 0x31, 0x20, 0x20, 0x20, 0x20, 0x3a, 0xe7, 0xab, 0x99, 0xe7, 0xab, 0x8b, 0xe5, 0xbc, 0x8f, 0xe9, 0x9b, 0xb2, + 0xe9, 0x9c, 0x84, 0xe9, 0xa3, 0x9b, 0xe8, 0xbb, 0x8a, 0x0a, 0x53, 0x54, 0x52, 0x5f, 0x30, 0x30, 0x30, 0x32, 0x20, 0x20, + 0x20, 0x20, 0x3a, 0xe6, 0x87, 0xb8, 0xe5, 0x90, 0x8a, 0xe5, 0xbc, 0x8f, 0xe9, 0x9b, 0xb2, 0xe9, 0x9c, 0x84, 0xe9, 0xa3, + 0x9b, 0xe8, 0xbb, 0x8a, 0x0a, 0x53, 0x54, 0x52, 0x5f, 0x30, 0x30, 0x30, 0x33, 0x20, 0x20, 0x20, 0x20, 0x3a, 0xe5, 0x8f, + 0x8d, 0xe8, 0xbd, 0x89, 0xe5, 0xbc, 0x8f, 0xe9, 0x9b, 0xb2, 0xe9, 0x9c, 0x84, 0xe9, 0xa3, 0x9b, 0xe8, 0xbb, 0x8a, 0x0a, + 0x3c, 0x46, 0x6f, 0x72, 0x65, 0x73, 0x74, 0x20, 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x69, 0x65, 0x72, 0x73, 0x3e, 0x0a, 0x53, + 0x54, 0x52, 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