From ae3eb6cb3645edda881c16887fc6621ac9a930ef Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Fri, 24 Oct 2025 08:53:21 +0300 Subject: [PATCH] [CRT_APITEST] Implement tests for _wcsicmp and _wcsnicmp --- modules/rostests/apitests/crt/_wcsicmp.c | 53 ++++++++++++++++ modules/rostests/apitests/crt/_wcsnicmp.c | 61 +++++++++++++++++++ .../rostests/apitests/msvcrt/CMakeLists.txt | 2 + modules/rostests/apitests/msvcrt/testlist.c | 4 ++ .../rostests/apitests/ntdll/CMakeLists.txt | 2 + modules/rostests/apitests/ntdll/testlist.c | 4 ++ 6 files changed, 126 insertions(+) create mode 100644 modules/rostests/apitests/crt/_wcsicmp.c create mode 100644 modules/rostests/apitests/crt/_wcsnicmp.c diff --git a/modules/rostests/apitests/crt/_wcsicmp.c b/modules/rostests/apitests/crt/_wcsicmp.c new file mode 100644 index 00000000000..82b5bd1943e --- /dev/null +++ b/modules/rostests/apitests/crt/_wcsicmp.c @@ -0,0 +1,53 @@ +/* + * PROJECT: ReactOS API tests + * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later) + * PURPOSE: Tests for _wcsicmp + * COPYRIGHT: Copyright 2025 Timo Kreuzer (timo.kreuzer@reactos.org) + */ + +#define WIN32_NO_STATUS +#include +#include +#include + +typedef int (__cdecl *PFN_wcsicmp)(const wchar_t* _String1, const wchar_t* _String2); +static PFN_wcsicmp p_wcsicmp; + +static BOOL Init(void) +{ + HMODULE hdll = LoadLibraryA(TEST_DLL_NAME); + p_wcsicmp = (PFN_wcsicmp)GetProcAddress(hdll, "_wcsicmp"); + ok(p_wcsicmp != NULL, "Failed to load _wcsicmp from %s\n", TEST_DLL_NAME); + return (p_wcsicmp != NULL); +} + +START_TEST(_wcsicmp) +{ + int result; + +#ifndef TEST_STATIC_CRT + if (!Init()) + { + skip("Skipping tests, because _wcsicmp is not available\n"); + return; + } +#endif + + StartSeh() + result = p_wcsicmp(L"a", NULL); + ok_int(result, MAXLONG); +#ifdef TEST_NTDLL + EndSeh(STATUS_ACCESS_VIOLATION); +#else + EndSeh((is_reactos() || _winver >= _WIN32_WINNT_VISTA) ? STATUS_SUCCESS : STATUS_ACCESS_VIOLATION); +#endif + + StartSeh() + result = p_wcsicmp(NULL, L"a"); + ok_int(result, MAXLONG); +#ifdef TEST_NTDLL + EndSeh(STATUS_ACCESS_VIOLATION); +#else + EndSeh((is_reactos() || _winver >= _WIN32_WINNT_VISTA) ? STATUS_SUCCESS : STATUS_ACCESS_VIOLATION); +#endif +} diff --git a/modules/rostests/apitests/crt/_wcsnicmp.c b/modules/rostests/apitests/crt/_wcsnicmp.c new file mode 100644 index 00000000000..03cf67731f2 --- /dev/null +++ b/modules/rostests/apitests/crt/_wcsnicmp.c @@ -0,0 +1,61 @@ +/* + * PROJECT: ReactOS API tests + * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later) + * PURPOSE: Tests for _wcsnicmp + * COPYRIGHT: Copyright 2025 Timo Kreuzer (timo.kreuzer@reactos.org) + */ + +#define WIN32_NO_STATUS +#include +#include +#include + +typedef int (__cdecl *PFN_wcsnicmp)(const wchar_t* _String1, const wchar_t* _String2, size_t _MaxCount); +static PFN_wcsnicmp p_wcsnicmp; + +static BOOL Init(void) +{ + HMODULE hdll = LoadLibraryA(TEST_DLL_NAME); + p_wcsnicmp = (PFN_wcsnicmp)GetProcAddress(hdll, "_wcsnicmp"); + ok(p_wcsnicmp != NULL, "Failed to load _wcsnicmp from %s\n", TEST_DLL_NAME); + return (p_wcsnicmp != NULL); +} + +START_TEST(_wcsnicmp) +{ + int result; + +#ifndef TEST_STATIC_CRT + if (!Init()) + { + skip("Skipping tests, because _wcsnicmp is not available\n"); + return; + } +#endif + + StartSeh() + result = p_wcsnicmp(L"a", NULL, 0); + EndSeh(STATUS_SUCCESS); + + StartSeh() + result = p_wcsnicmp(L"a", NULL, 1); + ok_int(result, MAXLONG); +#ifdef TEST_NTDLL + EndSeh(STATUS_ACCESS_VIOLATION); +#else + EndSeh((is_reactos() || GetNTVersion() >= _WIN32_WINNT_VISTA) ? STATUS_SUCCESS : STATUS_ACCESS_VIOLATION); +#endif + + StartSeh() + result = p_wcsnicmp(NULL, L"a", 0); + EndSeh(STATUS_SUCCESS); + + StartSeh() + result = p_wcsnicmp(NULL, L"a", 1); + ok_int(result, MAXLONG); +#ifdef TEST_NTDLL + EndSeh(STATUS_ACCESS_VIOLATION); +#else + EndSeh((is_reactos() || GetNTVersion() >= _WIN32_WINNT_VISTA) ? STATUS_SUCCESS : STATUS_ACCESS_VIOLATION); +#endif +} diff --git a/modules/rostests/apitests/msvcrt/CMakeLists.txt b/modules/rostests/apitests/msvcrt/CMakeLists.txt index a84b08e2090..97baa30b341 100644 --- a/modules/rostests/apitests/msvcrt/CMakeLists.txt +++ b/modules/rostests/apitests/msvcrt/CMakeLists.txt @@ -22,6 +22,8 @@ list(APPEND SOURCE_CRT_TESTS ../crt/_vscwprintf.c ../crt/_vsnprintf.c ../crt/_vsnwprintf.c + ../crt/_wcsicmp.c + ../crt/_wcsnicmp.c ../crt/_wsystem.c ../crt/acos.c ../crt/asin.c diff --git a/modules/rostests/apitests/msvcrt/testlist.c b/modules/rostests/apitests/msvcrt/testlist.c index d3a73ce5e7c..b13cd69d1c2 100644 --- a/modules/rostests/apitests/msvcrt/testlist.c +++ b/modules/rostests/apitests/msvcrt/testlist.c @@ -16,6 +16,8 @@ extern void func__vscprintf(void); extern void func__vscwprintf(void); extern void func__vsnprintf(void); extern void func__vsnwprintf(void); +extern void func__wcsicmp(void); +extern void func__wcsnicmp(void); extern void func__wsystem(void); extern void func_acos(void); extern void func_asin(void); @@ -76,6 +78,8 @@ const struct test winetest_testlist[] = { "_vscwprintf", func__vscwprintf }, { "_vsnprintf", func__vsnprintf }, { "_vsnwprintf", func__vsnwprintf }, + { "_wcsicmp", func__wcsicmp }, + { "_wcsnicmp", func__wcsnicmp }, { "_wsystem", func__wsystem }, { "acos", func_acos }, { "asin", func_asin }, diff --git a/modules/rostests/apitests/ntdll/CMakeLists.txt b/modules/rostests/apitests/ntdll/CMakeLists.txt index 639d6438376..02545dc669b 100644 --- a/modules/rostests/apitests/ntdll/CMakeLists.txt +++ b/modules/rostests/apitests/ntdll/CMakeLists.txt @@ -15,6 +15,8 @@ list(APPEND SOURCE_CRT_TESTS ../crt/_vscwprintf.c ../crt/_vsnprintf.c ../crt/_vsnwprintf.c + ../crt/_wcsicmp.c + ../crt/_wcsnicmp.c ../crt/mbstowcs.c ../crt/setjmp.c ../crt/sprintf.c diff --git a/modules/rostests/apitests/ntdll/testlist.c b/modules/rostests/apitests/ntdll/testlist.c index 6bd0f932fd3..3801defbb99 100644 --- a/modules/rostests/apitests/ntdll/testlist.c +++ b/modules/rostests/apitests/ntdll/testlist.c @@ -9,6 +9,8 @@ extern void func__strnicmp(void); extern void func__vscwprintf(void); extern void func__vsnprintf(void); extern void func__vsnwprintf(void); +extern void func__wcsicmp(void); +extern void func__wcsnicmp(void); extern void func_mbstowcs(void); extern void func_setjmp(void); extern void func_sprintf(void); @@ -136,6 +138,8 @@ const struct test winetest_testlist[] = { "_vscwprintf", func__vscwprintf }, { "_vsnprintf", func__vsnprintf }, { "_vsnwprintf", func__vsnwprintf }, + { "_wcsicmp", func__wcsicmp }, + { "_wcsnicmp", func__wcsnicmp }, { "mbstowcs", func_mbstowcs }, { "setjmp", func_setjmp }, { "sprintf", func_sprintf },