ReactOS
0.4.17-dev-357-ga8f14ff
StrDup.c
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 StrDupA/W
5
* COPYRIGHT: Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6
*/
7
8
#include <
apitest.h
>
9
#include <shlwapi.h>
10
#include <
versionhelpers.h
>
11
12
static
void
TEST_StrDupA
(
void
)
13
{
14
LPSTR
ptrA;
15
16
ptrA =
StrDupA
(
NULL
);
17
18
if
(
IsWindowsXPOrGreater
())
19
ok_ptr
(ptrA,
NULL
);
20
else
21
ok
(ptrA && !*ptrA,
"ptrA: '%s'\n"
,
wine_dbgstr_a
(ptrA));
22
23
if
(ptrA)
24
LocalFree
(ptrA);
25
}
26
27
static
void
TEST_StrDupW
(
void
)
28
{
29
LPWSTR
ptrW;
30
31
ptrW =
StrDupW
(
NULL
);
32
33
if
(
IsWindowsXPOrGreater
())
34
ok_ptr
(ptrW,
NULL
);
35
else
36
ok
(ptrW && !*ptrW,
"ptrW: '%s'\n"
,
wine_dbgstr_w
(ptrW));
37
38
if
(ptrW)
39
LocalFree
(ptrW);
40
}
41
42
static
void
TEST_StrRet
(
void
)
43
{
44
LPWSTR
input
, output;
45
if
(
SUCCEEDED
(
SHStrDupW
(
L
"Test"
, &
input
)))
46
{
47
STRRET
strret;
48
strret.
uType
=
STRRET_WSTR
;
49
U
(strret).pOleStr =
input
;
50
output =
NULL
;
51
ok_int
(
StrRetToStrW
(&strret,
NULL
, &output),
S_OK
);
52
ok_ptr
(
U
(strret).pOleStr,
NULL
);
53
ok_ptr
(
input
, output);
54
CoTaskMemFree
(output);
55
}
56
}
57
58
START_TEST
(
StrDup
)
59
{
60
TEST_StrDupA
();
61
TEST_StrDupW
();
62
TEST_StrRet
();
63
}
TEST_StrDupA
static void TEST_StrDupA(void)
Definition:
StrDup.c:12
TEST_StrRet
static void TEST_StrRet(void)
Definition:
StrDup.c:42
TEST_StrDupW
static void TEST_StrDupW(void)
Definition:
StrDup.c:27
apitest.h
ok
#define ok(value,...)
Definition:
atltest.h:57
START_TEST
#define START_TEST(x)
Definition:
atltest.h:75
ok_int
#define ok_int(expression, result)
Definition:
atltest.h:134
ok_ptr
#define ok_ptr(expression, result)
Definition:
atltest.h:108
U
#define U(x)
Definition:
wordpad.c:45
NULL
#define NULL
Definition:
types.h:112
CoTaskMemFree
void WINAPI CoTaskMemFree(void *ptr)
Definition:
malloc.c:389
StrDupW
WCHAR *WINAPI StrDupW(const WCHAR *str)
Definition:
string.c:317
StrDupA
char *WINAPI StrDupA(const char *str)
Definition:
string.c:292
SHStrDupW
HRESULT WINAPI SHStrDupW(const WCHAR *src, WCHAR **dest)
Definition:
main.c:1692
StrRetToStrW
HRESULT WINAPI StrRetToStrW(LPSTRRET lpStrRet, const ITEMIDLIST *pidl, LPWSTR *ppszName)
Definition:
string.c:349
L
#define L(x)
Definition:
resources.c:13
input
GLenum GLenum GLenum input
Definition:
glext.h:9031
LocalFree
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition:
heapmem.c:1594
S_OK
#define S_OK
Definition:
intsafe.h:52
SUCCEEDED
#define SUCCEEDED(hr)
Definition:
intsafe.h:50
wine_dbgstr_w
#define wine_dbgstr_w
Definition:
kernel32.h:34
StrDup
#define StrDup
Definition:
shlwapi.h:1228
wine_dbgstr_a
const char int int int static __inline const char * wine_dbgstr_a(const char *s)
Definition:
debug.h:152
STRRET_WSTR
@ STRRET_WSTR
Definition:
shtypes.idl:85
_STRRET
Definition:
shtypes.idl:92
_STRRET::uType
UINT uType
Definition:
shtypes.idl:93
LPWSTR
uint16_t * LPWSTR
Definition:
typedefs.h:56
LPSTR
char * LPSTR
Definition:
typedefs.h:51
versionhelpers.h
IsWindowsXPOrGreater
VERSIONHELPERAPI IsWindowsXPOrGreater()
Definition:
versionhelpers.h:46
modules
rostests
apitests
shlwapi
StrDup.c
Generated on Mon Jun 22 2026 06:11:28 for ReactOS by
1.9.6