Skip to content

Commit ae3eb6c

Browse files
committed
[CRT_APITEST] Implement tests for _wcsicmp and _wcsnicmp
1 parent 7872c0d commit ae3eb6c

File tree

6 files changed

+126
-0
lines changed

6 files changed

+126
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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 ([email protected])
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+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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 ([email protected])
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+
}

modules/rostests/apitests/msvcrt/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ list(APPEND SOURCE_CRT_TESTS
2222
../crt/_vscwprintf.c
2323
../crt/_vsnprintf.c
2424
../crt/_vsnwprintf.c
25+
../crt/_wcsicmp.c
26+
../crt/_wcsnicmp.c
2527
../crt/_wsystem.c
2628
../crt/acos.c
2729
../crt/asin.c

modules/rostests/apitests/msvcrt/testlist.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ extern void func__vscprintf(void);
1616
extern void func__vscwprintf(void);
1717
extern void func__vsnprintf(void);
1818
extern void func__vsnwprintf(void);
19+
extern void func__wcsicmp(void);
20+
extern void func__wcsnicmp(void);
1921
extern void func__wsystem(void);
2022
extern void func_acos(void);
2123
extern void func_asin(void);
@@ -76,6 +78,8 @@ const struct test winetest_testlist[] =
7678
{ "_vscwprintf", func__vscwprintf },
7779
{ "_vsnprintf", func__vsnprintf },
7880
{ "_vsnwprintf", func__vsnwprintf },
81+
{ "_wcsicmp", func__wcsicmp },
82+
{ "_wcsnicmp", func__wcsnicmp },
7983
{ "_wsystem", func__wsystem },
8084
{ "acos", func_acos },
8185
{ "asin", func_asin },

modules/rostests/apitests/ntdll/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ list(APPEND SOURCE_CRT_TESTS
1515
../crt/_vscwprintf.c
1616
../crt/_vsnprintf.c
1717
../crt/_vsnwprintf.c
18+
../crt/_wcsicmp.c
19+
../crt/_wcsnicmp.c
1820
../crt/mbstowcs.c
1921
../crt/setjmp.c
2022
../crt/sprintf.c

modules/rostests/apitests/ntdll/testlist.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ extern void func__strnicmp(void);
99
extern void func__vscwprintf(void);
1010
extern void func__vsnprintf(void);
1111
extern void func__vsnwprintf(void);
12+
extern void func__wcsicmp(void);
13+
extern void func__wcsnicmp(void);
1214
extern void func_mbstowcs(void);
1315
extern void func_setjmp(void);
1416
extern void func_sprintf(void);
@@ -136,6 +138,8 @@ const struct test winetest_testlist[] =
136138
{ "_vscwprintf", func__vscwprintf },
137139
{ "_vsnprintf", func__vsnprintf },
138140
{ "_vsnwprintf", func__vsnwprintf },
141+
{ "_wcsicmp", func__wcsicmp },
142+
{ "_wcsnicmp", func__wcsnicmp },
139143
{ "mbstowcs", func_mbstowcs },
140144
{ "setjmp", func_setjmp },
141145
{ "sprintf", func_sprintf },

0 commit comments

Comments
 (0)