ReactOS 0.4.15-dev-8131-g4988de4
GUIDFromString.cpp
Go to the documentation of this file.
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 GUIDFromStringA/W
5 * COPYRIGHT: Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6 */
7
8#include <shelltest.h>
9#include <initguid.h>
10#include <undocshell.h>
11#include <versionhelpers.h>
12
13DEFINE_GUID(invalid_guid, 0xDEADDEAD, 0xDEAD, 0xDEAD, 0xED, 0xED, 0xED, 0xED,
14 0xED, 0xED, 0xED, 0xED);
15
16//DEFINE_GUID(IID_IShellLinkW, 0x000214F9, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00,
17// 0x00, 0x00, 0x00, 0x46);
18//DEFINE_GUID(IID_IShellLinkW_Invalid, 0x000214F9, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00,
19// 0x00, 0x00, 0x00, 0xED);
20
21static void TEST_GUIDFromStringA(void)
22{
23 GUID guid;
24 BOOL ret;
25
26 guid = invalid_guid;
28 {
30 }
32 {
33 ret = 0xDEADBEEF;
34 }
36
39 else
40 ok_int(ret, 0xDEADBEEF);
41 ok_int(memcmp(&guid, &invalid_guid, sizeof(guid)) == 0, TRUE);
42
43 guid = invalid_guid;
45 ok_int(memcmp(&guid, &invalid_guid, sizeof(guid)) == 0, TRUE);
46
47 guid = invalid_guid;
49 ok_int(memcmp(&guid, &invalid_guid, sizeof(guid)) == 0, TRUE);
50
51 guid = invalid_guid;
52 ok_int(GUIDFromStringA("{000214F9-0000-0000-C000-000000000046", &guid), FALSE);
53 //ok_int(memcmp(&guid, &IID_IShellLinkW_Invalid, sizeof(guid)) == 0, TRUE); // Ignorable corner case
54
55 guid = invalid_guid;
56 ok_int(GUIDFromStringA("{000214F9-0000-0000-C000-000000000046}", &guid), TRUE);
57 ok_int(memcmp(&guid, &IID_IShellLinkW, sizeof(guid)) == 0, TRUE);
58
59 guid = invalid_guid;
60 ok_int(GUIDFromStringA("{000214F9-0000-0000-C000-000000000046}g", &guid), TRUE);
61 ok_int(memcmp(&guid, &IID_IShellLinkW, sizeof(guid)) == 0, TRUE);
62
63 guid = invalid_guid;
64 ok_int(GUIDFromStringA(" {000214F9-0000-0000-C000-000000000046}", &guid), FALSE);
65 ok_int(memcmp(&guid, &invalid_guid, sizeof(guid)) == 0, TRUE);
66}
67
68static void TEST_GUIDFromStringW(void)
69{
70 GUID guid;
71 BOOL ret;
72
73 guid = invalid_guid;
75 {
77 }
79 {
80 ret = 0xDEADBEEF;
81 }
83
85 ok_int(ret, 0xDEADBEEF);
86 else
88 ok_int(memcmp(&guid, &invalid_guid, sizeof(guid)) == 0, TRUE);
89
90 guid = invalid_guid;
92 ok_int(memcmp(&guid, &invalid_guid, sizeof(guid)) == 0, TRUE);
93
94 guid = invalid_guid;
96 ok_int(memcmp(&guid, &invalid_guid, sizeof(guid)) == 0, TRUE);
97
98 guid = invalid_guid;
99 ok_int(GUIDFromStringW(L"{000214F9-0000-0000-C000-000000000046", &guid), FALSE);
100 //ok_int(memcmp(&guid, &IID_IShellLinkW_Invalid, sizeof(guid)) == 0, TRUE); // Ignorable corner case
101
102 guid = invalid_guid;
103 ok_int(GUIDFromStringW(L"{000214F9-0000-0000-C000-000000000046}", &guid), TRUE);
104 ok_int(memcmp(&guid, &IID_IShellLinkW, sizeof(guid)) == 0, TRUE);
105
106 guid = invalid_guid;
107 ok_int(GUIDFromStringW(L"{000214F9-0000-0000-C000-000000000046}g", &guid), TRUE);
108 ok_int(memcmp(&guid, &IID_IShellLinkW, sizeof(guid)) == 0, TRUE);
109
110 guid = invalid_guid;
111 ok_int(GUIDFromStringW(L" {000214F9-0000-0000-C000-000000000046}", &guid), FALSE);
112 ok_int(memcmp(&guid, &invalid_guid, sizeof(guid)) == 0, TRUE);
113}
114
115START_TEST(GUIDFromString)
116{
119}
static void TEST_GUIDFromStringW(void)
static void TEST_GUIDFromStringA(void)
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define START_TEST(x)
Definition: atltest.h:75
#define ok_int(expression, result)
Definition: atltest.h:134
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
unsigned int BOOL
Definition: ntddk_ex.h:94
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
const GUID * guid
#define L(x)
Definition: ntvdm.h:50
BOOL WINAPI GUIDFromStringW(_In_ PCWSTR psz, _Out_ LPGUID pguid)
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
Definition: guiddef.h:68
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
BOOL WINAPI GUIDFromStringA(LPCSTR str, LPGUID guid)
Definition: shellord.c:1890
VERSIONHELPERAPI IsWindowsVistaOrGreater()
int ret