30 char buffer[100], buffer1[100];
36 float res1= -82.6267f, res2= 27.76f, res11, res12;
38 static const char pname[]=
" St. Petersburg, Florida\n";
39 int hour=21,
min=59,sec=20;
52 ok( p_sscanf(
"000000000046F170",
"%p", &
ptr) == 1,
"sscanf failed\n" );
53 ok(
ptr == (
void *)0x46F170,
"sscanf reads %p instead of %x\n",
ptr, 0x46F170 );
55 ok( p_sscanf(
"0046F171",
"%p", &
ptr) == 1,
"sscanf failed\n" );
56 ok(
ptr == (
void *)0x46F171,
"sscanf reads %p instead of %x\n",
ptr, 0x46F171 );
58 ok( p_sscanf(
"46F172",
"%p", &
ptr) == 1,
"sscanf failed\n" );
59 ok(
ptr == (
void *)0x46F172,
"sscanf reads %p instead of %x\n",
ptr, 0x46F172 );
61 ok( p_sscanf(
"0x46F173",
"%p", &
ptr) == 1,
"sscanf failed\n" );
62 ok(
ptr ==
NULL,
"sscanf reads %p instead of %x\n",
ptr, 0 );
64 ok( p_sscanf(
"-46F174",
"%p", &
ptr) == 1,
"sscanf failed\n" );
65 ok(
ptr == (
void *)(
ULONG_PTR)-0x46f174,
"sscanf reads %p instead of %p\n",
68 ok( p_sscanf(
"+46F175",
"%p", &
ptr) == 1,
"sscanf failed\n" );
69 ok(
ptr == (
void *)0x46F175,
"sscanf reads %p instead of %x\n",
ptr, 0x46F175 );
72 ok( p_sscanf(
"1233",
"%p", &
ptr) == 1,
"sscanf failed\n" );
73 ok(
ptr == (
void *)0x1233,
"sscanf reads %p instead of %x\n",
ptr, 0x1233 );
75 ok( p_sscanf(
"1234",
"%P", &
ptr) == 1,
"sscanf failed\n" );
76 ok(
ptr == (
void *)0x1234,
"sscanf reads %p instead of %x\n",
ptr, 0x1234 );
81 ok(
result == 0x519,
"sscanf reads %x instead of %x\n",
result, 0x519 );
85 ok(
result == 0x51a ,
"sscanf reads %x instead of %x\n",
result, 0x51a );
89 ok(
result == 0x51,
"sscanf reads %x instead of %x\n",
result, 0x51 );
93 ok(
ret == 1,
"Wrong number of arguments read: %d (expected 1)\n",
ret);
100 ok(
result == 12,
"sscanf reads %x instead of %x\n",
result, 12 );
103 ret = p_sprintf(
buffer,
"%f %f",res1, res2);
104 ok(
ret == 20,
"expected 20, got %u\n",
ret);
105 ret = p_sscanf(
buffer,
"%f%f",&res11, &res12);
106 ok(
ret == 2,
"expected 2, got %u\n",
ret);
107 ok( (res11 == res1) && (res12 == res2),
"Error reading floats\n");
111 ok(
ret == 9,
"expected 9, got %u\n",
ret);
112 ret = p_sscanf(
buffer,
"%lf", &double_res);
113 ok(
ret == 1,
"expected 1, got %u\n",
ret);
114 ok(double_res == 32.715,
"Got %lf, expected %lf\n", double_res, 32.715);
115 ret = p_sscanf(
buffer,
"%Lf", &double_res);
116 ok(
ret == 1,
"expected 1, got %u\n",
ret);
117 ok(double_res == 32.715,
"Got %lf, expected %lf\n", double_res, 32.715);
120 ret = p_sscanf(
buffer,
"%lf", &double_res);
121 ok(
ret == 1,
"expected 1, got %u\n",
ret);
122 ok(double_res >= 1.1e-30-1
e-45 && double_res <= 1.1e-30+1
e-45,
123 "Got %.18le, expected %.18le\n", double_res, 1.1e-30);
127 ok(
ret == 26,
"expected 26, got %u\n",
ret);
128 ret = p_sscanf(
buffer,
"%*c%[^\n]",buffer1);
129 ok(
ret == 1,
"Error with format \"%s\"\n",
"%*c%[^\n]");
132 ret = p_sscanf(
"abcefgdh",
"%*[a-cg-e]%c",&
buffer[0]);
133 ok(
ret == 1,
"Error with format \"%s\"\n",
"%*[a-cg-e]%c");
134 ok(
buffer[0] ==
'd',
"Error with \"abcefgdh\" \"%c\"\n",
buffer[0]);
136 ret = p_sscanf(
"abcefgdh",
"%*[a-cd-dg-e]%c",&
buffer[0]);
137 ok(
ret == 1,
"Error with format \"%s\"\n",
"%*[a-cd-dg-e]%c");
138 ok(
buffer[0] ==
'h',
"Error with \"abcefgdh\" \"%c\"\n",
buffer[0]);
141 ret = p_sscanf(
"a",
"%s%s",
buffer, buffer1);
142 ok(
ret == 1,
"expected 1, got %u\n",
ret);
145 ok( buffer1[0] ==
'b',
"buffer1[0] = '%c'\n", buffer1[0]);
149 ok(
ret == 8,
"expected 8, got %u\n",
ret);
151 ok(
ret == 1 ,
"problem with format arg \"%%d%%n\"\n");
152 ok(
number == hour,
"Read wrong arg %d instead of %d\n",
number, hour);
153 ok(number_so_far == 2,
"Read wrong arg for \"%%n\" %d instead of 2\n",number_so_far);
155 ret = p_sscanf(
buffer+2,
"%*c%n",&number_so_far);
156 ok(
ret == 0 ,
"problem with format arg \"%%*c%%n\"\n");
157 ok(number_so_far == 1,
"Read wrong arg for \"%%n\" %d instead of 2\n",number_so_far);
162 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
167 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
171 ret = p_sscanf(
buffer,
"%lld", &result64);
172 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
173 ret = p_sprintf(buffer1,
"%lld", result64);
181 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
182 ok(
result == 123,
"Wrong number read\n");
185 ok(
ret == 1,
"Wrong number of arguments read: %d (expected 1)\n",
ret);
188 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
189 ok(
result == 123,
"Wrong number read\n");
192 ok(
ret == 1,
"Wrong number of arguments read: %d (expected 1)\n",
ret);
199 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
200 ok(
result == 15,
"Wrong number read\n");
204 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
205 ok(
result == 23,
"Wrong number read\n");
210 ok(
ret == 1,
"Wrong number of arguments read: %d (expected 1)\n",
ret);
216 ok(
ret == 1,
"Wrong number of arguments read: %d (expected 1)\n",
ret);
223 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
224 ok(
c ==
'a',
"Field incorrect: '%c'\n",
c);
229 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
230 ok(
c ==
' ',
"Field incorrect: '%c'\n",
c);
235 ok(
ret == 2,
"Wrong number of arguments read: %d\n",
ret);
236 ok(hour == 18,
"Field 1 incorrect: %d\n", hour);
237 ok(
min == 59,
"Field 2 incorrect: %d\n",
min);
238 ok(
c == 0x55,
"Field 3 incorrect: 0x%02x\n",
c);
241 buffer[0]=0; buffer1[0]=0;
242 ret = p_sscanf(
"abc def",
"%s %n%s",
buffer, &number_so_far, buffer1);
244 ok(
strcmp(buffer1,
"def")==0,
"Second %%s read incorrectly: %s\n", buffer1);
245 ok(number_so_far==6,
"%%n yielded wrong result: %d\n", number_so_far);
246 ok(
ret == 2,
"%%n shouldn't count as a conversion: %d\n",
ret);
250 ret = p_sscanf(
buffer,
"%d:%d%n", &hour, &
min, &number_so_far);
251 ok(
ret == 2,
"Wrong number of arguments read: %d\n",
ret);
252 ok(number_so_far == 4,
"%%n yielded wrong result: %d\n", number_so_far);
256 ret = p_sscanf(
"test=value\xda",
"%[^=] = %[^;]",
buffer, buffer1);
259 ok(!
strcmp(buffer1,
"value\xda"),
"buf %s\n", buffer1);
261 ret = p_sscanf(
"\x81\x82test",
"\x81%\x82%s",
buffer);
268 int (
WINAPIV *psscanf_s)(
const char*,
const char*,...);
275 win_skip(
"sscanf_s not available\n");
279 ret = psscanf_s(
"123",
"%d", &
i);
280 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
281 ok(
i == 123,
"i = %d\n",
i);
283 ret = psscanf_s(
"123",
"%s",
buf, 100);
284 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
287 ret = psscanf_s(
"123",
"%s",
buf, 3);
288 ok(
ret == 0,
"Wrong number of arguments read: %d\n",
ret);
289 ok(
buf[0]==
'\0',
"buf = %s\n",
buf);
292 ret = psscanf_s(
"123",
"%3c",
buf, 2);
293 ok(
ret == 0,
"Wrong number of arguments read: %d\n",
ret);
294 ok(
buf[0]==
'\0',
"buf = %s\n",
buf);
295 ok(
buf[1]==
'2',
"buf[1] = %d\n",
buf[1]);
296 ok(
buf[2]==
'a',
"buf[2] = %d\n",
buf[2]);
300 ret = psscanf_s(
"123",
"%3c",
buf, 3);
304 ret = psscanf_s(
"123 123",
"%s %d",
buf, 2, &
i);
305 ok(
ret == 0,
"Wrong number of arguments read: %d\n",
ret);
306 ok(
i==1,
"i = %d\n",
i);
309 ret = psscanf_s(
"123 123",
"%d %s", &
i,
buf, 2);
310 ok(
ret == 1,
"Wrong number of arguments read: %d\n",
ret);
311 ok(
i==123,
"i = %d\n",
i);
318 static const WCHAR formatd[] = {
'%',
'd',0};
319 const WCHAR format2[] = {
'a',0x1234,
'%',0x1234,
'%',
'c',0};
329 "swscanf returns %x instead of %x\n",
ret,
WEOF );
336 ok(
ret == 1,
"swscanf returned %d\n",
ret);
337 ok(
c ==
'b',
"c = %x\n",
c);
342 static const wchar_t fmt1[] = {
'%',
'c',0};
343 static const wchar_t fmt2[] = {
'%',
'[',
'a',
'-',
'z',
']',0};
345 int (
WINAPIV *pswscanf_s)(
const wchar_t*,
const wchar_t*,...);
352 win_skip(
"swscanf_s not available\n");
360 ok(
ret == 1,
"swscanf_s returned %d\n",
ret);
361 ok(
out[0] ==
'a',
"out[0] = %x\n",
out[0]);
362 ok(
out[1] ==
'b',
"out[1] = %x\n",
out[1]);
365 ok(!
ret,
"swscanf_s returned %d\n",
ret);
368 ok(
ret == 1,
"swscanf_s returned %d\n",
ret);
369 ok(
out[0] ==
'a',
"out[0] = %x\n",
out[0]);
370 ok(!
out[1],
"out[1] = %x\n",
out[1]);
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)
char * strcpy(char *DstString, const char *SrcString)
#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,...)
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_sscanf_s(void)