From b721ff6d5deaea46c0f043f03aa25293c87861b2 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 22 Aug 2024 11:19:37 +0100 Subject: [PATCH 1/5] fix(developer): add call test cases from #11990 to GetXStringImpl_type_c test --- .../kmcmplib/tests/gtest-compiler-test.cpp | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index 1c205976452..9d335de83a1 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -1225,6 +1225,59 @@ TEST_F(CompilerTest, GetXStringImpl_type_o_test) { EXPECT_EQ(0, u16cmp(tstr_outs_space_after_valid, tstr)); } +// tests strings starting with 'c' +TEST_F(CompilerTest, GetXStringImpl_type_c_test) { + KMX_WCHAR tstr[128]; + fileKeyboard.version = VERSION_60; + KMX_WCHAR str[LINESIZE]; + KMX_WCHAR output[GLOBAL_BUFSIZE]; + PKMX_WCHAR newp = nullptr; + PFILE_STORE file_store = new FILE_STORE[100]; + fileKeyboard.cxStoreArray = 3u; + fileKeyboard.dpStoreArray = file_store; + file_store[1].fIsStore = TRUE; + u16cpy(file_store[0].szName, u"a"); + u16cpy(file_store[1].szName, u"b"); + u16cpy(file_store[2].szName, u"c"); + + // call, KmnCompilerMessages::ERROR_501FeatureOnly_Call + fileKeyboard.version = VERSION_50; + u16cpy(str, u"call"); + EXPECT_EQ(KmnCompilerMessages::ERROR_501FeatureOnly_Call, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // call, KmnCompilerMessages::ERROR_CallInVirtualKeySection *** TODO *** + + // call, no close delimiter => NULL + fileKeyboard.version = VERSION_501; + u16cpy(str, u"call("); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidCall, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // call, empty delimiters => empty string + fileKeyboard.version = VERSION_501; + u16cpy(str, u"call()"); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidCall, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // call, space in delimiters (see I11814, I11937, #11910, #11894, #11938) + fileKeyboard.version = VERSION_501; + u16cpy(str, u"call( )"); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidCall, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // call, KmnCompilerMessages::ERROR_StoreDoesNotExist + // fileKeyboard.version = VERSION_501; + // u16cpy(str, u"call(d)"); + // EXPECT_EQ(KmnCompilerMessages::ERROR_StoreDoesNotExist, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // call, KmnCompilerMessages::ERROR_StoreDoesNotExist, space before store + // fileKeyboard.version = VERSION_501; + // u16cpy(str, u"call( d)"); + // EXPECT_EQ(KmnCompilerMessages::ERROR_StoreDoesNotExist, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // call, KmnCompilerMessages::ERROR_StoreDoesNotExist, space after store + // fileKeyboard.version = VERSION_501; + // u16cpy(str, u"call(d )"); + // EXPECT_EQ(KmnCompilerMessages::ERROR_StoreDoesNotExist, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); +} + // KMX_DWORD process_baselayout(PFILE_KEYBOARD fk, PKMX_WCHAR q, PKMX_WCHAR tstr, int *mx) // KMX_DWORD process_platform(PFILE_KEYBOARD fk, PKMX_WCHAR q, PKMX_WCHAR tstr, int *mx) // KMX_DWORD process_if_synonym(KMX_DWORD dwSystemID, PFILE_KEYBOARD fk, PKMX_WCHAR q, PKMX_WCHAR tstr, int *mx) From 7e2f797dd8d65958e194a03d3696b580677afb96 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 22 Aug 2024 11:35:49 +0100 Subject: [PATCH 2/5] fix(developer): move check on store name search to just after search --- developer/src/kmcmplib/src/Compiler.cpp | 2 +- developer/src/kmcmplib/tests/gtest-compiler-test.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/developer/src/kmcmplib/src/Compiler.cpp b/developer/src/kmcmplib/src/Compiler.cpp index 3893a728559..313cc859e59 100644 --- a/developer/src/kmcmplib/src/Compiler.cpp +++ b/developer/src/kmcmplib/src/Compiler.cpp @@ -2310,11 +2310,11 @@ KMX_DWORD GetXStringImpl(PKMX_WCHAR tstr, PFILE_KEYBOARD fk, PKMX_WCHAR str, KMX { if (u16icmp(q, fk->dpStoreArray[i].szName) == 0) break; } + if (i == fk->cxStoreArray) return KmnCompilerMessages::ERROR_StoreDoesNotExist; if (!kmcmp::IsValidCallStore(&fk->dpStoreArray[i])) return KmnCompilerMessages::ERROR_InvalidCall; kmcmp::CheckStoreUsage(fk, i, FALSE, FALSE, TRUE); - if (i == fk->cxStoreArray) return KmnCompilerMessages::ERROR_StoreDoesNotExist; tstr[mx++] = UC_SENTINEL; tstr[mx++] = CODE_CALL; tstr[mx++] = (KMX_WCHAR)i + 1; diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index 9d335de83a1..87db0faa664 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -1235,7 +1235,7 @@ TEST_F(CompilerTest, GetXStringImpl_type_c_test) { PFILE_STORE file_store = new FILE_STORE[100]; fileKeyboard.cxStoreArray = 3u; fileKeyboard.dpStoreArray = file_store; - file_store[1].fIsStore = TRUE; + file_store[1].fIsCall = TRUE; u16cpy(file_store[0].szName, u"a"); u16cpy(file_store[1].szName, u"b"); u16cpy(file_store[2].szName, u"c"); From 75508f46b451f9dde798e9c0832814f443648b92 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 22 Aug 2024 11:43:03 +0100 Subject: [PATCH 3/5] fix(developer): add ERROR_StoreDoesNotExist test cases to GetXStringImpl_type_c test --- .../src/kmcmplib/tests/gtest-compiler-test.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index 87db0faa664..f55bb63ffa4 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -1263,19 +1263,19 @@ TEST_F(CompilerTest, GetXStringImpl_type_c_test) { EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidCall, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); // call, KmnCompilerMessages::ERROR_StoreDoesNotExist - // fileKeyboard.version = VERSION_501; - // u16cpy(str, u"call(d)"); - // EXPECT_EQ(KmnCompilerMessages::ERROR_StoreDoesNotExist, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + fileKeyboard.version = VERSION_501; + u16cpy(str, u"call(d)"); + EXPECT_EQ(KmnCompilerMessages::ERROR_StoreDoesNotExist, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); // call, KmnCompilerMessages::ERROR_StoreDoesNotExist, space before store - // fileKeyboard.version = VERSION_501; - // u16cpy(str, u"call( d)"); - // EXPECT_EQ(KmnCompilerMessages::ERROR_StoreDoesNotExist, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + fileKeyboard.version = VERSION_501; + u16cpy(str, u"call( d)"); + EXPECT_EQ(KmnCompilerMessages::ERROR_StoreDoesNotExist, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); // call, KmnCompilerMessages::ERROR_StoreDoesNotExist, space after store - // fileKeyboard.version = VERSION_501; - // u16cpy(str, u"call(d )"); - // EXPECT_EQ(KmnCompilerMessages::ERROR_StoreDoesNotExist, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + fileKeyboard.version = VERSION_501; + u16cpy(str, u"call(d )"); + EXPECT_EQ(KmnCompilerMessages::ERROR_StoreDoesNotExist, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); } // KMX_DWORD process_baselayout(PFILE_KEYBOARD fk, PKMX_WCHAR q, PKMX_WCHAR tstr, int *mx) From b608e1ca84cffac3a237f5c5338e60df0c979df9 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 22 Aug 2024 15:15:32 +0100 Subject: [PATCH 4/5] fix(developer): add ERROR_InvalidCall and first valid test case to GetXStringImpl_type_c test --- .../src/kmcmplib/tests/gtest-compiler-test.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index f55bb63ffa4..c3ea2a90373 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -1236,6 +1236,7 @@ TEST_F(CompilerTest, GetXStringImpl_type_c_test) { fileKeyboard.cxStoreArray = 3u; fileKeyboard.dpStoreArray = file_store; file_store[1].fIsCall = TRUE; + file_store[1].dwSystemID = TSS_NONE; u16cpy(file_store[0].szName, u"a"); u16cpy(file_store[1].szName, u"b"); u16cpy(file_store[2].szName, u"c"); @@ -1276,6 +1277,22 @@ TEST_F(CompilerTest, GetXStringImpl_type_c_test) { fileKeyboard.version = VERSION_501; u16cpy(str, u"call(d )"); EXPECT_EQ(KmnCompilerMessages::ERROR_StoreDoesNotExist, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // call, KmnCompilerMessages::ERROR_InvalidCall + fileKeyboard.version = VERSION_501; + file_store[1].dpString = (PKMX_WCHAR)u"*"; // cause IsValidCallStore() to fail + u16cpy(str, u"call(b)"); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidCall, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // call, valid + fileKeyboard.version = VERSION_501; + file_store[1].dpString = (PKMX_WCHAR)u"a.dll:A"; + file_store[1].dwSystemID = TSS_NONE; + u16cpy(str, u"call(b)"); + EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + const KMX_WCHAR tstr_call_valid[] = { UC_SENTINEL, CODE_CALL, 2, 0 }; + EXPECT_EQ(0, u16cmp(tstr_call_valid, tstr)); + EXPECT_EQ(TSS_CALLDEFINITION, file_store[1].dwSystemID); } // KMX_DWORD process_baselayout(PFILE_KEYBOARD fk, PKMX_WCHAR q, PKMX_WCHAR tstr, int *mx) From 862f0d9191896951a7fb929e1991f7a59c8e8122 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 22 Aug 2024 15:21:01 +0100 Subject: [PATCH 5/5] fix(developer): add test cases for spaces before and after valid store in call in GetXStringImpl_type_c test --- .../src/kmcmplib/tests/gtest-compiler-test.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index c3ea2a90373..aab01f8131c 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -1293,6 +1293,24 @@ TEST_F(CompilerTest, GetXStringImpl_type_c_test) { const KMX_WCHAR tstr_call_valid[] = { UC_SENTINEL, CODE_CALL, 2, 0 }; EXPECT_EQ(0, u16cmp(tstr_call_valid, tstr)); EXPECT_EQ(TSS_CALLDEFINITION, file_store[1].dwSystemID); + + // call, space before store, valid + fileKeyboard.version = VERSION_501; + file_store[1].dpString = (PKMX_WCHAR)u"a.dll:A"; + file_store[1].dwSystemID = TSS_NONE; + u16cpy(str, u"call( b)"); + EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(0, u16cmp(tstr_call_valid, tstr)); + EXPECT_EQ(TSS_CALLDEFINITION, file_store[1].dwSystemID); + + // call, space after store, valid (see I11937, #11938) + fileKeyboard.version = VERSION_501; + file_store[1].dpString = (PKMX_WCHAR)u"a.dll:A"; + file_store[1].dwSystemID = TSS_NONE; + u16cpy(str, u"call(b )"); + EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(0, u16cmp(tstr_call_valid, tstr)); + EXPECT_EQ(TSS_CALLDEFINITION, file_store[1].dwSystemID); } // KMX_DWORD process_baselayout(PFILE_KEYBOARD fk, PKMX_WCHAR q, PKMX_WCHAR tstr, int *mx)