Reactos

[CRT_APITEST] Implement tests for _wcsicmp and _wcsnicmp

+126
+53
modules/rostests/apitests/crt/_wcsicmp.c
··· 1 + /* 2 + * PROJECT: ReactOS API tests 3 + * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later) 4 + * PURPOSE: Tests for _wcsicmp 5 + * COPYRIGHT: Copyright 2025 Timo Kreuzer (timo.kreuzer@reactos.org) 6 + */ 7 + 8 + #define WIN32_NO_STATUS 9 + #include <apitest.h> 10 + #include <pseh/pseh2.h> 11 + #include <ndk/umtypes.h> 12 + 13 + typedef int (__cdecl *PFN_wcsicmp)(const wchar_t* _String1, const wchar_t* _String2); 14 + static PFN_wcsicmp p_wcsicmp; 15 + 16 + static BOOL Init(void) 17 + { 18 + HMODULE hdll = LoadLibraryA(TEST_DLL_NAME); 19 + p_wcsicmp = (PFN_wcsicmp)GetProcAddress(hdll, "_wcsicmp"); 20 + ok(p_wcsicmp != NULL, "Failed to load _wcsicmp from %s\n", TEST_DLL_NAME); 21 + return (p_wcsicmp != NULL); 22 + } 23 + 24 + START_TEST(_wcsicmp) 25 + { 26 + int result; 27 + 28 + #ifndef TEST_STATIC_CRT 29 + if (!Init()) 30 + { 31 + skip("Skipping tests, because _wcsicmp is not available\n"); 32 + return; 33 + } 34 + #endif 35 + 36 + StartSeh() 37 + result = p_wcsicmp(L"a", NULL); 38 + ok_int(result, MAXLONG); 39 + #ifdef TEST_NTDLL 40 + EndSeh(STATUS_ACCESS_VIOLATION); 41 + #else 42 + EndSeh((is_reactos() || _winver >= _WIN32_WINNT_VISTA) ? STATUS_SUCCESS : STATUS_ACCESS_VIOLATION); 43 + #endif 44 + 45 + StartSeh() 46 + result = p_wcsicmp(NULL, L"a"); 47 + ok_int(result, MAXLONG); 48 + #ifdef TEST_NTDLL 49 + EndSeh(STATUS_ACCESS_VIOLATION); 50 + #else 51 + EndSeh((is_reactos() || _winver >= _WIN32_WINNT_VISTA) ? STATUS_SUCCESS : STATUS_ACCESS_VIOLATION); 52 + #endif 53 + }
+61
modules/rostests/apitests/crt/_wcsnicmp.c
··· 1 + /* 2 + * PROJECT: ReactOS API tests 3 + * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later) 4 + * PURPOSE: Tests for _wcsnicmp 5 + * COPYRIGHT: Copyright 2025 Timo Kreuzer (timo.kreuzer@reactos.org) 6 + */ 7 + 8 + #define WIN32_NO_STATUS 9 + #include <apitest.h> 10 + #include <pseh/pseh2.h> 11 + #include <ndk/umtypes.h> 12 + 13 + typedef int (__cdecl *PFN_wcsnicmp)(const wchar_t* _String1, const wchar_t* _String2, size_t _MaxCount); 14 + static PFN_wcsnicmp p_wcsnicmp; 15 + 16 + static BOOL Init(void) 17 + { 18 + HMODULE hdll = LoadLibraryA(TEST_DLL_NAME); 19 + p_wcsnicmp = (PFN_wcsnicmp)GetProcAddress(hdll, "_wcsnicmp"); 20 + ok(p_wcsnicmp != NULL, "Failed to load _wcsnicmp from %s\n", TEST_DLL_NAME); 21 + return (p_wcsnicmp != NULL); 22 + } 23 + 24 + START_TEST(_wcsnicmp) 25 + { 26 + int result; 27 + 28 + #ifndef TEST_STATIC_CRT 29 + if (!Init()) 30 + { 31 + skip("Skipping tests, because _wcsnicmp is not available\n"); 32 + return; 33 + } 34 + #endif 35 + 36 + StartSeh() 37 + result = p_wcsnicmp(L"a", NULL, 0); 38 + EndSeh(STATUS_SUCCESS); 39 + 40 + StartSeh() 41 + result = p_wcsnicmp(L"a", NULL, 1); 42 + ok_int(result, MAXLONG); 43 + #ifdef TEST_NTDLL 44 + EndSeh(STATUS_ACCESS_VIOLATION); 45 + #else 46 + EndSeh((is_reactos() || GetNTVersion() >= _WIN32_WINNT_VISTA) ? STATUS_SUCCESS : STATUS_ACCESS_VIOLATION); 47 + #endif 48 + 49 + StartSeh() 50 + result = p_wcsnicmp(NULL, L"a", 0); 51 + EndSeh(STATUS_SUCCESS); 52 + 53 + StartSeh() 54 + result = p_wcsnicmp(NULL, L"a", 1); 55 + ok_int(result, MAXLONG); 56 + #ifdef TEST_NTDLL 57 + EndSeh(STATUS_ACCESS_VIOLATION); 58 + #else 59 + EndSeh((is_reactos() || GetNTVersion() >= _WIN32_WINNT_VISTA) ? STATUS_SUCCESS : STATUS_ACCESS_VIOLATION); 60 + #endif 61 + }
+2
modules/rostests/apitests/msvcrt/CMakeLists.txt
··· 22 22 ../crt/_vscwprintf.c 23 23 ../crt/_vsnprintf.c 24 24 ../crt/_vsnwprintf.c 25 + ../crt/_wcsicmp.c 26 + ../crt/_wcsnicmp.c 25 27 ../crt/_wsystem.c 26 28 ../crt/acos.c 27 29 ../crt/asin.c
+4
modules/rostests/apitests/msvcrt/testlist.c
··· 16 16 extern void func__vscwprintf(void); 17 17 extern void func__vsnprintf(void); 18 18 extern void func__vsnwprintf(void); 19 + extern void func__wcsicmp(void); 20 + extern void func__wcsnicmp(void); 19 21 extern void func__wsystem(void); 20 22 extern void func_acos(void); 21 23 extern void func_asin(void); ··· 76 78 { "_vscwprintf", func__vscwprintf }, 77 79 { "_vsnprintf", func__vsnprintf }, 78 80 { "_vsnwprintf", func__vsnwprintf }, 81 + { "_wcsicmp", func__wcsicmp }, 82 + { "_wcsnicmp", func__wcsnicmp }, 79 83 { "_wsystem", func__wsystem }, 80 84 { "acos", func_acos }, 81 85 { "asin", func_asin },
+2
modules/rostests/apitests/ntdll/CMakeLists.txt
··· 15 15 ../crt/_vscwprintf.c 16 16 ../crt/_vsnprintf.c 17 17 ../crt/_vsnwprintf.c 18 + ../crt/_wcsicmp.c 19 + ../crt/_wcsnicmp.c 18 20 ../crt/mbstowcs.c 19 21 ../crt/setjmp.c 20 22 ../crt/sprintf.c
+4
modules/rostests/apitests/ntdll/testlist.c
··· 9 9 extern void func__vscwprintf(void); 10 10 extern void func__vsnprintf(void); 11 11 extern void func__vsnwprintf(void); 12 + extern void func__wcsicmp(void); 13 + extern void func__wcsnicmp(void); 12 14 extern void func_mbstowcs(void); 13 15 extern void func_setjmp(void); 14 16 extern void func_sprintf(void); ··· 136 138 { "_vscwprintf", func__vscwprintf }, 137 139 { "_vsnprintf", func__vsnprintf }, 138 140 { "_vsnwprintf", func__vsnwprintf }, 141 + { "_wcsicmp", func__wcsicmp }, 142 + { "_wcsnicmp", func__wcsnicmp }, 139 143 { "mbstowcs", func_mbstowcs }, 140 144 { "setjmp", func_setjmp }, 141 145 { "sprintf", func_sprintf },