ReactOS 0.4.16-dev-2175-g9420ab7
StrToInt.c File Reference
#include <apitest.h>
#include <shlwapi.h>
Include dependency graph for StrToInt.c:

Go to the source code of this file.

Macros

#define ok_longlong(expression, result)
 

Functions

static VOID TEST_StrToIntA (VOID)
 
static VOID TEST_StrToIntW (VOID)
 
 START_TEST (StrToInt)
 

Macro Definition Documentation

◆ ok_longlong

#define ok_longlong (   expression,
  result 
)
Value:
do { \
long long _value = (expression); \
ok(_value == (result), "Wrong value for '%s', expected: " #result " (0x%llx), got: 0x%llx\n", \
#expression, (long long)(result), _value); \
} while (0)
GLuint64EXT * result
Definition: glext.h:11304

Definition at line 11 of file StrToInt.c.

Function Documentation

◆ START_TEST()

START_TEST ( StrToInt  )

Definition at line 187 of file StrToInt.c.

188{
191}
static VOID TEST_StrToIntA(VOID)
Definition: StrToInt.c:17
static VOID TEST_StrToIntW(VOID)
Definition: StrToInt.c:102

◆ TEST_StrToIntA()

static VOID TEST_StrToIntA ( VOID  )
static

Definition at line 17 of file StrToInt.c.

18{
19 INT n0, n1;
21 LPCSTR psz;
22 BOOL ret1, ret2;
23
24 n2 = n1 = 0xDEADFACE;
25 psz = NULL;
26 n0 = StrToIntA(psz);
27 ret1 = StrToIntExA(psz, 0, &n1);
28 ret2 = StrToInt64ExA(psz, 0, &n2);
29 ok_int(n0, 0);
30 ok_int(n1, 0);
31 ok_longlong(n2, 0xFFFFFFFFDEADFACE);
32 ok_int(ret1, FALSE);
33 ok_int(ret2, FALSE);
34
35 n2 = n1 = 0xDEADFACE;
36 psz = "";
37 n0 = StrToIntA(psz);
38 ret1 = StrToIntExA(psz, 0, &n1);
39 ret2 = StrToInt64ExA(psz, 0, &n2);
40 ok_int(n0, 0);
41 ok_int(n1, 0);
42 ok_longlong(n2, 0);
43 ok_int(ret1, FALSE);
44 ok_int(ret2, FALSE);
45
46 n2 = n1 = 0xDEADFACE;
47 psz = "123";
48 n0 = StrToIntA(psz);
49 ret1 = StrToIntExA(psz, 0, &n1);
50 ret2 = StrToInt64ExA(psz, 0, &n2);
51 ok_int(n0, 123);
52 ok_int(n1, 123);
53 ok_longlong(n2, 123);
54 ok_int(ret1, TRUE);
55 ok_int(ret2, TRUE);
56
57 n2 = n1 = 0xDEADFACE;
58 psz = "+123";
59 n0 = StrToIntA(psz);
60 ret1 = StrToIntExA(psz, 0, &n1);
61 ret2 = StrToInt64ExA(psz, 0, &n2);
62 ok_int(n0, 0);
63 ok_int(n1, 123);
64 ok_longlong(n2, 123);
65 ok_int(ret1, TRUE);
66 ok_int(ret2, TRUE);
67
68 n2 = n1 = 0xDEADFACE;
69 psz = "-123";
70 n0 = StrToIntA(psz);
71 ret1 = StrToIntExA(psz, 0, &n1);
72 ret2 = StrToInt64ExA(psz, 0, &n2);
73 ok_int(n0, -123);
74 ok_int(n1, -123);
75 ok_longlong(n2, -123);
76 ok_int(ret1, TRUE);
77 ok_int(ret2, TRUE);
78
79 n2 = n1 = 0xDEADFACE;
80 psz = " +123";
81 n0 = StrToIntA(psz);
82 ret1 = StrToIntExA(psz, 0, &n1);
83 ret2 = StrToInt64ExA(psz, 0, &n2);
84 ok_int(n0, 0);
85 ok_int(n1, 123);
86 ok_longlong(n2, 123);
87 ok_int(ret1, TRUE);
88 ok_int(ret2, TRUE);
89
90 n2 = n1 = 0xDEADFACE;
91 psz = " -123";
92 n0 = StrToIntA(psz);
93 ret1 = StrToIntExA(psz, 0, &n1);
94 ret2 = StrToInt64ExA(psz, 0, &n2);
95 ok_int(n0, 0);
96 ok_int(n1, -123);
97 ok_longlong(n2, -123);
98 ok_int(ret1, TRUE);
99 ok_int(ret2, TRUE);
100}
#define ok_longlong(expression, result)
Definition: StrToInt.c:11
#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
INT WINAPI StrToIntA(LPCSTR lpszStr)
Definition: string.c:370
BOOL WINAPI StrToIntExA(const char *str, DWORD flags, INT *ret)
Definition: string.c:960
BOOL WINAPI StrToInt64ExA(const char *str, DWORD flags, LONGLONG *ret)
Definition: string.c:834
unsigned int BOOL
Definition: ntddk_ex.h:94
int n2
Definition: dwarfget.c:147
int n1
Definition: dwarfget.c:147
int64_t LONGLONG
Definition: typedefs.h:68
int32_t INT
Definition: typedefs.h:58
const char * LPCSTR
Definition: xmlstorage.h:183

Referenced by START_TEST().

◆ TEST_StrToIntW()

static VOID TEST_StrToIntW ( VOID  )
static

Definition at line 102 of file StrToInt.c.

103{
104 INT n0, n1;
105 LONGLONG n2;
106 LPCWSTR psz;
107 BOOL ret1, ret2;
108
109 n2 = n1 = 0xDEADFACE;
110 psz = NULL;
111 n0 = StrToIntW(psz);
112 ret1 = StrToIntExW(psz, 0, &n1);
113 ret2 = StrToInt64ExW(psz, 0, &n2);
114 ok_int(n0, 0);
115 ok_int(n1, 0);
116 ok_longlong(n2, 0xFFFFFFFFDEADFACE);
117 ok_int(ret1, FALSE);
118 ok_int(ret2, FALSE);
119
120 n2 = n1 = 0xDEADFACE;
121 psz = L"";
122 n0 = StrToIntW(psz);
123 ret1 = StrToIntExW(psz, 0, &n1);
124 ret2 = StrToInt64ExW(psz, 0, &n2);
125 ok_int(n0, 0);
126 ok_int(n1, 0);
127 ok_longlong(n2, 0);
128 ok_int(ret1, FALSE);
129 ok_int(ret2, FALSE);
130
131 n2 = n1 = 0xDEADFACE;
132 psz = L"123";
133 n0 = StrToIntW(psz);
134 ret1 = StrToIntExW(psz, 0, &n1);
135 ret2 = StrToInt64ExW(psz, 0, &n2);
136 ok_int(n0, 123);
137 ok_int(n1, 123);
138 ok_longlong(n2, 123);
139 ok_int(ret1, TRUE);
140 ok_int(ret2, TRUE);
141
142 n2 = n1 = 0xDEADFACE;
143 psz = L"+123";
144 n0 = StrToIntW(psz);
145 ret1 = StrToIntExW(psz, 0, &n1);
146 ret2 = StrToInt64ExW(psz, 0, &n2);
147 ok_int(n0, 0);
148 ok_int(n1, 123);
149 ok_longlong(n2, 123);
150 ok_int(ret1, TRUE);
151 ok_int(ret2, TRUE);
152
153 n2 = n1 = 0xDEADFACE;
154 psz = L"-123";
155 n0 = StrToIntW(psz);
156 ret1 = StrToIntExW(psz, 0, &n1);
157 ret2 = StrToInt64ExW(psz, 0, &n2);
158 ok_int(n0, -123);
159 ok_int(n1, -123);
160 ok_longlong(n2, -123);
161 ok_int(ret1, TRUE);
162 ok_int(ret2, TRUE);
163
164 n2 = n1 = 0xDEADFACE;
165 psz = L" +123";
166 n0 = StrToIntW(psz);
167 ret1 = StrToIntExW(psz, 0, &n1);
168 ret2 = StrToInt64ExW(psz, 0, &n2);
169 ok_int(n0, 0);
170 ok_int(n1, 123);
171 ok_longlong(n2, 123);
172 ok_int(ret1, TRUE);
173 ok_int(ret2, TRUE);
174
175 n2 = n1 = 0xDEADFACE;
176 psz = L" -123";
177 n0 = StrToIntW(psz);
178 ret1 = StrToIntExW(psz, 0, &n1);
179 ret2 = StrToInt64ExW(psz, 0, &n2);
180 ok_int(n0, 0);
181 ok_int(n1, -123);
182 ok_longlong(n2, -123);
183 ok_int(ret1, TRUE);
184 ok_int(ret2, TRUE);
185}
INT WINAPI StrToIntW(LPCWSTR lpString)
Definition: string.c:407
BOOL WINAPI StrToIntExW(const WCHAR *str, DWORD flags, INT *ret)
Definition: string.c:972
BOOL WINAPI StrToInt64ExW(const WCHAR *str, DWORD flags, LONGLONG *ret)
Definition: string.c:897
#define L(x)
Definition: resources.c:13
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by START_TEST().