27 static const char file_name[] =
"fscanf.tst";
37 ok(fp !=
NULL,
"fp = %p\n", fp);
39 skip(
"failed to create temporary test file\n");
65 char buffer[100], buffer1[100];
71 float res1= -82.6267f, res2= 27.76f, res11, res12;
73 static const char pname[]=
" St. Petersburg, Florida\n";
74 int hour=21,
min=59,sec=20;
90 ret = p_sscanf(
"test\n",
"%s%c",
buffer, buffer1);
92 ok( buffer1[0] ==
'\n',
"buffer1[0] = %d\n", buffer1[0] );
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 );
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 );
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 );
104 ok( p_sscanf(
"0x46F173",
"%p", &
ptr) == 1,
"sscanf failed\n" );
105 ok(
ptr ==
NULL,
"sscanf reads %p instead of %x\n",
ptr, 0 );
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",
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 );
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 );
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 );
124 ok(
result == 0x519,
"sscanf reads %x instead of %x\n",
result, 0x519 );
128 ok(
result == 0x51a ,
"sscanf reads %x instead of %x\n",
result, 0x51a );
132 ok(
result == 0x51,
"sscanf reads %x instead of %x\n",
result, 0x51 );
136 ok(
ret == 1,
"Wrong number of arguments read: %d (expected 1)\n",
ret);
143 ok(
result == 12,
"sscanf reads %x instead of %x\n",
result, 12 );
146 ret = p_sprintf(
buffer,
"%f %f",res1, res2);
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");
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);
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);
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);
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]");
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]);
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]);
189 ret = p_sscanf(
"-123",
"%[-0-9]",
buffer);
190 ok(
ret == 1,
"Error with format \"%s\"\n",
"%[-0-9]");
193 ret = p_sscanf(
"-321",
"%[0-9-]",
buffer);
194 ok(
ret == 1,
"Error with format \"%s\"\n",
"%[0-9-]");
197 ret = p_sscanf(
"-4123",
"%[1-2-4]",
buffer);
198 ok(
ret == 1,
"Error with format \"%s\"\n",
"%[1-2-4]");
201 ret = p_sscanf(
"-456123",
"%[1-2-45-6]",
buffer);
202 ok(
ret == 1,
"Error with format \"%s\"\n",
"%[1-2-45-6]");
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]);
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);
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);
227 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
233 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
239 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
245 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
251 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
256 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
260 ret = p_sscanf(
buffer,
"%lld", &result64);
261 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
262 ret = p_sprintf(buffer1,
"%lld", result64);
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);
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");
299 ok(
ret == 1,
"Wrong number of arguments read: %d (expected 1)\n",
ret);
305 ok(
ret == 1,
"Wrong number of arguments read: %d (expected 1)\n",
ret);
312 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
313 ok(
c ==
'a',
"Field incorrect: '%c'\n",
c);
318 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
319 ok(
c ==
' ',
"Field incorrect: '%c'\n",
c);
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);
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);
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);
345 ret = p_sscanf(
"test=value\xda",
"%[^=] = %[^;]",
buffer, buffer1);
348 ok(!
strcmp(buffer1,
"value\xda"),
"buf %s\n", buffer1);
350 ret = p_sscanf(
"\x81\x82test",
"\x81%\x82%s",
buffer);
357 int (
WINAPIV *psscanf_s)(
const char*,
const char*,...);
364 win_skip(
"sscanf_s not available\n");
368 ret = psscanf_s(
"123",
"%d", &
i);
369 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
370 ok(
i == 123,
"i = %d\n",
i);
372 ret = psscanf_s(
"123",
"%s",
buf, 100);
373 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
376 ret = psscanf_s(
"123",
"%s",
buf, 3);
377 ok(
ret == 0,
"Wrong number of arguments read: %d\n",
ret);
378 ok(
buf[0]==
'\0',
"buf = %s\n",
buf);
381 ret = psscanf_s(
"123",
"%3c",
buf, 2);
382 ok(
ret == 0,
"Wrong number of arguments read: %d\n",
ret);
383 ok(
buf[0]==
'\0',
"buf = %s\n",
buf);
384 ok(
buf[1]==
'2',
"buf[1] = %d\n",
buf[1]);
385 ok(
buf[2]==
'a',
"buf[2] = %d\n",
buf[2]);
389 ret = psscanf_s(
"123",
"%3c",
buf, 3);
393 ret = psscanf_s(
"123 123",
"%s %d",
buf, 2, &
i);
394 ok(
ret == 0,
"Wrong number of arguments read: %d\n",
ret);
395 ok(
i==1,
"i = %d\n",
i);
398 ret = psscanf_s(
"123 123",
"%d %s", &
i,
buf, 2);
399 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
400 ok(
i==123,
"i = %d\n",
i);
416 "swscanf returns %x instead of %x\n",
ret,
WEOF );
427 ok(
ret == 1,
"swscanf returned %d\n",
ret);
428 ok(
c ==
'b',
"c = %x\n",
c);
433 int (
WINAPIV *pswscanf_s)(
const wchar_t*,
const wchar_t*,...);
440 win_skip(
"swscanf_s not available\n");
448 ok(
ret == 1,
"swscanf_s returned %d\n",
ret);
449 ok(
out[0] ==
'a',
"out[0] = %x\n",
out[0]);
450 ok(
out[1] ==
'b',
"out[1] = %x\n",
out[1]);
453 ok(!
ret,
"swscanf_s returned %d\n",
ret);
456 ok(
ret == 1,
"swscanf_s returned %d\n",
ret);
457 ok(
out[0] ==
'a',
"out[0] = %x\n",
out[0]);
458 ok(!
out[1],
"out[1] = %x\n",
out[1]);
static struct _test_info results[8]
int strcmp(const char *String1, const char *String2)
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 *
GLenum GLuint GLenum GLsizei const GLchar * buf
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
_Check_return_ _CRTIMP int __cdecl swscanf(_In_z_ const wchar_t *_Src, _In_z_ _Scanf_format_string_ const wchar_t *_Format,...)
_Check_return_ _CRTIMP int __cdecl scanf(_In_z_ _Scanf_format_string_ const char *_Format,...)
_Check_return_ _CRTIMP int __cdecl fscanf(_Inout_ FILE *_File, _In_z_ _Scanf_format_string_ const char *_Format,...)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
static PEXPLICIT_ACCESSW *static HMODULE hmod
static unsigned int number
static void test_swscanf_s(void)
static void test_swscanf(void)
static void test_sscanf(void)
static void test_fscanf(void)
static void test_sscanf_s(void)
static const char * contents
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out