61{
62
65 char buffer[100], buffer1[100];
71 float res1= -82.6267f, res2= 27.76f, res11, res12;
72 double double_res;
73 static const char pname[]=
" St. Petersburg, Florida\n";
74 int hour=21,
min=59,sec=20;
77
80
81
85
88
89 buffer1[0] = 'a';
90 ret = p_sscanf(
"test\n",
"%s%c",
buffer, buffer1);
92 ok( buffer1[0] ==
'\n',
"buffer1[0] = %d\n", buffer1[0] );
93
94
95 ok( p_sscanf(
"000000000046F170",
"%p", &
ptr) == 1,
"sscanf failed\n" );
96 ok(
ptr == (
void *)0x46F170,
"sscanf reads %p instead of %x\n",
ptr, 0x46F170 );
97
98 ok( p_sscanf(
"0046F171",
"%p", &
ptr) == 1,
"sscanf failed\n" );
99 ok(
ptr == (
void *)0x46F171,
"sscanf reads %p instead of %x\n",
ptr, 0x46F171 );
100
101 ok( p_sscanf(
"46F172",
"%p", &
ptr) == 1,
"sscanf failed\n" );
102 ok(
ptr == (
void *)0x46F172,
"sscanf reads %p instead of %x\n",
ptr, 0x46F172 );
103
104 ok( p_sscanf(
"0x46F173",
"%p", &
ptr) == 1,
"sscanf failed\n" );
105 ok(
ptr ==
NULL,
"sscanf reads %p instead of %x\n",
ptr, 0 );
106
107 ok( p_sscanf(
"-46F174",
"%p", &
ptr) == 1,
"sscanf failed\n" );
108 ok(
ptr == (
void *)(
ULONG_PTR)-0x46f174,
"sscanf reads %p instead of %p\n",
110
111 ok( p_sscanf(
"+46F175",
"%p", &
ptr) == 1,
"sscanf failed\n" );
112 ok(
ptr == (
void *)0x46F175,
"sscanf reads %p instead of %x\n",
ptr, 0x46F175 );
113
114
115 ok( p_sscanf(
"1233",
"%p", &
ptr) == 1,
"sscanf failed\n" );
116 ok(
ptr == (
void *)0x1233,
"sscanf reads %p instead of %x\n",
ptr, 0x1233 );
117
118 ok( p_sscanf(
"1234",
"%P", &
ptr) == 1,
"sscanf failed\n" );
119 ok(
ptr == (
void *)0x1234,
"sscanf reads %p instead of %x\n",
ptr, 0x1234 );
120
121
124 ok(
result == 0x519,
"sscanf reads %x instead of %x\n",
result, 0x519 );
125
128 ok(
result == 0x51a ,
"sscanf reads %x instead of %x\n",
result, 0x51a );
129
132 ok(
result == 0x51,
"sscanf reads %x instead of %x\n",
result, 0x51 );
133
136 ok(
ret == 1,
"Wrong number of arguments read: %d (expected 1)\n",
ret);
138
139
143 ok(
result == 12,
"sscanf reads %x instead of %x\n",
result, 12 );
144
145
147 ok(
ret == 20,
"expected 20, got %u\n",
ret);
148 ret = p_sscanf(
buffer,
"%f%f",&res11, &res12);
149 ok(
ret == 2,
"expected 2, got %u\n",
ret);
150 ok( (res11 == res1) && (res12 == res2),
"Error reading floats\n");
151
152
154 ok(
ret == 9,
"expected 9, got %u\n",
ret);
155 ret = p_sscanf(
buffer,
"%lf", &double_res);
156 ok(
ret == 1,
"expected 1, got %u\n",
ret);
157 ok(double_res == 32.715,
"Got %lf, expected %lf\n", double_res, 32.715);
158 ret = p_sscanf(
buffer,
"%Lf", &double_res);
159 ok(
ret == 1,
"expected 1, got %u\n",
ret);
160 ok(double_res == 32.715,
"Got %lf, expected %lf\n", double_res, 32.715);
161
163 ret = p_sscanf(
buffer,
"%lf", &double_res);
164 ok(
ret == 1,
"expected 1, got %u\n",
ret);
165 ok(double_res >= 1.1e-30-1
e-45 && double_res <= 1.1e-30+1
e-45,
166 "Got %.18le, expected %.18le\n", double_res, 1.1e-30);
167
169 double_res = 1;
170 ret = p_sscanf(
buffer,
"%lf", &double_res);
171 ok(
ret == -1,
"expected 0, got %u\n",
ret);
172 ok(double_res == 1,
"Got %lf, expected 1\n", double_res);
173
174
176 ok(
ret == 26,
"expected 26, got %u\n",
ret);
177 ret = p_sscanf(
buffer,
"%*c%[^\n]",buffer1);
178 ok(
ret == 1,
"Error with format \"%s\"\n",
"%*c%[^\n]");
180
181 ret = p_sscanf(
"abcefgdh",
"%*[a-cg-e]%c",&
buffer[0]);
182 ok(
ret == 1,
"Error with format \"%s\"\n",
"%*[a-cg-e]%c");
183 ok(
buffer[0] ==
'd',
"Error with \"abcefgdh\" \"%c\"\n",
buffer[0]);
184
185 ret = p_sscanf(
"abcefgdh",
"%*[a-cd-dg-e]%c",&
buffer[0]);
186 ok(
ret == 1,
"Error with format \"%s\"\n",
"%*[a-cd-dg-e]%c");
187 ok(
buffer[0] ==
'h',
"Error with \"abcefgdh\" \"%c\"\n",
buffer[0]);
188
189 ret = p_sscanf(
"-123",
"%[-0-9]",
buffer);
190 ok(
ret == 1,
"Error with format \"%s\"\n",
"%[-0-9]");
192
193 ret = p_sscanf(
"-321",
"%[0-9-]",
buffer);
194 ok(
ret == 1,
"Error with format \"%s\"\n",
"%[0-9-]");
196
197 ret = p_sscanf(
"-4123",
"%[1-2-4]",
buffer);
198 ok(
ret == 1,
"Error with format \"%s\"\n",
"%[1-2-4]");
200
201 ret = p_sscanf(
"-456123",
"%[1-2-45-6]",
buffer);
202 ok(
ret == 1,
"Error with format \"%s\"\n",
"%[1-2-45-6]");
204
205 buffer1[0] = 'b';
206 ret = p_sscanf(
"a",
"%s%s",
buffer, buffer1);
207 ok(
ret == 1,
"expected 1, got %u\n",
ret);
210 ok( buffer1[0] ==
'b',
"buffer1[0] = '%c'\n", buffer1[0]);
211
212
214 ok(
ret == 8,
"expected 8, got %u\n",
ret);
216 ok(
ret == 1 ,
"problem with format arg \"%%d%%n\"\n");
217 ok(
number == hour,
"Read wrong arg %d instead of %d\n",
number, hour);
218 ok(number_so_far == 2,
"Read wrong arg for \"%%n\" %d instead of 2\n",number_so_far);
219
220 ret = p_sscanf(
buffer+2,
"%*c%n",&number_so_far);
221 ok(
ret == 0 ,
"problem with format arg \"%%*c%%n\"\n");
222 ok(number_so_far == 1,
"Read wrong arg for \"%%n\" %d instead of 2\n",number_so_far);
223
227 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
229
233 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
235
239 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
241
245 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
247
251 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
253
256 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
258
260 ret = p_sscanf(
buffer,
"%lld", &result64);
261 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
266
267
270 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
271 ok(
result == 123,
"Wrong number read\n");
274 ok(
ret == 1,
"Wrong number of arguments read: %d (expected 1)\n",
ret);
277 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
278 ok(
result == 123,
"Wrong number read\n");
281 ok(
ret == 1,
"Wrong number of arguments read: %d (expected 1)\n",
ret);
283
284
288 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
289 ok(
result == 15,
"Wrong number read\n");
293 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
294 ok(
result == 23,
"Wrong number read\n");
295
296
299 ok(
ret == 1,
"Wrong number of arguments read: %d (expected 1)\n",
ret);
301
302
305 ok(
ret == 1,
"Wrong number of arguments read: %d (expected 1)\n",
ret);
307
308
312 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
313 ok(
c ==
'a',
"Field incorrect: '%c'\n",
c);
314
318 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
319 ok(
c ==
' ',
"Field incorrect: '%c'\n",
c);
320
324 ok(
ret == 2,
"Wrong number of arguments read: %d\n",
ret);
325 ok(hour == 18,
"Field 1 incorrect: %d\n", hour);
326 ok(
min == 59,
"Field 2 incorrect: %d\n",
min);
327 ok(
c == 0x55,
"Field 3 incorrect: 0x%02x\n",
c);
328
329
330 buffer[0]=0; buffer1[0]=0;
331 ret = p_sscanf(
"abc def",
"%s %n%s",
buffer, &number_so_far, buffer1);
333 ok(
strcmp(buffer1,
"def")==0,
"Second %%s read incorrectly: %s\n", buffer1);
334 ok(number_so_far==6,
"%%n yielded wrong result: %d\n", number_so_far);
335 ok(
ret == 2,
"%%n shouldn't count as a conversion: %d\n",
ret);
336
337
339 ret = p_sscanf(
buffer,
"%d:%d%n", &hour, &
min, &number_so_far);
340 ok(
ret == 2,
"Wrong number of arguments read: %d\n",
ret);
341 ok(number_so_far == 4,
"%%n yielded wrong result: %d\n", number_so_far);
342
344 buffer1[0] = 0;
345 ret = p_sscanf(
"test=value\xda",
"%[^=] = %[^;]",
buffer, buffer1);
348 ok(!
strcmp(buffer1,
"value\xda"),
"buf %s\n", buffer1);
349
350 ret = p_sscanf(
"\x81\x82test",
"\x81%\x82%s",
buffer);
353}
ACPI_SIZE strlen(const char *String)
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
#define GetProcAddress(x, y)
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
static PFN_sprintf p_sprintf
static PEXPLICIT_ACCESSW *static HMODULE hmod
static unsigned int number