ReactOS 0.4.17-dev-117-g313be0c
CharUpperNoDBCS.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Tests for CharUpperNoDBCSA/W and CharLowerNoDBCSA/W
5 * COPYRIGHT: Copyright 2026 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6 */
7
8#include <apitest.h>
9#include <shlwapi.h>
10#include <string.h>
11#include <wchar.h>
12
17
22
23static void Test_CharUpperNoDBCSA(void)
24{
25 // Basic ASCII lowercase → uppercase
26 {
27 char buf[] = "hello world";
29 ok(ret == buf, "ret was %p\n", ret);
30 ok_str(buf, "HELLO WORLD");
31 }
32
33 // Already uppercase → unchanged
34 {
35 char buf[] = "HELLO WORLD";
37 ok_str(buf, "HELLO WORLD");
38 }
39
40 // Mixed case
41 {
42 char buf[] = "Hello World";
44 ok_str(buf, "HELLO WORLD");
45 }
46
47 // Digits and symbols are unchanged
48 {
49 char buf[] = "abc123!@#";
51 ok_str(buf, "ABC123!@#");
52 }
53
54 // Empty string
55 {
56 char buf[] = "";
58 ok(ret == NULL, "ret was not NULL.\n");
59 ok_int(buf[0], ANSI_NULL);
60 }
61
62 // NULL pointer → must return NULL without crashing
63 {
65 ok(ret == NULL, "ret was %p\n", ret);
66 }
67}
68
69static void Test_CharLowerNoDBCSA(void)
70{
71 // Basic ASCII uppercase → lowercase
72 {
73 char buf[] = "HELLO WORLD";
75 ok(ret == buf, "ret was %p\n", ret);
76 ok_str(buf, "hello world");
77 }
78
79 // Already lowercase → unchanged
80 {
81 char buf[] = "hello world";
83 ok_str(buf, "hello world");
84 }
85
86 // Mixed case
87 {
88 char buf[] = "Hello World";
90 ok_str(buf, "hello world");
91 }
92
93 // Digits and symbols are unchanged
94 {
95 char buf[] = "ABC123!@#";
97 ok_str(buf, "abc123!@#");
98 }
99
100 // Empty string
101 {
102 char buf[] = "";
104 ok(ret == NULL, "ret was not NULL.\n");
105 ok_int(buf[0], ANSI_NULL);
106 }
107
108 // NULL pointer → must return NULL without crashing
109 {
111 ok(ret == NULL, "ret was %p\n", ret);
112 }
113}
114
115static void Test_CharUpperNoDBCSW(void)
116{
117 // Basic ASCII lowercase → uppercase (wide)
118 {
119 wchar_t buf[] = L"hello world";
121 ok(ret == buf, "ret was %p\n", ret);
122 ok_wstr(buf, L"HELLO WORLD");
123 }
124
125 // Already uppercase → unchanged
126 {
127 wchar_t buf[] = L"HELLO WORLD";
129 ok_wstr(buf, L"HELLO WORLD");
130 }
131
132 // Mixed case
133 {
134 wchar_t buf[] = L"Hello World";
136 ok_wstr(buf, L"HELLO WORLD");
137 }
138
139 // Digits and symbols are unchanged
140 {
141 wchar_t buf[] = L"abc123!@#";
143 ok_wstr(buf, L"ABC123!@#");
144 }
145
146 // Empty string
147 {
148 wchar_t buf[] = L"";
150 ok(ret == NULL, "ret was not NULL.\n");
152 }
153
154 // NULL pointer → must return NULL without crashing
155 {
157 ok(ret == NULL, "ret was %p\n", ret);
158 }
159}
160
161static void Test_CharLowerNoDBCSW(void)
162{
163 // Basic ASCII uppercase → lowercase (wide)
164 {
165 wchar_t buf[] = L"HELLO WORLD";
167 ok(ret == buf, "ret was %p\n", ret);
168 ok_wstr(buf, L"hello world");
169 }
170
171 // Already lowercase → unchanged
172 {
173 wchar_t buf[] = L"hello world";
175 ok_wstr(buf, L"hello world");
176 }
177
178 // Mixed case
179 {
180 wchar_t buf[] = L"Hello World";
182 ok_wstr(buf, L"hello world");
183 }
184
185 // Digits and symbols are unchanged
186 {
187 wchar_t buf[] = L"ABC123!@#";
189 ok_wstr(buf, L"abc123!@#");
190 }
191
192 // Empty string
193 {
194 wchar_t buf[] = L"";
196 ok(ret == NULL, "ret was not NULL.\n");
198 }
199
200 // NULL pointer → must return NULL without crashing
201 {
203 ok(ret == NULL, "ret was %p\n", ret);
204 }
205}
206
207static void Test_RoundTrip(void)
208{
209 {
210 char upper[] = "Hello World 123";
211 char lower[] = "Hello World 123";
212 g_fnCharUpperNoDBCSA(upper); // "HELLO WORLD 123"
213 g_fnCharLowerNoDBCSA(lower); // "hello world 123"
214
215 char rt1[] = "hello world 123";
216 g_fnCharUpperNoDBCSA(rt1); // Lower then Upper → "HELLO WORLD 123"
217 ok_str(rt1, upper);
218
219 char rt2[] = "HELLO WORLD 123";
220 g_fnCharLowerNoDBCSA(rt2); // Upper then Lower → "hello world 123"
221 ok_str(rt2, lower);
222 }
223
224 {
225 wchar_t upper[] = L"Hello World 123";
226 wchar_t lower[] = L"Hello World 123";
229
230 wchar_t rt1[] = L"hello world 123";
232 ok_wstr(rt1, upper);
233
234 wchar_t rt2[] = L"HELLO WORLD 123";
236 ok_wstr(rt2, lower);
237 }
238}
239
240static void Test_NoDBCS(void)
241{
242 BYTE buf[] = { 0x82, 'a', ANSI_NULL };
244 ok_int(buf[2], ANSI_NULL);
245}
246
247START_TEST(CharUpperNoDBCS)
248{
249 HINSTANCE hSHLWAPI = LoadLibraryW(L"shlwapi");
250 if (!hSHLWAPI)
251 {
252 skip("shlwapi not found\n");
253 return;
254 }
255
262 {
263 skip("CharUpperNoDBCSA/W or CharLowerNoDBCSA/W not found\n");
264 FreeLibrary(hSHLWAPI);
265 return;
266 }
267
273 Test_NoDBCS();
274
275 FreeLibrary(hSHLWAPI);
276}
static void Test_CharLowerNoDBCSW(void)
static void Test_CharUpperNoDBCSW(void)
PWSTR(WINAPI * FN_CharLowerNoDBCSW)(PWSTR)
static void Test_NoDBCS(void)
static void Test_CharUpperNoDBCSA(void)
static FN_CharUpperNoDBCSA g_fnCharUpperNoDBCSA
static FN_CharLowerNoDBCSA g_fnCharLowerNoDBCSA
static FN_CharUpperNoDBCSW g_fnCharUpperNoDBCSW
static FN_CharLowerNoDBCSW g_fnCharLowerNoDBCSW
static void Test_CharLowerNoDBCSA(void)
PSTR(WINAPI * FN_CharUpperNoDBCSA)(PSTR)
PWSTR(WINAPI * FN_CharUpperNoDBCSW)(PWSTR)
PSTR(WINAPI * FN_CharLowerNoDBCSA)(PSTR)
static void Test_RoundTrip(void)
#define ok_str(x, y)
Definition: atltest.h:127
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define ok_wstr(x, y)
Definition: atltest.h:130
#define START_TEST(x)
Definition: atltest.h:75
#define ok_int(expression, result)
Definition: atltest.h:134
#define NULL
Definition: types.h:112
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define LoadLibraryW(x)
Definition: compat.h:747
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define UNICODE_NULL
#define ANSI_NULL
uint16_t * PWSTR
Definition: typedefs.h:56
char * PSTR
Definition: typedefs.h:51
const uint16_t * PCWSTR
Definition: typedefs.h:57
const char * PCSTR
Definition: typedefs.h:52
#define WINAPI
Definition: msvc.h:6
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
unsigned char BYTE
Definition: xxhash.c:193