Skip to content

Commit ac63cef

Browse files
committed
[CRT_APITEST] Implement tests for _stricmp and _strnicmp
1 parent 0dea0cf commit ac63cef

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 _stricmp
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_stricmp)(const char* _String1, const char* _String2);
14+
static PFN_stricmp p_stricmp;
15+
16+
static BOOL Init(void)
17+
{
18+
HMODULE hdll = LoadLibraryA(TEST_DLL_NAME);
19+
p_stricmp = (PFN_stricmp)GetProcAddress(hdll, "_stricmp");
20+
ok(p_stricmp != NULL, "Failed to load _stricmp from %s\n", TEST_DLL_NAME);
21+
return (p_stricmp != NULL);
22+
}
23+
24+
START_TEST(_stricmp)
25+
{
26+
int result;
27+
28+
#ifndef TEST_STATIC_CRT
29+
if (!Init())
30+
{
31+
skip("Skipping tests, because _stricmp is not available\n");
32+
return;
33+
}
34+
#endif
35+
36+
StartSeh()
37+
result = p_stricmp("a", NULL);
38+
ok_int(result, MAXLONG);
39+
#ifdef TEST_NTDLL
40+
EndSeh(STATUS_ACCESS_VIOLATION);
41+
#else
42+
EndSeh((is_reactos() || GetNTVersion() >= _WIN32_WINNT_VISTA) ? STATUS_SUCCESS : STATUS_ACCESS_VIOLATION);
43+
#endif
44+
45+
StartSeh()
46+
result = p_stricmp(NULL, "a");
47+
ok_int(result, MAXLONG);
48+
#ifdef TEST_NTDLL
49+
EndSeh(STATUS_ACCESS_VIOLATION);
50+
#else
51+
EndSeh((is_reactos() || GetNTVersion() >= _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 _strnicmp
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_strnicmp)(const char* _String1, const char* _String2, size_t _MaxCount);
14+
static PFN_strnicmp p_strnicmp;
15+
16+
static BOOL Init(void)
17+
{
18+
HMODULE hdll = LoadLibraryA(TEST_DLL_NAME);
19+
p_strnicmp = (PFN_strnicmp)GetProcAddress(hdll, "_strnicmp");
20+
ok(p_strnicmp != NULL, "Failed to load _strnicmp from %s\n", TEST_DLL_NAME);
21+
return (p_strnicmp != NULL);
22+
}
23+
24+
START_TEST(_strnicmp)
25+
{
26+
int result;
27+
28+
#ifndef TEST_STATIC_CRT
29+
if (!Init())
30+
{
31+
skip("Skipping tests, because _strnicmp is not available\n");
32+
return;
33+
}
34+
#endif
35+
36+
StartSeh()
37+
result = p_strnicmp("a", NULL, 0);
38+
EndSeh(STATUS_SUCCESS);
39+
40+
StartSeh()
41+
result = p_strnicmp("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_strnicmp(NULL, "a", 0);
51+
EndSeh(STATUS_SUCCESS);
52+
53+
StartSeh()
54+
result = p_strnicmp(NULL, "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
@@ -16,6 +16,8 @@ list(APPEND SOURCE_CRT_TESTS
1616
../crt/_mbsstr.c
1717
../crt/_snprintf.c
1818
../crt/_snwprintf.c
19+
../crt/_stricmp.c
20+
../crt/_strnicmp.c
1921
../crt/_vscprintf.c
2022
../crt/_vscwprintf.c
2123
../crt/_vsnprintf.c

modules/rostests/apitests/msvcrt/testlist.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ extern void func__mbsncmp(void);
1010
extern void func__mbsstr(void);
1111
extern void func__snprintf(void);
1212
extern void func__snwprintf(void);
13+
extern void func__stricmp(void);
14+
extern void func__strnicmp(void);
1315
extern void func__vscprintf(void);
1416
extern void func__vscwprintf(void);
1517
extern void func__vsnprintf(void);
@@ -68,6 +70,8 @@ const struct test winetest_testlist[] =
6870
{ "_mbsstr", func__mbsstr },
6971
{ "_snprintf", func__snprintf },
7072
{ "_snwprintf", func__snwprintf },
73+
{ "_stricmp", func__stricmp },
74+
{ "_strnicmp", func__strnicmp },
7175
{ "_vscprintf", func__vscprintf },
7276
{ "_vscwprintf", func__vscwprintf },
7377
{ "_vsnprintf", func__vsnprintf },

modules/rostests/apitests/ntdll/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ spec2def(ntdll_apitest.exe ntdll_apitest.spec)
1010
list(APPEND SOURCE_CRT_TESTS
1111
../crt/_snprintf.c
1212
../crt/_snwprintf.c
13+
../crt/_stricmp.c
14+
../crt/_strnicmp.c
1315
../crt/_vscwprintf.c
1416
../crt/_vsnprintf.c
1517
../crt/_vsnwprintf.c

modules/rostests/apitests/ntdll/testlist.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
extern void func__snprintf(void);
66
extern void func__snwprintf(void);
7+
extern void func__stricmp(void);
8+
extern void func__strnicmp(void);
79
extern void func__vscwprintf(void);
810
extern void func__vsnprintf(void);
911
extern void func__vsnwprintf(void);
@@ -129,6 +131,8 @@ const struct test winetest_testlist[] =
129131
// CRT tests from ../crt
130132
{ "_snprintf", func__snprintf },
131133
{ "_snwprintf", func__snwprintf },
134+
{ "_stricmp", func__stricmp },
135+
{ "_strnicmp", func__strnicmp },
132136
{ "_vscwprintf", func__vscwprintf },
133137
{ "_vsnprintf", func__vsnprintf },
134138
{ "_vsnwprintf", func__vsnwprintf },

0 commit comments

Comments
 (0)