From 8738ee368197cdae77e825892d33e43387f85e34 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Wed, 19 Jun 2024 11:30:29 +0100 Subject: [PATCH] fix(developer): rename isuiw() to isIntegerWString() --- developer/src/kmcmplib/src/Compiler.cpp | 6 +++--- .../kmcmplib/tests/gtest-compiler-test.cpp | 20 +++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/developer/src/kmcmplib/src/Compiler.cpp b/developer/src/kmcmplib/src/Compiler.cpp index 77ecd00952..85412aedb1 100644 --- a/developer/src/kmcmplib/src/Compiler.cpp +++ b/developer/src/kmcmplib/src/Compiler.cpp @@ -134,7 +134,7 @@ namespace kmcmp{ int xatoi(PKMX_WCHAR *p); int atoiW(PKMX_WCHAR p); -bool isuiw(PKMX_WCHAR p); +bool isIntegerWstring(PKMX_WCHAR p); void safe_wcsncpy(PKMX_WCHAR out, PKMX_WCHAR in, int cbMax); int GetDeadKey(PFILE_KEYBOARD fk, PKMX_WCHAR p); @@ -2015,7 +2015,7 @@ KMX_DWORD GetXStringImpl(PKMX_WCHAR tstr, PFILE_KEYBOARD fk, PKMX_WCHAR str, KMX kmcmp::CheckStoreUsage(fk, i, TRUE, FALSE, FALSE); r = u16tok(NULL, p_sep_com, &context); // I3481 - if (!r || !*r || !isuiw(r)) return CERR_InvalidIndex; + if (!r || !*r || !isIntegerWstring(r)) return CERR_InvalidIndex; } tstr[mx++] = UC_SENTINEL; tstr[mx++] = CODE_INDEX; @@ -3363,7 +3363,7 @@ int atoiW(PKMX_WCHAR p) return i; } -bool isuiw(PKMX_WCHAR p) { +bool isIntegerWstring(PKMX_WCHAR p) { if (!p || !*p) return false; PKMX_STR q = wstrtostr(p); diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index 89ea856ddd..fd48244a6a 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -1,4 +1,5 @@ #include +#include #include "../include/kmcompx.h" #include "../include/kmcmplibapi.h" #include "../src/kmx_u16.h" @@ -18,7 +19,7 @@ KMX_DWORD GetXStringImpl(PKMX_WCHAR tstr, PFILE_KEYBOARD fk, PKMX_WCHAR str, KMX PKMX_WCHAR output, int max, int offset, PKMX_WCHAR *newp, int isUnicode ); KMX_DWORD GetRHS(PFILE_KEYBOARD fk, PKMX_WCHAR p, PKMX_WCHAR buf, int bufsize, int offset, int IsUnicode); -bool isuiw(PKMX_WCHAR p); +bool isIntegerWstring(PKMX_WCHAR p); bool hasPreamble(std::u16string result); extern kmcmp_CompilerMessageProc msgproc; @@ -514,13 +515,16 @@ TEST_F(CompilerTest, GetRHS_test) { // int atoiW(PKMX_WCHAR p) // KMX_DWORD kmcmp::CheckUTF16(int n) -TEST_F(CompilerTest, isuiw_test) { - EXPECT_FALSE(isuiw(nullptr)); - EXPECT_FALSE(isuiw((PKMX_WCHAR)u"")); - EXPECT_FALSE(isuiw((PKMX_WCHAR)u"a")); - EXPECT_FALSE(isuiw((PKMX_WCHAR)u"-1")); - EXPECT_TRUE(isuiw((PKMX_WCHAR)u"1")); - EXPECT_TRUE(isuiw((PKMX_WCHAR)u"42")); +TEST_F(CompilerTest, isIntegerWstring_test) { + EXPECT_FALSE(isIntegerWstring(nullptr)); + EXPECT_FALSE(isIntegerWstring((PKMX_WCHAR)u"")); + EXPECT_FALSE(isIntegerWstring((PKMX_WCHAR)u"a")); + EXPECT_FALSE(isIntegerWstring((PKMX_WCHAR)u"-1")); + EXPECT_TRUE(isIntegerWstring((PKMX_WCHAR)u"1")); + EXPECT_TRUE(isIntegerWstring((PKMX_WCHAR)u"42")); + //EXPECT_TRUE(isIntegerWstring((PKMX_WCHAR)u"2147483647")); // INT_MAX + //EXPECT_FALSE(isIntegerWstring((PKMX_WCHAR)u"2147483648")); // INT_MAX + 1 + //EXPECT_FALSE(isIntegerWstring((PKMX_WCHAR)u"9999999999")); // > INT_MAX } // KMX_DWORD kmcmp::UTF32ToUTF16(int n, int *n1, int *n2)