From 00eb02e597f07b6ea6b34679be00641460939112 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Mon, 30 Sep 2024 10:26:48 +0100 Subject: [PATCH 01/28] chore(developer): add first three use() test cases in GetXStringImpl_type_u test --- .../src/kmcmplib/tests/gtest-compiler-test.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index 39c47372d4..9dbe41134f 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -1515,7 +1515,7 @@ TEST_F(CompilerTest, GetXStringImpl_type_n_test) { // tests strings starting with 'u' TEST_F(CompilerTest, GetXStringImpl_type_u_test) { KMX_WCHAR tstr[128]; - fileKeyboard.version = VERSION_70; + fileKeyboard.version = VERSION_90; KMX_WCHAR str[LINESIZE]; KMX_WCHAR output[GLOBAL_BUFSIZE]; PKMX_WCHAR newp = nullptr; @@ -1558,6 +1558,18 @@ TEST_F(CompilerTest, GetXStringImpl_type_u_test) { EXPECT_EQ(0, u16cmp(tstr_unicode_valid, tstr)); EXPECT_EQ(1, msgproc_errors.size()); EXPECT_EQ(KmnCompilerMessages::WARN_UnicodeInANSIGroup, msgproc_errors[0].errorCode); + + // use, no close delimiter => NULL + u16cpy(str, u"use("); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidUse, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // use, empty delimiters => empty string + u16cpy(str, u"use()"); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidUse, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // use, space in delimiters (see #11814, #11937, #11910, #11894, #11938) + u16cpy(str, u"use( )"); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidUse, 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 4d4e79007b43267cc67f2209ca22ec056629c401 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Mon, 30 Sep 2024 11:45:57 +0100 Subject: [PATCH 02/28] chore(developer): add initFileStoreArray() and use it in GetXStringImpl_type_i test --- .../kmcmplib/tests/gtest-compiler-test.cpp | 78 +++++++------------ 1 file changed, 28 insertions(+), 50 deletions(-) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index 9dbe41134f..46133cd98c 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -87,6 +87,22 @@ class CompilerTest : public testing::Test { fk.extra = nullptr; } + void initFileStoreArray(FILE_KEYBOARD &fk, std::vector names) { + fk.dpStoreArray = new FILE_STORE[100]; + fk.cxStoreArray = names.size(); + + for (int i=0; i NULL + u16cpy(str, u"use"); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidUse, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + // use, no close delimiter => NULL u16cpy(str, u"use("); EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidUse, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); From 85a40b695f8b126364fd54ec6d04aa8fbb5a69f2 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Mon, 30 Sep 2024 11:52:07 +0100 Subject: [PATCH 03/28] chore(developer): use initFileStoreArray() in GetXStringImpl_type_o test --- .../src/kmcmplib/tests/gtest-compiler-test.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index 46133cd98c..a5780797b4 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -1151,13 +1151,8 @@ TEST_F(CompilerTest, GetXStringImpl_type_o_test) { 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"); + initFileStoreArray(fileKeyboard, {u"a", u"b", u"c"}); + fileKeyboard.dpStoreArray[1].fIsStore = TRUE; // KmnCompilerMessages::ERROR_InvalidToken u16cpy(str, u"opq"); @@ -1191,26 +1186,26 @@ TEST_F(CompilerTest, GetXStringImpl_type_o_test) { // outs, KmnCompilerMessages::ERROR_OutsTooLong PKMX_WCHAR dpString = (PKMX_WCHAR)u"abc"; - file_store[1].dpString = dpString; // length 4 => max should be > 4, otherwise a ERROR_OutsTooLong is emitted + fileKeyboard.dpStoreArray[1].dpString = dpString; // length 4 => max should be > 4, otherwise a ERROR_OutsTooLong is emitted int max = u16len(dpString) + 1; // 4, including terminating '\0' u16cpy(str, u"outs(b)"); EXPECT_EQ(KmnCompilerMessages::ERROR_OutsTooLong, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, max, 0, &newp, FALSE)); // max reduced to force error // outs, valid - file_store[1].dpString = (PKMX_WCHAR)u"abc"; + fileKeyboard.dpStoreArray[1].dpString = (PKMX_WCHAR)u"abc"; u16cpy(str, u"outs(b)"); EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); const KMX_WCHAR tstr_outs_valid[] = { 'a', 'b', 'c', 0 }; EXPECT_EQ(0, u16cmp(tstr_outs_valid, tstr)); // outs, space before store, valid - file_store[1].dpString = (PKMX_WCHAR)u"abc"; + fileKeyboard.dpStoreArray[1].dpString = (PKMX_WCHAR)u"abc"; u16cpy(str, u"outs( b)"); EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); EXPECT_EQ(0, u16cmp(tstr_outs_valid, tstr)); // outs, space after store, valid (see #11937, #11938) - file_store[1].dpString = (PKMX_WCHAR)u"abc"; + fileKeyboard.dpStoreArray[1].dpString = (PKMX_WCHAR)u"abc"; u16cpy(str, u"outs(b )"); EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); EXPECT_EQ(0, u16cmp(tstr_outs_valid, tstr)); From 016c464ad788d58c0223c3b0f7294024838f1099 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Mon, 30 Sep 2024 11:57:57 +0100 Subject: [PATCH 04/28] chore(developer): use initFileStoreArray() in GetXStringImpl_type_c test --- .../kmcmplib/tests/gtest-compiler-test.cpp | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index a5780797b4..767fcc46ea 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -1218,14 +1218,9 @@ TEST_F(CompilerTest, GetXStringImpl_type_c_test) { 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].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"); + initFileStoreArray(fileKeyboard, {u"a", u"b", u"c"}); + fileKeyboard.dpStoreArray[1].fIsCall = TRUE; + fileKeyboard.dpStoreArray[1].dwSystemID = TSS_NONE; // are comments stripped before this point? // if so, why the test on whitespace after 'c'? @@ -1355,37 +1350,37 @@ TEST_F(CompilerTest, GetXStringImpl_type_c_test) { // call, KmnCompilerMessages::ERROR_InvalidCall fileKeyboard.version = VERSION_501; - file_store[1].dpString = (PKMX_WCHAR)u"*"; // cause IsValidCallStore() to fail + fileKeyboard.dpStoreArray[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; + fileKeyboard.dpStoreArray[1].dpString = (PKMX_WCHAR)u"a.dll:A"; + fileKeyboard.dpStoreArray[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); + EXPECT_EQ(TSS_CALLDEFINITION, fileKeyboard.dpStoreArray[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; + fileKeyboard.dpStoreArray[1].dpString = (PKMX_WCHAR)u"a.dll:A"; + fileKeyboard.dpStoreArray[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); + EXPECT_EQ(TSS_CALLDEFINITION, fileKeyboard.dpStoreArray[1].dwSystemID); // call, space after store, valid (see #11937, #11938) fileKeyboard.version = VERSION_501; - file_store[1].dpString = (PKMX_WCHAR)u"a.dll:A"; - file_store[1].dwSystemID = TSS_NONE; + fileKeyboard.dpStoreArray[1].dpString = (PKMX_WCHAR)u"a.dll:A"; + fileKeyboard.dpStoreArray[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); + EXPECT_EQ(TSS_CALLDEFINITION, fileKeyboard.dpStoreArray[1].dwSystemID); } // tests strings starting with 'n' From 7b26c54b11026a5645552d2fed713aa2f0c48ba9 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Mon, 30 Sep 2024 12:00:16 +0100 Subject: [PATCH 05/28] chore(developer): use initFileStoreArray() in GetXStringImpl_type_n test --- .../src/kmcmplib/tests/gtest-compiler-test.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index 767fcc46ea..a93e0f16d3 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -1390,12 +1390,7 @@ TEST_F(CompilerTest, GetXStringImpl_type_n_test) { 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; - u16cpy(file_store[0].szName, u"a"); - u16cpy(file_store[1].szName, u"b"); - u16cpy(file_store[2].szName, u"c"); + initFileStoreArray(fileKeyboard, {u"a", u"b", u"c"}); // KmnCompilerMessages::ERROR_InvalidToken fileKeyboard.version = VERSION_70; @@ -1442,7 +1437,7 @@ TEST_F(CompilerTest, GetXStringImpl_type_n_test) { // notany, valid fileKeyboard.version = VERSION_70; u16cpy(str, u"notany(b)"); - file_store[1].dpString = (PKMX_WCHAR)u"abc"; // non-empty + fileKeyboard.dpStoreArray[1].dpString = (PKMX_WCHAR)u"abc"; // non-empty EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); const KMX_WCHAR tstr_notany_valid[] = { UC_SENTINEL, CODE_NOTANY, 2, 0 }; EXPECT_EQ(0, u16cmp(tstr_notany_valid, tstr)); @@ -1450,21 +1445,21 @@ TEST_F(CompilerTest, GetXStringImpl_type_n_test) { // notany, valid, empy store fileKeyboard.version = VERSION_70; u16cpy(str, u"notany(b)"); - file_store[1].dpString = (PKMX_WCHAR)u""; // empty + fileKeyboard.dpStoreArray[1].dpString = (PKMX_WCHAR)u""; // empty EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); EXPECT_EQ(0, u16cmp(tstr_notany_valid, tstr)); // notany, space before store, valid fileKeyboard.version = VERSION_70; u16cpy(str, u"notany( b)"); - file_store[1].dpString = (PKMX_WCHAR)u"abc"; // non-empty + fileKeyboard.dpStoreArray[1].dpString = (PKMX_WCHAR)u"abc"; // non-empty EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); EXPECT_EQ(0, u16cmp(tstr_notany_valid, tstr)); // notany, space after store, valid (see #11937, #11938) fileKeyboard.version = VERSION_70; u16cpy(str, u"notany(b )"); - file_store[1].dpString = (PKMX_WCHAR)u"abc"; // non-empty + fileKeyboard.dpStoreArray[1].dpString = (PKMX_WCHAR)u"abc"; // non-empty EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); EXPECT_EQ(0, u16cmp(tstr_notany_valid, tstr)); From b79c6895bbee72303dae8ac3ebf8404aeccbc389 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Mon, 30 Sep 2024 12:04:52 +0100 Subject: [PATCH 06/28] chore(developer): use initFileStoreArray() in GetXStringImpl_type_a test --- .../src/kmcmplib/tests/gtest-compiler-test.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index a93e0f16d3..c72a0cb589 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -800,12 +800,7 @@ TEST_F(CompilerTest, GetXStringImpl_type_a_test) { 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; - u16cpy(file_store[0].szName, u"a"); - u16cpy(file_store[1].szName, u"b"); - u16cpy(file_store[2].szName, u"c"); + initFileStoreArray(fileKeyboard, {u"a", u"b", u"c"}); // KmnCompilerMessages::ERROR_InvalidToken u16cpy(str, u"abc"); @@ -839,25 +834,25 @@ TEST_F(CompilerTest, GetXStringImpl_type_a_test) { // KmnCompilerMessages::ERROR_ZeroLengthString u16cpy(str, u"any(b)"); - file_store[1].dpString = (PKMX_WCHAR)u""; + fileKeyboard.dpStoreArray[1].dpString = (PKMX_WCHAR)u""; EXPECT_EQ(KmnCompilerMessages::ERROR_ZeroLengthString, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); // valid u16cpy(str, u"any(b)"); - file_store[1].dpString = (PKMX_WCHAR)u"abc"; // non-empty + fileKeyboard.dpStoreArray[1].dpString = (PKMX_WCHAR)u"abc"; // non-empty EXPECT_EQ(STATUS_Success, 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)); // space before store, valid u16cpy(str, u"any( b)"); - file_store[1].dpString = (PKMX_WCHAR)u"abc"; // non-empty + fileKeyboard.dpStoreArray[1].dpString = (PKMX_WCHAR)u"abc"; // non-empty EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); EXPECT_EQ(0, u16cmp(tstr_any_valid, tstr)); // space after store, valid (see #11937, #11938) u16cpy(str, u"any(b )"); - file_store[1].dpString = (PKMX_WCHAR)u"abc"; // non-empty + fileKeyboard.dpStoreArray[1].dpString = (PKMX_WCHAR)u"abc"; // non-empty EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); EXPECT_EQ(0, u16cmp(tstr_any_valid, tstr)); } From 3bb60fead417e918d6f7cbebb1ac1ed6da546f9c Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Mon, 30 Sep 2024 12:15:17 +0100 Subject: [PATCH 07/28] chore(developer): fix to initFileStoreArray due to Linux build failure --- developer/src/kmcmplib/tests/gtest-compiler-test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index c72a0cb589..3cf395d73d 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -91,7 +91,7 @@ class CompilerTest : public testing::Test { fk.dpStoreArray = new FILE_STORE[100]; fk.cxStoreArray = names.size(); - for (int i=0; i Date: Thu, 3 Oct 2024 11:55:36 +0100 Subject: [PATCH 08/28] chore(developer): change initFileGroupArray() to take names; add three use() test cases for non-existent group --- .../kmcmplib/tests/gtest-compiler-test.cpp | 44 +++++++++++++------ 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index 3cf395d73d..de6cb6f40c 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -91,7 +91,7 @@ class CompilerTest : public testing::Test { fk.dpStoreArray = new FILE_STORE[100]; fk.cxStoreArray = names.size(); - for (unsigned int i=0; iszName[0] = 0; - fk.dpGroupArray->cxKeyArray = 0; - fk.dpGroupArray->dpKeyArray = nullptr; - fk.dpGroupArray->dpMatch = nullptr; - fk.dpGroupArray->dpNoMatch = nullptr; - fk.dpGroupArray->fUsingKeys = fUsingKeys; - fk.dpGroupArray->fReadOnly = FALSE; - fk.dpGroupArray->Line = 0; + void initFileGroupArray(FILE_KEYBOARD &fk, std::vector names) { + fk.dpGroupArray = new FILE_GROUP[100]; + fk.cxGroupArray = names.size(); + + for (KMX_DWORD i=0; i Date: Thu, 3 Oct 2024 12:04:14 +0100 Subject: [PATCH 09/28] chore(developer): add three use() test cases for valid group --- .../src/kmcmplib/tests/gtest-compiler-test.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index de6cb6f40c..c0f25d6efe 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -1544,6 +1544,22 @@ TEST_F(CompilerTest, GetXStringImpl_type_u_test) { // use, KmnCompilerMessages::ERROR_GroupDoesNotExist, space after store u16cpy(str, u"use(d )"); EXPECT_EQ(KmnCompilerMessages::ERROR_GroupDoesNotExist, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // use, valid + u16cpy(str, u"use(b)"); + EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + const KMX_WCHAR tstr_use_valid[] = { UC_SENTINEL, CODE_USE, 2, 0 }; + EXPECT_EQ(0, u16cmp(tstr_use_valid, tstr)); + + // use, space before group, valid + u16cpy(str, u"use( b)"); + EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(0, u16cmp(tstr_use_valid, tstr)); + + // use, space after group, valid (see #11937, #11938) + u16cpy(str, u"use(b )"); + EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(0, u16cmp(tstr_use_valid, tstr)); } // KMX_DWORD process_baselayout(PFILE_KEYBOARD fk, PKMX_WCHAR q, PKMX_WCHAR tstr, int *mx) From 947932fbfe8043a512591ad227535cb693d6b684 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 3 Oct 2024 12:10:49 +0100 Subject: [PATCH 10/28] chore(developer): add GetXStringImpl_type_r test and first test case --- .../src/kmcmplib/tests/gtest-compiler-test.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index c0f25d6efe..1d6d9a1b28 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -1562,6 +1562,19 @@ TEST_F(CompilerTest, GetXStringImpl_type_u_test) { EXPECT_EQ(0, u16cmp(tstr_use_valid, tstr)); } +// tests strings starting with 'r' +TEST_F(CompilerTest, GetXStringImpl_type_r_test) { + KMX_WCHAR tstr[128]; + fileKeyboard.version = VERSION_90; + KMX_WCHAR str[LINESIZE]; + KMX_WCHAR output[GLOBAL_BUFSIZE]; + PKMX_WCHAR newp = nullptr; + + // KmnCompilerMessages::ERROR_InvalidToken + u16cpy(str, u"rst"); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, 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 54b5781b1122fbb60ab5eefed9e99db0c9e4a1f3 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 3 Oct 2024 12:24:13 +0100 Subject: [PATCH 11/28] chore(developer): add eight test cases for commands without expected delimiters --- .../kmcmplib/tests/gtest-compiler-test.cpp | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index 1d6d9a1b28..d0b2806edc 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -742,6 +742,10 @@ TEST_F(CompilerTest, GetXStringImpl_type_xd_test) { u16cpy(str, u"dk(%)"); EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidDeadkey, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + // dk, KmnCompilerMessages::ERROR_InvalidDeadkey, no delimiters => NULL + u16cpy(str, u"dk"); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidDeadkey, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + // dk, KmnCompilerMessages::ERROR_InvalidDeadkey, no close delimiter => NULL u16cpy(str, u"dk("); EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidDeadkey, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); @@ -811,6 +815,10 @@ TEST_F(CompilerTest, GetXStringImpl_type_a_test) { // KmnCompilerMessages::ERROR_AnyInVirtualKeySection *** TODO *** + // KmnCompilerMessages::ERROR_InvalidAny, no delimiters => NULL + u16cpy(str, u"any"); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidAny, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + // KmnCompilerMessages::ERROR_InvalidAny, no close delimiter => NULL u16cpy(str, u"any("); EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidAny, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); @@ -889,6 +897,11 @@ TEST_F(CompilerTest, GetXStringImpl_type_b_test) { // baselayout, KmnCompilerMessages::ERROR_InvalidInVirtualKeySection *** TODO *** + // baselayout, no delimiters => NULL + fileKeyboard.version = VERSION_90; + u16cpy(str, u"baselayout"); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + // baselayout, no close delimiter => NULL fileKeyboard.version = VERSION_90; u16cpy(str, u"baselayout("); @@ -957,6 +970,11 @@ TEST_F(CompilerTest, GetXStringImpl_type_i_test) { // if, KmnCompilerMessages::ERROR_InvalidInVirtualKeySection *** TODO *** + // if, no delimiters => NULL + fileKeyboard.version = VERSION_80; + u16cpy(str, u"if"); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidIf, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + // if, no close delimiter => NULL fileKeyboard.version = VERSION_80; u16cpy(str, u"if("); @@ -1049,6 +1067,10 @@ TEST_F(CompilerTest, GetXStringImpl_type_i_test) { // index, KmnCompilerMessages::ERROR_InvalidInVirtualKeySection *** TODO *** + // index, no delimiters => NULL + u16cpy(str, u"index"); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidIndex, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + // index, no close delimiter => NULL u16cpy(str, u"index("); EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidIndex, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); @@ -1158,6 +1180,10 @@ TEST_F(CompilerTest, GetXStringImpl_type_o_test) { // outs, KmnCompilerMessages::ERROR_OutsInVirtualKeySection *** TODO *** + // outs, no delimiters => NULL + u16cpy(str, u"outs"); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidOuts, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + // outs, no close delimiter => NULL u16cpy(str, u"outs("); EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidOuts, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); @@ -1316,6 +1342,11 @@ TEST_F(CompilerTest, GetXStringImpl_type_c_test) { // call, KmnCompilerMessages::ERROR_CallInVirtualKeySection *** TODO *** + // call, no delimiters => 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, no close delimiter => NULL fileKeyboard.version = VERSION_501; u16cpy(str, u"call("); @@ -1402,6 +1433,11 @@ TEST_F(CompilerTest, GetXStringImpl_type_n_test) { // notany, KmnCompilerMessages::ERROR_AnyInVirtualKeySection *** TODO *** + // notany, no delimiters => NULL + fileKeyboard.version = VERSION_70; + u16cpy(str, u"notany"); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidAny, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + // notany, no close delimiter => NULL fileKeyboard.version = VERSION_70; u16cpy(str, u"notany("); From b8d2fad56eaf5ba1d388cac269ca9530d43cdcaf Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 3 Oct 2024 12:31:18 +0100 Subject: [PATCH 12/28] chore(developer): add reset() ERROR_80FeatureOnly test case --- developer/src/kmcmplib/tests/gtest-compiler-test.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index d0b2806edc..533c010d15 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -1426,7 +1426,7 @@ TEST_F(CompilerTest, GetXStringImpl_type_n_test) { u16cpy(str, u"nmo"); EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); - // notany, KmnCompilerMessages::ERROR_60FeatureOnly_Contextn + // notany, KmnCompilerMessages::ERROR_70FeatureOnly fileKeyboard.version = VERSION_60; u16cpy(str, u"notany"); EXPECT_EQ(KmnCompilerMessages::ERROR_70FeatureOnly, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); @@ -1601,14 +1601,22 @@ TEST_F(CompilerTest, GetXStringImpl_type_u_test) { // tests strings starting with 'r' TEST_F(CompilerTest, GetXStringImpl_type_r_test) { KMX_WCHAR tstr[128]; - fileKeyboard.version = VERSION_90; + fileKeyboard.version = VERSION_80; KMX_WCHAR str[LINESIZE]; KMX_WCHAR output[GLOBAL_BUFSIZE]; PKMX_WCHAR newp = nullptr; // KmnCompilerMessages::ERROR_InvalidToken + fileKeyboard.version = VERSION_80; u16cpy(str, u"rst"); EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // reset, KmnCompilerMessages::ERROR_80FeatureOnly + fileKeyboard.version = VERSION_70; + u16cpy(str, u"reset"); + EXPECT_EQ(KmnCompilerMessages::ERROR_80FeatureOnly, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // reset, KmnCompilerMessages::ERROR_InvalidInVirtualKeySection *** TODO *** } // KMX_DWORD process_baselayout(PFILE_KEYBOARD fk, PKMX_WCHAR q, PKMX_WCHAR tstr, int *mx) From eee9cf49ddfda1c9b4033ddd262d190e7f8fa01a Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Mon, 7 Oct 2024 13:48:38 +0100 Subject: [PATCH 13/28] chore(developer): add ten use cases for reset() in GetXStringImpl_type_r test --- .../kmcmplib/tests/gtest-compiler-test.cpp | 60 ++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index 533c010d15..f44f1fc517 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -1476,7 +1476,7 @@ TEST_F(CompilerTest, GetXStringImpl_type_n_test) { const KMX_WCHAR tstr_notany_valid[] = { UC_SENTINEL, CODE_NOTANY, 2, 0 }; EXPECT_EQ(0, u16cmp(tstr_notany_valid, tstr)); - // notany, valid, empy store + // notany, valid, empty store fileKeyboard.version = VERSION_70; u16cpy(str, u"notany(b)"); fileKeyboard.dpStoreArray[1].dpString = (PKMX_WCHAR)u""; // empty @@ -1605,6 +1605,7 @@ TEST_F(CompilerTest, GetXStringImpl_type_r_test) { KMX_WCHAR str[LINESIZE]; KMX_WCHAR output[GLOBAL_BUFSIZE]; PKMX_WCHAR newp = nullptr; + initFileStoreArray(fileKeyboard, {u"a", u"b", u"c"}); // KmnCompilerMessages::ERROR_InvalidToken fileKeyboard.version = VERSION_80; @@ -1617,6 +1618,63 @@ TEST_F(CompilerTest, GetXStringImpl_type_r_test) { EXPECT_EQ(KmnCompilerMessages::ERROR_80FeatureOnly, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); // reset, KmnCompilerMessages::ERROR_InvalidInVirtualKeySection *** TODO *** + + // reset, no delimiters => NULL + fileKeyboard.version = VERSION_80; + u16cpy(str, u"reset"); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidReset, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // reset, no close delimiter => NULL + fileKeyboard.version = VERSION_80; + u16cpy(str, u"reset("); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidReset, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // reset, empty delimiters => empty string + fileKeyboard.version = VERSION_80; + u16cpy(str, u"reset()"); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidReset, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // reset, space in delimiters (see #11814, #11937, #11910, #11894, #11938) + fileKeyboard.version = VERSION_80; + u16cpy(str, u"reset( )"); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidReset, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // reset, KmnCompilerMessages::ERROR_StoreDoesNotExist + fileKeyboard.version = VERSION_80; + u16cpy(str, u"reset(d)"); + EXPECT_EQ(KmnCompilerMessages::ERROR_StoreDoesNotExist, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // reset, KmnCompilerMessages::ERROR_StoreDoesNotExist, space before store + fileKeyboard.version = VERSION_80; + u16cpy(str, u"reset( d)"); + EXPECT_EQ(KmnCompilerMessages::ERROR_StoreDoesNotExist, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // reset, KmnCompilerMessages::ERROR_StoreDoesNotExist, space after store + fileKeyboard.version = VERSION_80; + u16cpy(str, u"reset(d )"); + EXPECT_EQ(KmnCompilerMessages::ERROR_StoreDoesNotExist, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // reset, valid + fileKeyboard.version = VERSION_80; + u16cpy(str, u"reset(b)"); + fileKeyboard.dpStoreArray[1].dpString = (PKMX_WCHAR)u"abc"; // non-empty + EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + const KMX_WCHAR tstr_reset_valid[] = { UC_SENTINEL, CODE_RESETOPT, 2, 0 }; + EXPECT_EQ(0, u16cmp(tstr_reset_valid, tstr)); + + // reset, space before store, valid + fileKeyboard.version = VERSION_80; + u16cpy(str, u"reset( b)"); + fileKeyboard.dpStoreArray[1].dpString = (PKMX_WCHAR)u"abc"; // non-empty + EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(0, u16cmp(tstr_reset_valid, tstr)); + + // reset, space after store, valid (see #11937, #11938) + fileKeyboard.version = VERSION_80; + u16cpy(str, u"reset(b )"); + fileKeyboard.dpStoreArray[1].dpString = (PKMX_WCHAR)u"abc"; // non-empty + EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(0, u16cmp(tstr_reset_valid, tstr)); } // KMX_DWORD process_baselayout(PFILE_KEYBOARD fk, PKMX_WCHAR q, PKMX_WCHAR tstr, int *mx) From ebb6f87fb325861537248a9b0c583e81ccb363e0 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Mon, 7 Oct 2024 14:10:06 +0100 Subject: [PATCH 14/28] chore(developer): add return() test case to GetXStringImpl_type_r test --- developer/src/kmcmplib/tests/gtest-compiler-test.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index f44f1fc517..892096f275 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -1665,16 +1665,23 @@ TEST_F(CompilerTest, GetXStringImpl_type_r_test) { // reset, space before store, valid fileKeyboard.version = VERSION_80; u16cpy(str, u"reset( b)"); - fileKeyboard.dpStoreArray[1].dpString = (PKMX_WCHAR)u"abc"; // non-empty EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); EXPECT_EQ(0, u16cmp(tstr_reset_valid, tstr)); // reset, space after store, valid (see #11937, #11938) fileKeyboard.version = VERSION_80; u16cpy(str, u"reset(b )"); - fileKeyboard.dpStoreArray[1].dpString = (PKMX_WCHAR)u"abc"; // non-empty EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); EXPECT_EQ(0, u16cmp(tstr_reset_valid, tstr)); + + // return, valid + u16cpy(str, u"return"); + u16cpy(output, u"XXXXX"); + EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 4, 0, &newp, FALSE)); + const KMX_WCHAR tstr_return_valid[] = { UC_SENTINEL, CODE_RETURN, 0 }; + const KMX_WCHAR output_return_valid[] = { UC_SENTINEL, CODE_RETURN, 0, 0, 'X' }; + EXPECT_EQ(0, u16cmp(tstr_return_valid, tstr)); + EXPECT_EQ(0, u16cmp(output_return_valid, output)); } // KMX_DWORD process_baselayout(PFILE_KEYBOARD fk, PKMX_WCHAR q, PKMX_WCHAR tstr, int *mx) From d269edb20ca5afefbe853585774c8d649f8e8e21 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Mon, 7 Oct 2024 16:25:42 +0100 Subject: [PATCH 15/28] chore(developer): add initial three test cases to GetXStringImpl_type_osb test, plus initVKDictionary() --- .../kmcmplib/tests/gtest-compiler-test.cpp | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index 892096f275..3692552ad5 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -119,6 +119,15 @@ class CompilerTest : public testing::Test { } } + void initVKDictionary(FILE_KEYBOARD &fk) { + fk.dpVKDictionary = new FILE_VKDICTIONARY[10]; + fk.cxVKDictionary = 0; + + for (KMX_DWORD i=0; i<10; i++) { + fk.dpVKDictionary[i].szName[0] = 0; + } + } + void deleteFileKeyboard(FILE_KEYBOARD &fk) { if (fk.dpStoreArray) { delete[] fk.dpStoreArray; } if (fk.dpGroupArray) { delete[] fk.dpGroupArray; } @@ -1684,6 +1693,32 @@ TEST_F(CompilerTest, GetXStringImpl_type_r_test) { EXPECT_EQ(0, u16cmp(output_return_valid, output)); } +// tests strings starting with '[' +TEST_F(CompilerTest, GetXStringImpl_type_osb_test) { + KMX_WCHAR tstr[128]; + fileKeyboard.version = VERSION_90; + KMX_WCHAR str[LINESIZE]; + KMX_WCHAR output[GLOBAL_BUFSIZE]; + PKMX_WCHAR newp = nullptr; + initVKDictionary(fileKeyboard); + + // virtual key, empty, KmnCompilerMessages::ERROR_InvalidToken + u16cpy(str, u"[]"); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // virtual key, single space, KmnCompilerMessages::ERROR_InvalidToken + u16cpy(str, u"[ ]"); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // virtual key, in VKeyNames, valid + fileKeyboard.version = VERSION_90; + u16cpy(str, u"[K_A]"); + EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + KMX_WCHAR sFlag = ISVIRTUALKEY; + const KMX_WCHAR tstr_virtual_key_valid[] = { UC_SENTINEL, CODE_EXTENDED, sFlag, 65, UC_SENTINEL_EXTENDEDEND, 0 }; + EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); +} + // 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 2f7096a81041d17cea808920bcbc9fb824aac391 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 10 Oct 2024 10:47:18 +0100 Subject: [PATCH 16/28] chore(developer): add ten test cases on virtual key qualifiers --- .../kmcmplib/tests/gtest-compiler-test.cpp | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index 3692552ad5..03a57ece11 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -1715,8 +1715,31 @@ TEST_F(CompilerTest, GetXStringImpl_type_osb_test) { u16cpy(str, u"[K_A]"); EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); KMX_WCHAR sFlag = ISVIRTUALKEY; - const KMX_WCHAR tstr_virtual_key_valid[] = { UC_SENTINEL, CODE_EXTENDED, sFlag, 65, UC_SENTINEL_EXTENDEDEND, 0 }; + KMX_WCHAR tstr_virtual_key_valid[] = { UC_SENTINEL, CODE_EXTENDED, sFlag, 65, UC_SENTINEL_EXTENDEDEND, 0 }; EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); + + // virtual key, in VKeyNames, valid with qualifiers + std::map m{ + // str sFlag + {u"[NCAPS K_A]", ISVIRTUALKEY | NOTCAPITALFLAG }, + {u"[LALT K_A]", ISVIRTUALKEY | LALTFLAG }, + {u"[LCTRL K_A]", ISVIRTUALKEY | LCTRLFLAG }, + {u"[RALT K_A]", ISVIRTUALKEY | RALTFLAG }, + {u"[RCTRL K_A]", ISVIRTUALKEY | RCTRLFLAG }, + {u"[ALT K_A]", ISVIRTUALKEY | K_ALTFLAG }, + {u"[CTRL K_A]", ISVIRTUALKEY | K_CTRLFLAG }, + {u"[CAPS K_A]", ISVIRTUALKEY | CAPITALFLAG }, + {u"[SHIFT K_A]", ISVIRTUALKEY | K_SHIFTFLAG }, + {u"[CTRL ALT K_A]", ISVIRTUALKEY | K_CTRLFLAG | K_ALTFLAG }, + }; + + fileKeyboard.version = VERSION_90; + for (auto i = m.begin(); i != m.end(); i++) { + u16cpy(str, i->first); + EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + tstr_virtual_key_valid[2] = i->second; + EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); + } } // KMX_DWORD process_baselayout(PFILE_KEYBOARD fk, PKMX_WCHAR q, PKMX_WCHAR tstr, int *mx) From 5b7ccc9f055f281d2659bd8ef6b3c3cf8d10dcbe Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 10 Oct 2024 11:20:35 +0100 Subject: [PATCH 17/28] chore(developer): check for mixed modifiers on virtual keys --- .../kmcmplib/tests/gtest-compiler-test.cpp | 48 +++++++++++++------ 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index 03a57ece11..c5a2cd131e 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -1695,6 +1695,7 @@ TEST_F(CompilerTest, GetXStringImpl_type_r_test) { // tests strings starting with '[' TEST_F(CompilerTest, GetXStringImpl_type_osb_test) { + kmcmp::msgproc = msgproc_collect; KMX_WCHAR tstr[128]; fileKeyboard.version = VERSION_90; KMX_WCHAR str[LINESIZE]; @@ -1718,27 +1719,46 @@ TEST_F(CompilerTest, GetXStringImpl_type_osb_test) { KMX_WCHAR tstr_virtual_key_valid[] = { UC_SENTINEL, CODE_EXTENDED, sFlag, 65, UC_SENTINEL_EXTENDEDEND, 0 }; EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); - // virtual key, in VKeyNames, valid with qualifiers - std::map m{ - // str sFlag - {u"[NCAPS K_A]", ISVIRTUALKEY | NOTCAPITALFLAG }, - {u"[LALT K_A]", ISVIRTUALKEY | LALTFLAG }, - {u"[LCTRL K_A]", ISVIRTUALKEY | LCTRLFLAG }, - {u"[RALT K_A]", ISVIRTUALKEY | RALTFLAG }, - {u"[RCTRL K_A]", ISVIRTUALKEY | RCTRLFLAG }, - {u"[ALT K_A]", ISVIRTUALKEY | K_ALTFLAG }, - {u"[CTRL K_A]", ISVIRTUALKEY | K_CTRLFLAG }, - {u"[CAPS K_A]", ISVIRTUALKEY | CAPITALFLAG }, - {u"[SHIFT K_A]", ISVIRTUALKEY | K_SHIFTFLAG }, - {u"[CTRL ALT K_A]", ISVIRTUALKEY | K_CTRLFLAG | K_ALTFLAG }, + // virtual key, in VKeyNames, valid with modifiers + std::map m_mod{ + // str sFlag + {u"[NCAPS K_A]", ISVIRTUALKEY | NOTCAPITALFLAG }, + {u"[LALT K_A]", ISVIRTUALKEY | LALTFLAG }, + {u"[LCTRL K_A]", ISVIRTUALKEY | LCTRLFLAG }, + {u"[RALT K_A]", ISVIRTUALKEY | RALTFLAG }, + {u"[RCTRL K_A]", ISVIRTUALKEY | RCTRLFLAG }, + {u"[ALT K_A]", ISVIRTUALKEY | K_ALTFLAG }, + {u"[CTRL K_A]", ISVIRTUALKEY | K_CTRLFLAG }, + {u"[CAPS K_A]", ISVIRTUALKEY | CAPITALFLAG }, + {u"[SHIFT K_A]", ISVIRTUALKEY | K_SHIFTFLAG }, + {u"[CTRL ALT K_A]", ISVIRTUALKEY | K_CTRLFLAG | K_ALTFLAG }, + {u"[LCTRL LALT K_A]", ISVIRTUALKEY | LCTRLFLAG | LALTFLAG }, // no mixed modifiers warning + {u"[RCTRL RALT K_A]", ISVIRTUALKEY | RCTRLFLAG | RALTFLAG }, // no mixed modifiers warning + }; + + fileKeyboard.version = VERSION_90; + for (auto i = m_mod.begin(); i != m_mod.end(); i++) { + u16cpy(str, i->first); + EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + tstr_virtual_key_valid[2] = i->second; + EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); + EXPECT_EQ(0, msgproc_errors.size()); + } + + // virtual key, in VKeyNames, with modifiers, KmnCompilerMessages::WARN_MixingLeftAndRightModifiers + std::map m_mixed{ + // str sFlag + {u"[LCTRL RALT K_A]", ISVIRTUALKEY | LCTRLFLAG | RALTFLAG }, + {u"[RCTRL LALT K_A]", ISVIRTUALKEY | RCTRLFLAG | LALTFLAG }, }; fileKeyboard.version = VERSION_90; - for (auto i = m.begin(); i != m.end(); i++) { + for (auto i = m_mixed.begin(); i != m_mixed.end(); i++) { u16cpy(str, i->first); EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); tstr_virtual_key_valid[2] = i->second; EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); + EXPECT_EQ(KmnCompilerMessages::WARN_MixingLeftAndRightModifiers, msgproc_errors.back().errorCode); } } From 8d9ec89a3d4c9a2f1ed2aabea45961bdb7b108e3 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 10 Oct 2024 12:36:45 +0100 Subject: [PATCH 18/28] chore(developer): add test cases for chiral modifiers version bump --- .../kmcmplib/tests/gtest-compiler-test.cpp | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index c5a2cd131e..3c5fdb6eba 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -1760,6 +1760,36 @@ TEST_F(CompilerTest, GetXStringImpl_type_osb_test) { EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); EXPECT_EQ(KmnCompilerMessages::WARN_MixingLeftAndRightModifiers, msgproc_errors.back().errorCode); } + msgproc_errors.clear(); + + // virtual key, in VKeyNames, with modifiers, chiral modifiers version bump + std::map m_chiral{ + // str sFlag + {u"[LCTRL K_A]", ISVIRTUALKEY | LCTRLFLAG }, + {u"[LALT K_A]", ISVIRTUALKEY | LALTFLAG }, + {u"[RCTRL K_A]", ISVIRTUALKEY | RCTRLFLAG }, + {u"[RALT K_A]", ISVIRTUALKEY | RALTFLAG }, + {u"[CAPS K_A]", ISVIRTUALKEY | CAPITALFLAG }, + {u"[NCAPS K_A]", ISVIRTUALKEY | NOTCAPITALFLAG }, + }; + + std::cerr << "start debug" << std::endl; + + kmcmp::CompileTarget = CKF_KEYMANWEB; + fileKeyboard.dwFlags = KF_AUTOMATICVERSION; + for (auto i = m_chiral.begin(); i != m_chiral.end(); i++) { + fileKeyboard.version = VERSION_90; + u16cpy(str, i->first); + EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + tstr_virtual_key_valid[2] = i->second; + EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); + EXPECT_EQ(VERSION_100, fileKeyboard.version); + EXPECT_EQ(0, msgproc_errors.size()); + } + kmcmp::CompileTarget = CKF_KEYMAN; + fileKeyboard.dwFlags = 0; + + std::cerr << "end debug" << std::endl; } // KMX_DWORD process_baselayout(PFILE_KEYBOARD fk, PKMX_WCHAR q, PKMX_WCHAR tstr, int *mx) From 24377acfc9b41f683e8072f3930416686ea0f68d Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Mon, 14 Oct 2024 11:58:37 +0100 Subject: [PATCH 19/28] chore(developer): add ten virtual key test cases (virtual char key) --- .../kmcmplib/tests/gtest-compiler-test.cpp | 52 +++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index 3c5fdb6eba..b18f4f290e 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -1773,8 +1773,6 @@ TEST_F(CompilerTest, GetXStringImpl_type_osb_test) { {u"[NCAPS K_A]", ISVIRTUALKEY | NOTCAPITALFLAG }, }; - std::cerr << "start debug" << std::endl; - kmcmp::CompileTarget = CKF_KEYMANWEB; fileKeyboard.dwFlags = KF_AUTOMATICVERSION; for (auto i = m_chiral.begin(); i != m_chiral.end(); i++) { @@ -1789,7 +1787,55 @@ TEST_F(CompilerTest, GetXStringImpl_type_osb_test) { kmcmp::CompileTarget = CKF_KEYMAN; fileKeyboard.dwFlags = 0; - std::cerr << "end debug" << std::endl; + // virtual key, modifiers only (no key portion), KmnCompilerMessages::ERROR_InvalidToken + fileKeyboard.version = VERSION_90; + u16cpy(str, u"[CTRL ALT]"); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // virtual key, single quote, ERROR_60FeatureOnly_VirtualCharKey + fileKeyboard.version = VERSION_50; + u16cpy(str, u"[']"); + EXPECT_EQ(KmnCompilerMessages::ERROR_60FeatureOnly_VirtualCharKey, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // virtual key, double quote, ERROR_60FeatureOnly_VirtualCharKey + fileKeyboard.version = VERSION_50; + u16cpy(str, u"[\"]"); + EXPECT_EQ(KmnCompilerMessages::ERROR_60FeatureOnly_VirtualCharKey, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // virtual key, unmatched single quote, ERROR_InvalidToken + fileKeyboard.version = VERSION_60; + u16cpy(str, u"['"); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // virtual key, unmatched single quote, ERROR_InvalidToken + fileKeyboard.version = VERSION_60; + u16cpy(str, u"[']"); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // virtual key, unmatched double quote, ERROR_InvalidToken + fileKeyboard.version = VERSION_60; + u16cpy(str, u"[\""); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // virtual key, unmatched double quote, ERROR_InvalidToken + fileKeyboard.version = VERSION_60; + u16cpy(str, u"[\"]"); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // virtual key, unmatched single quote ('\n'), ERROR_InvalidToken + fileKeyboard.version = VERSION_60; + u16cpy(str, u"['\n"); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // virtual key, empty single quotes, ERROR_InvalidToken + fileKeyboard.version = VERSION_60; + u16cpy(str, u"['']"); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // virtual key, empty double quotes, ERROR_InvalidToken + fileKeyboard.version = VERSION_60; + u16cpy(str, u"[\"\"]"); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, 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 592ffbd8079113eb0d2616bc79c260406655b83e Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Mon, 14 Oct 2024 16:03:11 +0100 Subject: [PATCH 20/28] chore(developer): add six additional test cases (virtual char key), plus three commented-out test cases for issue #12307 --- .../kmcmplib/tests/gtest-compiler-test.cpp | 124 +++++++++++++++--- 1 file changed, 106 insertions(+), 18 deletions(-) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index b18f4f290e..467c4af2ff 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -31,6 +31,7 @@ namespace kmcmp { extern std::string messageFilename; extern int BeginLine[4]; extern int CompileTarget; + extern KMX_BOOL FMnemonicLayout = FALSE; } class CompilerTest : public testing::Test { @@ -1719,6 +1720,18 @@ TEST_F(CompilerTest, GetXStringImpl_type_osb_test) { KMX_WCHAR tstr_virtual_key_valid[] = { UC_SENTINEL, CODE_EXTENDED, sFlag, 65, UC_SENTINEL_EXTENDEDEND, 0 }; EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); + // virtual key, space before, in VKeyNames, valid + fileKeyboard.version = VERSION_90; + u16cpy(str, u"[ K_A]"); + EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); + + // virtual key, space after, in VKeyNames, valid + fileKeyboard.version = VERSION_90; + u16cpy(str, u"[K_A ]"); + EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); + // virtual key, in VKeyNames, valid with modifiers std::map m_mod{ // str sFlag @@ -1792,50 +1805,125 @@ TEST_F(CompilerTest, GetXStringImpl_type_osb_test) { u16cpy(str, u"[CTRL ALT]"); EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); - // virtual key, single quote, ERROR_60FeatureOnly_VirtualCharKey - fileKeyboard.version = VERSION_50; + // virtual key, in VKeyNames, no space between modifier and key portion, ERROR_InvalidToken + // fileKeyboard.version = VERSION_90; + // u16cpy(str, u"[CTRLK_A]"); + // EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // virtual key, in VKeyNames, no space between modifiers, ERROR_InvalidToken + // fileKeyboard.version = VERSION_90; + // u16cpy(str, u"[CTRLALT K_A]"); + // EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // virtual key, '_' bewteen modifier and key portion' + // fileKeyboard.version = VERSION_90; + // u16cpy(str, u"[CTRL_K_A]"); + // EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + // tstr_virtual_key_valid[2] = ISVIRTUALKEY | K_CTRLFLAG; + // tstr_virtual_key_valid[3] = 256; //VK_MAX + 1 + // std::cerr << "tstr_virtual_key_valid: "; + // for (int i=0; i<6; i++) + // std::cerr << (int)tstr_virtual_key_valid[i] << ' '; + // std::cerr << std::endl; + // std::cerr << "tstr : "; + // for (int i=0; i<6; i++) + // std::cerr << (int)tstr[i] << ' '; + // std::cerr << std::endl; + // EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); + // EXPECT_EQ(0, msgproc_errors.size()); + // tstr_virtual_key_valid[3] = 65; + + // virtual char key, single quote, ERROR_60FeatureOnly_VirtualCharKey + fileKeyboard.version = VERSION_50; + kmcmp::FMnemonicLayout = TRUE; u16cpy(str, u"[']"); EXPECT_EQ(KmnCompilerMessages::ERROR_60FeatureOnly_VirtualCharKey, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); - // virtual key, double quote, ERROR_60FeatureOnly_VirtualCharKey - fileKeyboard.version = VERSION_50; + // virtual char key, double quote, ERROR_60FeatureOnly_VirtualCharKey + fileKeyboard.version = VERSION_50; + kmcmp::FMnemonicLayout = TRUE; u16cpy(str, u"[\"]"); EXPECT_EQ(KmnCompilerMessages::ERROR_60FeatureOnly_VirtualCharKey, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); - // virtual key, unmatched single quote, ERROR_InvalidToken - fileKeyboard.version = VERSION_60; + // virtual char key, unmatched single quote, ERROR_InvalidToken + fileKeyboard.version = VERSION_60; + kmcmp::FMnemonicLayout = TRUE; u16cpy(str, u"['"); EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); - // virtual key, unmatched single quote, ERROR_InvalidToken - fileKeyboard.version = VERSION_60; + // virtual char key, unmatched single quote, ERROR_InvalidToken + fileKeyboard.version = VERSION_60; + kmcmp::FMnemonicLayout = TRUE; u16cpy(str, u"[']"); EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); - // virtual key, unmatched double quote, ERROR_InvalidToken - fileKeyboard.version = VERSION_60; + // virtual char key, unmatched double quote, ERROR_InvalidToken + fileKeyboard.version = VERSION_60; + kmcmp::FMnemonicLayout = TRUE; u16cpy(str, u"[\""); EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); - // virtual key, unmatched double quote, ERROR_InvalidToken - fileKeyboard.version = VERSION_60; + // virtual char key, unmatched double quote, ERROR_InvalidToken + fileKeyboard.version = VERSION_60; + kmcmp::FMnemonicLayout = TRUE; u16cpy(str, u"[\"]"); EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); - // virtual key, unmatched single quote ('\n'), ERROR_InvalidToken - fileKeyboard.version = VERSION_60; + // virtual char key, unmatched single quote ('\n'), ERROR_InvalidToken + fileKeyboard.version = VERSION_60; + kmcmp::FMnemonicLayout = TRUE; u16cpy(str, u"['\n"); EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); - // virtual key, empty single quotes, ERROR_InvalidToken - fileKeyboard.version = VERSION_60; + // virtual char key, empty single quotes, ERROR_InvalidToken + fileKeyboard.version = VERSION_60; + kmcmp::FMnemonicLayout = TRUE; u16cpy(str, u"['']"); EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); - // virtual key, empty double quotes, ERROR_InvalidToken - fileKeyboard.version = VERSION_60; + // virtual char key, empty double quotes, ERROR_InvalidToken + fileKeyboard.version = VERSION_60; + kmcmp::FMnemonicLayout = TRUE; u16cpy(str, u"[\"\"]"); EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // virtual char key, valid + fileKeyboard.version = VERSION_60; + kmcmp::FMnemonicLayout = TRUE; + u16cpy(str, u"['A']"); + EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + tstr_virtual_key_valid[2] = ISVIRTUALKEY | VIRTUALCHARKEY; + EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); + EXPECT_EQ(0, msgproc_errors.size()); + + // virtual char key, space before, valid + fileKeyboard.version = VERSION_60; + kmcmp::FMnemonicLayout = TRUE; + u16cpy(str, u"[ 'A']"); + EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + tstr_virtual_key_valid[2] = ISVIRTUALKEY | VIRTUALCHARKEY; + EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); + EXPECT_EQ(0, msgproc_errors.size()); + + // virtual char key, space after, valid + fileKeyboard.version = VERSION_60; + kmcmp::FMnemonicLayout = TRUE; + u16cpy(str, u"['A' ]"); + EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + tstr_virtual_key_valid[2] = ISVIRTUALKEY | VIRTUALCHARKEY; + EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); + EXPECT_EQ(0, msgproc_errors.size()); + + // virtual char key, FMnemonicLayout not set, WARN_VirtualCharKeyWithPositionalLayout + fileKeyboard.version = VERSION_60; + kmcmp::FMnemonicLayout = FALSE; + u16cpy(str, u"['A']"); + EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + tstr_virtual_key_valid[2] = ISVIRTUALKEY | VIRTUALCHARKEY; + EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); + EXPECT_EQ(1, msgproc_errors.size()); + EXPECT_EQ(KmnCompilerMessages::WARN_VirtualCharKeyWithPositionalLayout, msgproc_errors[0].errorCode); + msgproc_errors.clear(); } // KMX_DWORD process_baselayout(PFILE_KEYBOARD fk, PKMX_WCHAR q, PKMX_WCHAR tstr, int *mx) From b3635680a6f220a9e4a64d5f76c972972e83659b Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Mon, 21 Oct 2024 10:48:36 +0100 Subject: [PATCH 21/28] chore(developer): correct extern variable initialisation (kmcmp::FMnemonicLayout) --- developer/src/kmcmplib/tests/gtest-compiler-test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index 467c4af2ff..e3fcacda11 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -31,7 +31,7 @@ namespace kmcmp { extern std::string messageFilename; extern int BeginLine[4]; extern int CompileTarget; - extern KMX_BOOL FMnemonicLayout = FALSE; + extern KMX_BOOL FMnemonicLayout; } class CompilerTest : public testing::Test { @@ -60,6 +60,7 @@ class CompilerTest : public testing::Test { kmcmp::BeginLine[BEGIN_NEWCONTEXT] = -1; kmcmp::BeginLine[BEGIN_POSTKEYSTROKE] = -1; kmcmp::CompileTarget = CKF_KEYMAN; + kmcmp::FMnemonicLayout = FALSE; } void initFileKeyboard(FILE_KEYBOARD &fk) { From e54762e1eba452fa94dc0d29d520beebf9e6820c Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Mon, 21 Oct 2024 11:55:41 +0100 Subject: [PATCH 22/28] chore(developer): add two test cases for long virtual key names --- .../kmcmplib/tests/gtest-compiler-test.cpp | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index e3fcacda11..3d76b79cd0 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -1816,20 +1816,12 @@ TEST_F(CompilerTest, GetXStringImpl_type_osb_test) { // u16cpy(str, u"[CTRLALT K_A]"); // EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); - // virtual key, '_' bewteen modifier and key portion' + // virtual key, '_' between modifier and key portion', ERROR_InvalidToken // fileKeyboard.version = VERSION_90; // u16cpy(str, u"[CTRL_K_A]"); // EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); // tstr_virtual_key_valid[2] = ISVIRTUALKEY | K_CTRLFLAG; // tstr_virtual_key_valid[3] = 256; //VK_MAX + 1 - // std::cerr << "tstr_virtual_key_valid: "; - // for (int i=0; i<6; i++) - // std::cerr << (int)tstr_virtual_key_valid[i] << ' '; - // std::cerr << std::endl; - // std::cerr << "tstr : "; - // for (int i=0; i<6; i++) - // std::cerr << (int)tstr[i] << ' '; - // std::cerr << std::endl; // EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); // EXPECT_EQ(0, msgproc_errors.size()); // tstr_virtual_key_valid[3] = 65; @@ -1925,6 +1917,27 @@ TEST_F(CompilerTest, GetXStringImpl_type_osb_test) { EXPECT_EQ(1, msgproc_errors.size()); EXPECT_EQ(KmnCompilerMessages::WARN_VirtualCharKeyWithPositionalLayout, msgproc_errors[0].errorCode); msgproc_errors.clear(); + + // virtual key, not in VKeyNames, long, but not too long name, valid + fileKeyboard.version = VERSION_90; + u16cpy(str, u"[XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX]"); // SZMAX_VKDICTIONARYNAME - 1 + EXPECT_EQ(SZMAX_VKDICTIONARYNAME - 1 + 2, u16len(str)); + EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + tstr_virtual_key_valid[2] = ISVIRTUALKEY; + tstr_virtual_key_valid[3] = 256; //VK_MAX + 1 + EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); + EXPECT_EQ(0, msgproc_errors.size()); + tstr_virtual_key_valid[3] = 65; + fileKeyboard.cxVKDictionary = 0; + delete[] fileKeyboard.dpVKDictionary; + fileKeyboard.dpVKDictionary = nullptr; + + // virtual key, not in VKeyNames, name too long, ERROR_InvalidToken + fileKeyboard.version = VERSION_90; + u16cpy(str, u"[XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX]"); // SZMAX_VKDICTIONARYNAME + EXPECT_EQ(SZMAX_VKDICTIONARYNAME + 2, u16len(str)); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, 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 6ec4a47214328e6804312f51a864ad8228c2a4f7 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Mon, 21 Oct 2024 12:30:08 +0100 Subject: [PATCH 23/28] chore(developer): three test cases for custom virtual key names --- .../kmcmplib/tests/gtest-compiler-test.cpp | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index 3d76b79cd0..fbb70793e1 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -1926,11 +1926,9 @@ TEST_F(CompilerTest, GetXStringImpl_type_osb_test) { tstr_virtual_key_valid[2] = ISVIRTUALKEY; tstr_virtual_key_valid[3] = 256; //VK_MAX + 1 EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); - EXPECT_EQ(0, msgproc_errors.size()); tstr_virtual_key_valid[3] = 65; fileKeyboard.cxVKDictionary = 0; - delete[] fileKeyboard.dpVKDictionary; - fileKeyboard.dpVKDictionary = nullptr; + fileKeyboard.dpVKDictionary[0].szName[0] = 0; // virtual key, not in VKeyNames, name too long, ERROR_InvalidToken fileKeyboard.version = VERSION_90; @@ -1938,6 +1936,39 @@ TEST_F(CompilerTest, GetXStringImpl_type_osb_test) { EXPECT_EQ(SZMAX_VKDICTIONARYNAME + 2, u16len(str)); EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + // virtual key, not in VKeyNames, version too low, ERROR_InvalidToken (this should be ERROR_90FeatureOnlyVirtualKeyDictionary) + fileKeyboard.version = VERSION_80; + u16cpy(str, u"[abc]"); + EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + + // virtual key, not in VKeyNames, valid + fileKeyboard.version = VERSION_90; + u16cpy(str, u"[abc]"); + EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + tstr_virtual_key_valid[2] = ISVIRTUALKEY; + tstr_virtual_key_valid[3] = 256; //VK_MAX + 1 + EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); + EXPECT_EQ(0, u16cmp(u"abc", fileKeyboard.dpVKDictionary[0].szName)); + tstr_virtual_key_valid[3] = 65; + fileKeyboard.cxVKDictionary = 0; + fileKeyboard.dpVKDictionary[0].szName[0] = 0; + + // virtual key, not in VKeyNames, pre-existing name, valid + fileKeyboard.version = VERSION_90; + fileKeyboard.cxVKDictionary = 3; + u16cpy(fileKeyboard.dpVKDictionary[0].szName, u"abc"); + u16cpy(fileKeyboard.dpVKDictionary[1].szName, u"def"); + u16cpy(fileKeyboard.dpVKDictionary[2].szName, u"ghi"); + u16cpy(str, u"[def]"); + EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + tstr_virtual_key_valid[2] = ISVIRTUALKEY; + tstr_virtual_key_valid[3] = 257; //VK_MAX + 2 + EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); + tstr_virtual_key_valid[3] = 65; + fileKeyboard.cxVKDictionary = 0; + fileKeyboard.dpVKDictionary[0].szName[0] = 0; + fileKeyboard.dpVKDictionary[1].szName[0] = 0; + fileKeyboard.dpVKDictionary[2].szName[0] = 0; } // KMX_DWORD process_baselayout(PFILE_KEYBOARD fk, PKMX_WCHAR q, PKMX_WCHAR tstr, int *mx) From 4b30cc9f3f867f4b68a8c181ef8de067942bfb7e Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 24 Oct 2024 12:29:02 +0100 Subject: [PATCH 24/28] chore(developer): added virtual key names to initVKDictionary() --- .../kmcmplib/tests/gtest-compiler-test.cpp | 36 ++++++++----------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index fbb70793e1..fbb58ab349 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -121,12 +121,12 @@ class CompilerTest : public testing::Test { } } - void initVKDictionary(FILE_KEYBOARD &fk) { + void initVKDictionary(FILE_KEYBOARD &fk, std::vector names) { fk.dpVKDictionary = new FILE_VKDICTIONARY[10]; - fk.cxVKDictionary = 0; + fk.cxVKDictionary = names.size(); - for (KMX_DWORD i=0; i<10; i++) { - fk.dpVKDictionary[i].szName[0] = 0; + for (KMX_DWORD i=0; i Date: Thu, 24 Oct 2024 12:40:21 +0100 Subject: [PATCH 25/28] chore(developer): some clarification of comments on test cases for custom name virtual keys --- developer/src/kmcmplib/tests/gtest-compiler-test.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index fbb58ab349..dcd2609690 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -1918,7 +1918,7 @@ TEST_F(CompilerTest, GetXStringImpl_type_osb_test) { EXPECT_EQ(KmnCompilerMessages::WARN_VirtualCharKeyWithPositionalLayout, msgproc_errors[0].errorCode); msgproc_errors.clear(); - // virtual key, not in VKeyNames, long, but not too long name, valid + // virtual key, custom name, long, but not too long name, valid fileKeyboard.version = VERSION_90; u16cpy(str, u"[XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX]"); // SZMAX_VKDICTIONARYNAME - 1 EXPECT_EQ(SZMAX_VKDICTIONARYNAME - 1 + 2, u16len(str)); @@ -1930,18 +1930,18 @@ TEST_F(CompilerTest, GetXStringImpl_type_osb_test) { fileKeyboard.cxVKDictionary = 3; fileKeyboard.dpVKDictionary[3].szName[0] = 0; - // virtual key, not in VKeyNames, name too long, ERROR_InvalidToken + // virtual key, custom name, name too long, ERROR_InvalidToken fileKeyboard.version = VERSION_90; u16cpy(str, u"[XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX]"); // SZMAX_VKDICTIONARYNAME EXPECT_EQ(SZMAX_VKDICTIONARYNAME + 2, u16len(str)); EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); - // virtual key, not in VKeyNames, version too low, ERROR_InvalidToken (this should be ERROR_90FeatureOnlyVirtualKeyDictionary) + // virtual key, custom name, version too low, ERROR_InvalidToken (this should be ERROR_90FeatureOnlyVirtualKeyDictionary) fileKeyboard.version = VERSION_80; u16cpy(str, u"[abc]"); EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); - // virtual key, not in VKeyNames, valid + // virtual key, custom name, valid fileKeyboard.version = VERSION_90; u16cpy(str, u"[jkl]"); EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); @@ -1953,7 +1953,7 @@ TEST_F(CompilerTest, GetXStringImpl_type_osb_test) { fileKeyboard.cxVKDictionary = 3; fileKeyboard.dpVKDictionary[3].szName[0] = 0; - // virtual key, not in VKeyNames, pre-existing name, valid + // virtual key, custom name, pre-existing name, valid fileKeyboard.version = VERSION_90; u16cpy(str, u"[def]"); EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); From 2da8f7b17b006610320c6a74a02f3e25e42da2ee Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Tue, 29 Oct 2024 13:13:49 +0000 Subject: [PATCH 26/28] chore(developer): add two test cases for VKeyMayBeVCKey when FMnemonicLayout is set --- .../kmcmplib/tests/gtest-compiler-test.cpp | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index dcd2609690..b0c3e0fa00 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -4,6 +4,7 @@ #include "../include/kmcmplibapi.h" #include "../src/compfile.h" #include "../src/CompilerErrors.h" +#include "../src/virtualcharkeys.h" #include "../../common/include/kmn_compiler_errors.h" #include "../../../../common/include/km_types.h" #include "../../../../common/include/kmx_file.h" @@ -1821,7 +1822,7 @@ TEST_F(CompilerTest, GetXStringImpl_type_osb_test) { // u16cpy(str, u"[CTRL_K_A]"); // EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); // tstr_virtual_key_valid[2] = ISVIRTUALKEY | K_CTRLFLAG; - // tstr_virtual_key_valid[3] = 259; //VK_MAX + 4 + // tstr_virtual_key_valid[3] = 259; // VK__MAX + 4 // EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); // EXPECT_EQ(0, msgproc_errors.size()); // tstr_virtual_key_valid[3] = 65; @@ -1924,7 +1925,7 @@ TEST_F(CompilerTest, GetXStringImpl_type_osb_test) { EXPECT_EQ(SZMAX_VKDICTIONARYNAME - 1 + 2, u16len(str)); EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); tstr_virtual_key_valid[2] = ISVIRTUALKEY; - tstr_virtual_key_valid[3] = 259; //VK_MAX + 4 + tstr_virtual_key_valid[3] = 259; // VK__MAX + 4 EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); tstr_virtual_key_valid[3] = 65; fileKeyboard.cxVKDictionary = 3; @@ -1946,7 +1947,7 @@ TEST_F(CompilerTest, GetXStringImpl_type_osb_test) { u16cpy(str, u"[jkl]"); EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); tstr_virtual_key_valid[2] = ISVIRTUALKEY; - tstr_virtual_key_valid[3] = 259; //VK_MAX + 4 + tstr_virtual_key_valid[3] = 259; // VK__MAX + 4 EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); EXPECT_EQ(0, u16cmp(u"jkl", fileKeyboard.dpVKDictionary[3].szName)); tstr_virtual_key_valid[3] = 65; @@ -1958,9 +1959,33 @@ TEST_F(CompilerTest, GetXStringImpl_type_osb_test) { u16cpy(str, u"[def]"); EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); tstr_virtual_key_valid[2] = ISVIRTUALKEY; - tstr_virtual_key_valid[3] = 257; //VK_MAX + 2 + tstr_virtual_key_valid[3] = 257; // VK__MAX + 2 EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); tstr_virtual_key_valid[3] = 65; + + // virtual key, in VKeyNames, kmcmp::FMnemonicLayout true, VKeyMayBeVCKey false, valid + fileKeyboard.version = VERSION_90; + kmcmp::FMnemonicLayout = TRUE; + EXPECT_EQ(FALSE, VKeyMayBeVCKey[9]); // K_TAB + u16cpy(str, u"[K_TAB]"); + EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + tstr_virtual_key_valid[2] = ISVIRTUALKEY; + tstr_virtual_key_valid[3] = 9; // K_TAB + EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); + EXPECT_EQ(0, msgproc_errors.size()); + tstr_virtual_key_valid[3] = 65; + + // virtual key, in VKeyNames, kmcmp::FMnemonicLayout true, VKeyMayBeVCKey true, KmnCompilerMessages::WARN_VirtualKeyWithMnemonicLayout + fileKeyboard.version = VERSION_90; + kmcmp::FMnemonicLayout = TRUE; + EXPECT_EQ(TRUE, VKeyMayBeVCKey[65]); // K_A + u16cpy(str, u"[K_A]"); + EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + tstr_virtual_key_valid[2] = ISVIRTUALKEY; + EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); + EXPECT_EQ(1, msgproc_errors.size()); + EXPECT_EQ(KmnCompilerMessages::WARN_VirtualKeyWithMnemonicLayout, msgproc_errors[0].errorCode); + msgproc_errors.clear(); } // KMX_DWORD process_baselayout(PFILE_KEYBOARD fk, PKMX_WCHAR q, PKMX_WCHAR tstr, int *mx) From feb7c51f8ff4aa600c8bc0b3bdb41ca70e881124 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Tue, 29 Oct 2024 13:20:20 +0000 Subject: [PATCH 27/28] chore(developer): four additional test cases with spaces around the names of custom virtual keys --- .../kmcmplib/tests/gtest-compiler-test.cpp | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index b0c3e0fa00..9f34faa156 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -1954,6 +1954,30 @@ TEST_F(CompilerTest, GetXStringImpl_type_osb_test) { fileKeyboard.cxVKDictionary = 3; fileKeyboard.dpVKDictionary[3].szName[0] = 0; + // virtual key, custom name, space before, valid + fileKeyboard.version = VERSION_90; + u16cpy(str, u"[ jkl]"); + EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + tstr_virtual_key_valid[2] = ISVIRTUALKEY; + tstr_virtual_key_valid[3] = 259; // VK__MAX + 4 + EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); + EXPECT_EQ(0, u16cmp(u"jkl", fileKeyboard.dpVKDictionary[3].szName)); + tstr_virtual_key_valid[3] = 65; + fileKeyboard.cxVKDictionary = 3; + fileKeyboard.dpVKDictionary[3].szName[0] = 0; + + // virtual key, custom name, space after, valid + fileKeyboard.version = VERSION_90; + u16cpy(str, u"[jkl ]"); + EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + tstr_virtual_key_valid[2] = ISVIRTUALKEY; + tstr_virtual_key_valid[3] = 259; // VK__MAX + 4 + EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); + EXPECT_EQ(0, u16cmp(u"jkl", fileKeyboard.dpVKDictionary[3].szName)); + tstr_virtual_key_valid[3] = 65; + fileKeyboard.cxVKDictionary = 3; + fileKeyboard.dpVKDictionary[3].szName[0] = 0; + // virtual key, custom name, pre-existing name, valid fileKeyboard.version = VERSION_90; u16cpy(str, u"[def]"); @@ -1963,6 +1987,24 @@ TEST_F(CompilerTest, GetXStringImpl_type_osb_test) { EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); tstr_virtual_key_valid[3] = 65; + // virtual key, custom name, pre-existing name, space before, valid + fileKeyboard.version = VERSION_90; + u16cpy(str, u"[ def]"); + EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + tstr_virtual_key_valid[2] = ISVIRTUALKEY; + tstr_virtual_key_valid[3] = 257; // VK__MAX + 2 + EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); + tstr_virtual_key_valid[3] = 65; + + // virtual key, custom name, pre-existing name, space after, valid + fileKeyboard.version = VERSION_90; + u16cpy(str, u"[def ]"); + EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + tstr_virtual_key_valid[2] = ISVIRTUALKEY; + tstr_virtual_key_valid[3] = 257; // VK__MAX + 2 + EXPECT_EQ(0, u16cmp(tstr_virtual_key_valid, tstr)); + tstr_virtual_key_valid[3] = 65; + // virtual key, in VKeyNames, kmcmp::FMnemonicLayout true, VKeyMayBeVCKey false, valid fileKeyboard.version = VERSION_90; kmcmp::FMnemonicLayout = TRUE; From 8ac4267ce3dc2ced667428da9c8914972b21bafc Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Tue, 29 Oct 2024 14:13:36 +0000 Subject: [PATCH 28/28] chore(developer): added commented-out unit test for multiple grouped virtual keys (see #12307) --- .../src/kmcmplib/tests/gtest-compiler-test.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index 9f34faa156..e6a5a0f513 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -1807,17 +1807,17 @@ TEST_F(CompilerTest, GetXStringImpl_type_osb_test) { u16cpy(str, u"[CTRL ALT]"); EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); - // virtual key, in VKeyNames, no space between modifier and key portion, ERROR_InvalidToken + // virtual key, in VKeyNames, no space between modifier and key portion, ERROR_InvalidToken (see #12307) // fileKeyboard.version = VERSION_90; // u16cpy(str, u"[CTRLK_A]"); // EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); - // virtual key, in VKeyNames, no space between modifiers, ERROR_InvalidToken + // virtual key, in VKeyNames, no space between modifiers, ERROR_InvalidToken (see #12307) // fileKeyboard.version = VERSION_90; // u16cpy(str, u"[CTRLALT K_A]"); // EXPECT_EQ(KmnCompilerMessages::ERROR_InvalidToken, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); - // virtual key, '_' between modifier and key portion', ERROR_InvalidToken + // virtual key, '_' between modifier and key portion', ERROR_InvalidToken (see #12307) // fileKeyboard.version = VERSION_90; // u16cpy(str, u"[CTRL_K_A]"); // EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); @@ -2028,6 +2028,14 @@ TEST_F(CompilerTest, GetXStringImpl_type_osb_test) { EXPECT_EQ(1, msgproc_errors.size()); EXPECT_EQ(KmnCompilerMessages::WARN_VirtualKeyWithMnemonicLayout, msgproc_errors[0].errorCode); msgproc_errors.clear(); + + // virtual key, in VKeyNames, multiple keys, valid (see #12307) + // fileKeyboard.version = VERSION_90; + // u16cpy(str, u"[K_A K_B K_C]"); + // EXPECT_EQ(STATUS_Success, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); + // sFlag = ISVIRTUALKEY; + // KMX_WCHAR tstr_virtual_key_multi_valid[] = { UC_SENTINEL, CODE_EXTENDED, sFlag, 65, 66, 67, UC_SENTINEL_EXTENDEDEND, 0 }; + // EXPECT_EQ(0, u16cmp(tstr_virtual_key_multi_valid, tstr)); } // KMX_DWORD process_baselayout(PFILE_KEYBOARD fk, PKMX_WCHAR q, PKMX_WCHAR tstr, int *mx)