diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index d928f552d1..bd6a632354 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -44,8 +44,9 @@ class CompilerTest : public testing::Test { } void TearDown() override { initGlobals(); - initFileKeyboard(fileKeyboard); + initFileKeyboard(fileKeyboard, false); } + void initGlobals() { msgproc = NULL; szText_stub[0] = '\0'; @@ -399,186 +400,183 @@ TEST_F(CompilerTest, GetXStringImpl_type2_test) { TEST_F(CompilerTest, GetXStringImpl_type3_test) { KMX_WCHAR tstr[128]; - FILE_KEYBOARD fk; KMX_WCHAR str[LINESIZE]; KMX_WCHAR output[GLOBAL_BUFSIZE]; PKMX_WCHAR newp = NULL; - FILE_STORE file_store[100]; - fk.cxStoreArray = 3u; - fk.dpStoreArray = file_store; + PFILE_STORE file_store = new FILE_STORE[100]; + fileKeyboard.cxStoreArray = 3u; + fileKeyboard.dpStoreArray = file_store; u16cpy(file_store[0].szName, u"a"); u16cpy(file_store[1].szName, u"b"); u16cpy(file_store[2].szName, u"c"); // type=3 ('A'), CERR_InvalidToken u16cpy(str, u"abc"); - EXPECT_EQ(CERR_InvalidToken, GetXStringImpl(tstr, &fk, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(CERR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); // type=3 ('A'), CERR_AnyInVirtualKeySection *** TODO *** // type=3 ('A'), CERR_InvalidAny, no close delimiter => NULL u16cpy(str, u"any("); - EXPECT_EQ(CERR_InvalidAny, GetXStringImpl(tstr, &fk, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(CERR_InvalidAny, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); // type=3 ('A'), CERR_InvalidAny, empty delimiters => empty string u16cpy(str, u"any()"); - EXPECT_EQ(CERR_InvalidAny, GetXStringImpl(tstr, &fk, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(CERR_InvalidAny, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); // type=3 ('A'), CERR_StoreDoesNotExist u16cpy(str, u"any(d)"); - EXPECT_EQ(CERR_StoreDoesNotExist, GetXStringImpl(tstr, &fk, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(CERR_StoreDoesNotExist, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); // type=3 ('A'), CERR_ZeroLengthString u16cpy(str, u"any(b)"); file_store[1].dpString = (PKMX_WCHAR)u""; - EXPECT_EQ(CERR_ZeroLengthString, GetXStringImpl(tstr, &fk, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(CERR_ZeroLengthString, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); // type=3 ('A'), valid u16cpy(str, u"any(b)"); file_store[1].dpString = (PKMX_WCHAR)u"abc"; // non-empty - EXPECT_EQ(CERR_None, GetXStringImpl(tstr, &fk, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(CERR_None, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); const KMX_WCHAR tstr_any_valid[] = { UC_SENTINEL, CODE_ANY, 2, 0 }; EXPECT_EQ(0, u16cmp(tstr_any_valid, tstr)); } TEST_F(CompilerTest, GetXStringImpl_type4_test) { KMX_WCHAR tstr[128]; - FILE_KEYBOARD fk; - fk.version = VERSION_90; - fk.cxStoreArray = 0; - fk.dpStoreArray = nullptr; + fileKeyboard.version = VERSION_90; + fileKeyboard.cxStoreArray = 0; + fileKeyboard.dpStoreArray = nullptr; KMX_WCHAR str[LINESIZE]; KMX_WCHAR output[GLOBAL_BUFSIZE]; PKMX_WCHAR newp = NULL; // type=3 ('B'), CERR_InvalidToken u16cpy(str, u"bcd"); - EXPECT_EQ(CERR_InvalidToken, GetXStringImpl(tstr, &fk, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(CERR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); // type=4 ('B'), beep, CERR_BeepInVirtualKeySection *** TODO *** // type=4 ('B'), beep, valid u16cpy(str, u"beep"); - EXPECT_EQ(CERR_None, GetXStringImpl(tstr, &fk, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(CERR_None, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); const KMX_WCHAR tstr_beep_valid[] = { UC_SENTINEL, CODE_BEEP, 0 }; EXPECT_EQ(0, u16cmp(tstr_beep_valid, tstr)); // type=4 ('B'), baselayout, CERR_90FeatureOnly_IfSystemStores - fk.version = VERSION_80; - fk.dwFlags = 0u; + fileKeyboard.version = VERSION_80; + fileKeyboard.dwFlags = 0u; u16cpy(str, u"baselayout"); - EXPECT_EQ(CERR_90FeatureOnly_IfSystemStores, GetXStringImpl(tstr, &fk, str, u"", output, 80, 0, &newp, FALSE)); - fk.version = VERSION_90; + EXPECT_EQ(CERR_90FeatureOnly_IfSystemStores, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + fileKeyboard.version = VERSION_90; // type=4 ('B'), baselayout, CERR_InvalidInVirtualKeySection *** TODO *** // type=4 ('B'), baselayout, no close delimiter => NULL - fk.version = VERSION_90; + fileKeyboard.version = VERSION_90; u16cpy(str, u"baselayout("); - EXPECT_EQ(CERR_InvalidToken, GetXStringImpl(tstr, &fk, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(CERR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); // type=4 ('B'), baselayout, empty delimiters => empty string - fk.version = VERSION_90; + fileKeyboard.version = VERSION_90; u16cpy(str, u"baselayout()"); - EXPECT_EQ(CERR_InvalidToken, GetXStringImpl(tstr, &fk, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(CERR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); // type=4 ('B'), baselayout, CERR_InvalidToken from process_baselayout - fk.version = VERSION_90; + fileKeyboard.version = VERSION_90; u16cpy(str, u"baselayout(abc)"); - EXPECT_EQ(CERR_InvalidToken, GetXStringImpl(tstr, &fk, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(CERR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); // type=4 ('B'), baselayout, valid - fk.version = VERSION_90; - fk.cxStoreArray = 0; - fk.dpStoreArray = nullptr; + fileKeyboard.version = VERSION_90; + fileKeyboard.cxStoreArray = 0; + fileKeyboard.dpStoreArray = nullptr; u16cpy(str, u"baselayout(beep)"); - EXPECT_EQ(CERR_None, GetXStringImpl(tstr, &fk, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(CERR_None, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); const KMX_WCHAR tstr_baselayout_valid[] = { UC_SENTINEL, CODE_IFSYSTEMSTORE, TSS_BASELAYOUT+1, 2, 1, 0 }; EXPECT_EQ(0, u16cmp(tstr_baselayout_valid, tstr)); - delete fk.dpStoreArray; + delete[] fileKeyboard.dpStoreArray; } TEST_F(CompilerTest, GetXStringImpl_type5_test) { KMX_WCHAR tstr[128]; - FILE_KEYBOARD fk; - fk.version = VERSION_80; + fileKeyboard.version = VERSION_80; KMX_WCHAR str[LINESIZE]; KMX_WCHAR output[GLOBAL_BUFSIZE]; PKMX_WCHAR newp = NULL; - FILE_STORE option[100]; - fk.cxStoreArray = 3u; - fk.dpStoreArray = option; + PFILE_STORE option = new FILE_STORE[100]; + fileKeyboard.cxStoreArray = 3u; + fileKeyboard.dpStoreArray = option; u16cpy(option[0].szName, u"a"); u16cpy(option[1].szName, u"b"); u16cpy(option[2].szName, u"c"); // type=5 ('I'), CERR_InvalidToken u16cpy(str, u"ijk"); - EXPECT_EQ(CERR_InvalidToken, GetXStringImpl(tstr, &fk, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(CERR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); // type=5 ('I'), if, CERR_80FeatureOnly - fk.version = VERSION_70; - fk.dwFlags = 0u; + fileKeyboard.version = VERSION_70; + fileKeyboard.dwFlags = 0u; u16cpy(str, u"if"); - EXPECT_EQ(CERR_80FeatureOnly, GetXStringImpl(tstr, &fk, str, u"", output, 80, 0, &newp, FALSE)); - fk.version = VERSION_80; + EXPECT_EQ(CERR_80FeatureOnly, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + fileKeyboard.version = VERSION_80; // type=5 ('I'), if, CERR_InvalidInVirtualKeySection *** TODO *** // type=5 ('I'), if, no close delimiter => NULL - fk.version = VERSION_80; + fileKeyboard.version = VERSION_80; u16cpy(str, u"if("); - EXPECT_EQ(CERR_InvalidIf, GetXStringImpl(tstr, &fk, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(CERR_InvalidIf, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); // type=5 ('I'), if, empty delimiters => empty string - fk.version = VERSION_80; - fk.dwFlags = 0u; + fileKeyboard.version = VERSION_80; + fileKeyboard.dwFlags = 0u; u16cpy(str, u"if()"); - EXPECT_EQ(CERR_InvalidIf, GetXStringImpl(tstr, &fk, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(CERR_InvalidIf, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); // type=5 ('I'), if, invalid - fk.version = VERSION_80; + fileKeyboard.version = VERSION_80; u16cpy(str, u"if(abc)"); - EXPECT_EQ(CERR_InvalidIf, GetXStringImpl(tstr, &fk, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(CERR_InvalidIf, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); // type=5 ('I'), if, CERR_90FeatureOnly_IfSystemStores - fk.version = VERSION_80; + fileKeyboard.version = VERSION_80; u16cpy(str, u"if(&BITMAP=)"); - EXPECT_EQ(CERR_90FeatureOnly_IfSystemStores, GetXStringImpl(tstr, &fk, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(CERR_90FeatureOnly_IfSystemStores, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); // type=5 ('I'), if, CERR_IfSystemStore_NotFound - fk.version = VERSION_90; + fileKeyboard.version = VERSION_90; u16cpy(str, u"if(&abc=)"); - EXPECT_EQ(CERR_IfSystemStore_NotFound, GetXStringImpl(tstr, &fk, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(CERR_IfSystemStore_NotFound, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); // type=5 ('I'), if, system store, equal, valid - fk.version = VERSION_90; - fk.cxStoreArray = 3u; + fileKeyboard.version = VERSION_90; + fileKeyboard.cxStoreArray = 3u; u16cpy(str, u"if(&BITMAP=beep)"); - EXPECT_EQ(CERR_None, GetXStringImpl(tstr, &fk, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(CERR_None, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); const KMX_WCHAR tstr_if_equal_system_store_valid[] = { UC_SENTINEL, CODE_IFSYSTEMSTORE, 2, 2, 4, 0 }; EXPECT_EQ(0, u16cmp(tstr_if_equal_system_store_valid, tstr)); // type=5 ('I'), if, system store, not equal, valid - fk.version = VERSION_90; - fk.cxStoreArray = 3u; + fileKeyboard.version = VERSION_90; + fileKeyboard.cxStoreArray = 3u; u16cpy(str, u"if(&BITMAP!=beep)"); - EXPECT_EQ(CERR_None, GetXStringImpl(tstr, &fk, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(CERR_None, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); const KMX_WCHAR tstr_if_not_equal_system_store_valid[] = { UC_SENTINEL, CODE_IFSYSTEMSTORE, 2, 1, 4, 0 }; EXPECT_EQ(0, u16cmp(tstr_if_not_equal_system_store_valid, tstr)); // type=5 ('I'), if, option, CERR_StoreDoesNotExist - fk.version = VERSION_80; + fileKeyboard.version = VERSION_80; u16cpy(str, u"if(d=beep)"); - EXPECT_EQ(CERR_StoreDoesNotExist, GetXStringImpl(tstr, &fk, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(CERR_StoreDoesNotExist, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); // type=5 ('I'), if, option, equal, valid - fk.version = VERSION_80; - fk.cxStoreArray = 3u; - fk.dpStoreArray = option; + fileKeyboard.version = VERSION_80; + fileKeyboard.cxStoreArray = 3u; + fileKeyboard.dpStoreArray = option; option[1].fIsOption = TRUE; u16cpy(str, u"if(b=beep)"); - EXPECT_EQ(CERR_None, GetXStringImpl(tstr, &fk, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(CERR_None, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); const KMX_WCHAR tstr_if_option_valid[] = { UC_SENTINEL, CODE_IFOPT, 2, 2, 4, 0 }; EXPECT_EQ(0, u16cmp(tstr_if_option_valid, tstr)); }