#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "winstring.h"
#include "wine/test.h"
Go to the source code of this file.
◆ check_string
◆ _check_string()
Definition at line 31 of file string.c.
32{
37
40 ok_(__FILE__,
line)(out_null == has_null,
"WindowsStringHasEmbeddedNull failed\n");
43
44
45 ok_(__FILE__,
line)(
ptr !=
NULL,
"WindowsGetStringRawBuffer returned null\n");
46 ok_(__FILE__,
line)(out_length ==
length,
"WindowsGetStringRawBuffer returned incorrect length\n");
48 ok_(__FILE__,
line)(
ptr !=
NULL,
"WindowsGetStringRawBuffer returned null\n");
49 ok_(__FILE__,
line)(
ptr[
length] ==
'\0',
"WindowsGetStringRawBuffer doesn't return a null terminated buffer\n");
51}
UINT32 WINAPI WindowsGetStringLen(HSTRING str)
LPCWSTR WINAPI WindowsGetStringRawBuffer(HSTRING str, UINT32 *len)
static const WCHAR empty[1]
HRESULT WINAPI WindowsStringHasEmbeddedNull(HSTRING str, BOOL *out)
BOOL WINAPI WindowsIsStringEmpty(HSTRING str)
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
GLuint GLsizei GLsizei * length
◆ START_TEST()
Definition at line 548 of file string.c.
549{
559}
static void test_access(void)
static void test_substring(void)
static void test_trim(void)
static void test_create_delete(void)
static void test_compare(void)
static void test_duplicate(void)
static void test_string_buffer(void)
static void test_concat(void)
static void test_hstring_struct(void)
◆ test_access()
Definition at line 141 of file string.c.
142{
145
146
148
149
153
157
158
162
166}
HRESULT WINAPI WindowsCreateString(LPCWSTR ptr, UINT32 len, HSTRING *out)
HRESULT WINAPI WindowsDeleteString(HSTRING str)
HRESULT WINAPI WindowsCreateStringReference(LPCWSTR ptr, UINT32 len, HSTRING_HEADER *header, HSTRING *out)
static const WCHAR input_embed_null[]
#define check_string(str, content, length, has_null)
static const WCHAR input_string[]
Referenced by START_TEST().
◆ test_compare()
Definition at line 350 of file string.c.
351{
355
356
359
361 ok(
res == 0,
"Expected 0, got %d\n",
res);
363 ok(
res == -1,
"Expected -1, got %d\n",
res);
365 ok(
res == 1,
"Expected 1, got %d\n",
res);
367 ok(
res == 0,
"Expected 0, got %d\n",
res);
369 ok(
res == 1,
"Expected 1, got %d\n",
res);
371 ok(
res == -1,
"Expected -1, got %d\n",
res);
373 ok(
res == 1,
"Expected 1, got %d\n",
res);
375 ok(
res == -1,
"Expected -1, got %d\n",
res);
376
379
380
383
385 ok(
res == 0,
"Expected 0, got %d\n",
res);
387 ok(
res == -1,
"Expected -1, got %d\n",
res);
389 ok(
res == 1,
"Expected 1, got %d\n",
res);
391 ok(
res == 0,
"Expected 0, got %d\n",
res);
393 ok(
res == 1,
"Expected 1, got %d\n",
res);
395 ok(
res == -1,
"Expected -1, got %d\n",
res);
397 ok(
res == 1,
"Expected 1, got %d\n",
res);
399 ok(
res == -1,
"Expected -1, got %d\n",
res);
400
403
404
407 ok(
res == 0,
"Expected 0, got %d\n",
res);
408}
HRESULT WINAPI WindowsCompareStringOrdinal(HSTRING str1, HSTRING str2, INT32 *res)
static const WCHAR input_string1[]
static const WCHAR input_string2[]
XML_HIDDEN void xmlParserErrors const char const xmlChar const xmlChar * str2
XML_HIDDEN void xmlParserErrors const char const xmlChar * str1
Referenced by START_TEST().
◆ test_concat()
Definition at line 294 of file string.c.
295{
298
299
302
305 ok(
str1 == concat,
"Concatenate created new string\n");
308
311 ok(
str2 == concat,
"Concatenate created new string\n");
314
319
322
323
326
328 ok(
str1 != concat,
"Concatenate string ref didn't create new string\n");
331
333 ok(
str2 != concat,
"Concatenate string ref didn't create new string\n");
336
340
343
344
347 ok(concat ==
NULL,
"Concatenate created new string\n");
348}
HRESULT WINAPI WindowsConcatString(HSTRING str1, HSTRING str2, HSTRING *out)
Referenced by START_TEST().
◆ test_create_delete()
Definition at line 59 of file string.c.
60{
63
64
68
71
72
74
75
79
80
81
82
83
85
86
91
92
96
97
99 ok(
str ==
NULL,
"Empty string not a null string\n");
101
103 ok(
str ==
NULL,
"Empty string not a null string\n");
105
107 ok(
str ==
NULL,
"Empty string not a null string\n");
109
111 ok(
str ==
NULL,
"Empty string not a null string\n");
113
115 ok(
str ==
NULL,
"Empty string not a null string\n");
117}
Referenced by START_TEST().
◆ test_duplicate()
Definition at line 119 of file string.c.
120{
126 ok(
str ==
str2,
"Duplicated string created new string\n");
129
132 ok(
str !=
str2,
"Duplicated string ref didn't create new string\n");
135
137 ok(
str2 ==
NULL,
"Duplicated string created new string\n");
139}
HRESULT WINAPI WindowsDuplicateString(HSTRING str, HSTRING *out)
Referenced by dsenum_callback(), and START_TEST().
◆ test_hstring_struct()
| static void test_hstring_struct |
( |
void |
| ) |
|
|
static |
Definition at line 482 of file string.c.
483{
485 {
491 };
492
494 {
498 };
499
505
506 BOOL arch64 = (
sizeof(
void*) == 8);
507
508 ok(arch64 ? (
sizeof(prv->
header) == 24) : (
sizeof(prv->
header) == 20),
"hstring_header size incorrect.\n");
509
511
513
514 ok(prv->
header.flags == 0,
"Expected 0 in flags field, got %#x.\n", prv->
header.flags);
515 ok(prv->
header.length == 6,
"Expected 6 in length field, got %u.\n", prv->
header.length);
516 ok(prv->
header.str == prv->
buffer,
"Expected str to point at buffer, instead pointing at %p.\n", prv->
header.str);
519 ok(prv->
buffer[prv->
header.length] ==
'\0',
"Expected buffer to be null terminated.\n");
520
522
524
528
530
532
534
536
539
540 ok(prv == prv2,
"Pointers not identical.\n");
541 ok(prv2->
header.flags == 1,
"Expected HSTRING_REFERENCE_FLAG to be set, got %#x.\n", prv2->
header.flags);
542 ok(prv2->
header.length == 6,
"Expected 6 in length field, got %u.\n", prv2->
header.length);
544
546}
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
struct hstring_header header
#define CONTAINING_RECORD(address, type, field)
Referenced by START_TEST().
◆ test_string_buffer()
Definition at line 168 of file string.c.
169{
170
171
175
176
178 ok(
ptr !=
NULL,
"Empty string didn't return a buffer pointer\n");
180 ok(
str ==
NULL,
"Empty string isn't a null string\n");
183
185
186
189
190
192 ok(
ptr[6] ==
'\0',
"Preallocated string buffer didn't have null termination\n");
198
199
202
207
208
214}
HRESULT WINAPI WindowsDeleteStringBuffer(HSTRING_BUFFER buf)
HRESULT WINAPI WindowsPromoteStringBuffer(HSTRING_BUFFER buf, HSTRING *out)
HRESULT WINAPI WindowsPreallocateStringBuffer(UINT32 len, WCHAR **outptr, HSTRING_BUFFER *out)
GLenum GLuint GLenum GLsizei const GLchar * buf
#define memcpy(s1, s2, n)
Referenced by START_TEST().
◆ test_substring()
Definition at line 216 of file string.c.
217{
220
221
230
231
234 ok(
str !=
substr,
"Duplicated string didn't create new string\n");
238 ok(
str !=
substr,
"Duplicated string didn't create new string\n");
242
243
252
253
256 ok(
str !=
substr,
"Duplicated string ref didn't create new string\n");
260 ok(
str !=
substr,
"Duplicated string ref didn't create new string\n");
264
265
270
271
278
279
286
287
292}
HRESULT WINAPI WindowsSubstringWithSpecifiedLength(HSTRING str, UINT32 start, UINT32 len, HSTRING *out)
HRESULT WINAPI WindowsSubstring(HSTRING str, UINT32 start, HSTRING *out)
static substr_t substr(const WCHAR *str, size_t len)
static const WCHAR output_substring[]
Referenced by START_TEST().
◆ test_trim()
Definition at line 410 of file string.c.
411{
414
415
418
423 ok(trimmed ==
str1,
"Trimmed string created new string\n");
426
429
431 ok(trimmed ==
str1,
"Trimmed string created new string\n");
437
440
441
444
449 ok(trimmed !=
str1,
"Trimmed string ref didn't create new string\n");
452
455
457 ok(trimmed !=
str1,
"Trimmed string ref didn't create new string\n");
463
466
467
473 ok(trimmed ==
NULL,
"Trimming created new string\n");
478 ok(trimmed ==
NULL,
"Trimming created new string\n");
480}
HRESULT WINAPI WindowsTrimStringStart(HSTRING str1, HSTRING str2, HSTRING *out)
HRESULT WINAPI WindowsTrimStringEnd(HSTRING str1, HSTRING str2, HSTRING *out)
Referenced by START_TEST().
◆ input_embed_null
◆ input_string
◆ input_string1
◆ input_string2
◆ output_substring