From 3ea80a88d6586eae29ba39e8d09bcfc2fd55ea99 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 18 Jul 2024 11:52:57 +0100 Subject: [PATCH] fix(developer): add LineTokenType test and initial three test cases --- .../kmcmplib/tests/gtest-compiler-test.cpp | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index d8482ebe1d..ccaa1e2106 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -14,6 +14,7 @@ KMX_BOOL AddCompileError(KMX_DWORD msg); KMX_DWORD ProcessBeginLine(PFILE_KEYBOARD fk, PKMX_WCHAR p); KMX_DWORD ValidateMatchNomatchOutput(PKMX_WCHAR p); KMX_BOOL IsValidKeyboardVersion(KMX_WCHAR *dpString); +int LineTokenType(PKMX_WCHAR *str); KMX_DWORD GetXStringImpl(PKMX_WCHAR tstr, PFILE_KEYBOARD fk, PKMX_WCHAR str, KMX_WCHAR const * token, PKMX_WCHAR output, int max, int offset, PKMX_WCHAR *newp, int isUnicode ); @@ -29,6 +30,7 @@ namespace kmcmp { extern int nErrors; extern int ErrChr; extern int BeginLine[4]; + extern int CompileTarget; KMX_BOOL AddCompileWarning(char* buf); } @@ -59,6 +61,7 @@ class CompilerTest : public testing::Test { kmcmp::BeginLine[BEGIN_UNICODE] = -1; kmcmp::BeginLine[BEGIN_NEWCONTEXT] = -1; kmcmp::BeginLine[BEGIN_POSTKEYSTROKE] = -1; + kmcmp::CompileTarget = CKF_KEYMAN; } void initFileKeyboard(FILE_KEYBOARD &fk) { @@ -313,7 +316,29 @@ TEST_F(CompilerTest, ProcessKeyLineImpl_test) { // KMX_DWORD ExpandKp(PFILE_KEYBOARD fk, PFILE_KEY kpp, KMX_DWORD storeIndex) // PKMX_WCHAR GetDelimitedString(PKMX_WCHAR *p, KMX_WCHAR const * Delimiters, KMX_WORD Flags) // LinePrefixType GetLinePrefixType(PKMX_WCHAR *p) -// int LineTokenType(PKMX_WCHAR *str) + +TEST_F(CompilerTest, LineTokenType_test) { + KMX_WCHAR str[LINESIZE]; + PKMX_WCHAR p = nullptr; + + // T_BLANK, lptOther, empty string + u16cpy(str, u""); + p = str; + EXPECT_EQ(T_BLANK, LineTokenType(&p)); + + // T_BLANK, CKF_KEYMAN, lptKeymanWebOnly + u16cpy(str, u"$keymanweb:"); + p = str; + kmcmp::CompileTarget = CKF_KEYMAN; + EXPECT_EQ(T_BLANK, LineTokenType(&p)); + + // T_BLANK, CKF_KEYMANWEB, lptKeymanOnly + u16cpy(str, u"$keymanonly:"); + p = str; + kmcmp::CompileTarget = CKF_KEYMANWEB; + EXPECT_EQ(T_BLANK, LineTokenType(&p)); +} + // KMX_BOOL StrValidChrs(PKMX_WCHAR q, KMX_WCHAR const * chrs) // KMX_DWORD GetXString(PFILE_KEYBOARD fk, PKMX_WCHAR str, KMX_WCHAR const * token, // PKMX_WCHAR output, int max, int offset, PKMX_WCHAR *newp, int /*isVKey*/, int isUnicode