Commit 159dfb21 authored by Alexandre Julliard's avatar Alexandre Julliard

msvcrt/tests: Fix the printf pointer formatting tests on 64-bit.

parent fcd2ff97
...@@ -277,6 +277,30 @@ static void test_sprintf( void ) ...@@ -277,6 +277,30 @@ static void test_sprintf( void )
ok(!strcmp(buffer,"1 "),"Character zero-padded and/or not left-adjusted \"%s\"\n",buffer); ok(!strcmp(buffer,"1 "),"Character zero-padded and/or not left-adjusted \"%s\"\n",buffer);
ok( r==4, "return count wrong\n"); ok( r==4, "return count wrong\n");
if (sizeof(void *) == 8)
{
format = "%p";
r = sprintf(buffer,format,(void *)57);
ok(!strcmp(buffer,"0000000000000039"),"Pointer formatted incorrectly \"%s\"\n",buffer);
ok( r==16, "return count wrong\n");
format = "%#020p";
r = sprintf(buffer,format,(void *)57);
ok(!strcmp(buffer," 0X0000000000000039"),"Pointer formatted incorrectly\n");
ok( r==20, "return count wrong\n");
format = "%Fp";
r = sprintf(buffer,format,(void *)57);
ok(!strcmp(buffer,"0000000000000039"),"Pointer formatted incorrectly \"%s\"\n",buffer);
ok( r==16, "return count wrong\n");
format = "%#-020p";
r = sprintf(buffer,format,(void *)57);
ok(!strcmp(buffer,"0X0000000000000039 "),"Pointer formatted incorrectly\n");
ok( r==20, "return count wrong\n");
}
else
{
format = "%p"; format = "%p";
r = sprintf(buffer,format,(void *)57); r = sprintf(buffer,format,(void *)57);
ok(!strcmp(buffer,"00000039"),"Pointer formatted incorrectly \"%s\"\n",buffer); ok(!strcmp(buffer,"00000039"),"Pointer formatted incorrectly \"%s\"\n",buffer);
...@@ -292,6 +316,12 @@ static void test_sprintf( void ) ...@@ -292,6 +316,12 @@ static void test_sprintf( void )
ok(!strcmp(buffer,"00000039"),"Pointer formatted incorrectly \"%s\"\n",buffer); ok(!strcmp(buffer,"00000039"),"Pointer formatted incorrectly \"%s\"\n",buffer);
ok( r==8, "return count wrong\n"); ok( r==8, "return count wrong\n");
format = "%#-012p";
r = sprintf(buffer,format,(void *)57);
ok(!strcmp(buffer,"0X00000039 "),"Pointer formatted incorrectly\n");
ok( r==12, "return count wrong\n");
}
format = "%04s"; format = "%04s";
r = sprintf(buffer,format,"foo"); r = sprintf(buffer,format,"foo");
ok(!strcmp(buffer,"0foo"),"String not zero-prefixed \"%s\"\n",buffer); ok(!strcmp(buffer,"0foo"),"String not zero-prefixed \"%s\"\n",buffer);
...@@ -312,11 +342,6 @@ static void test_sprintf( void ) ...@@ -312,11 +342,6 @@ static void test_sprintf( void )
ok(!strcmp(buffer,"foo "),"Negative field width ignored \"%s\"\n",buffer); ok(!strcmp(buffer,"foo "),"Negative field width ignored \"%s\"\n",buffer);
ok( r==5, "return count wrong\n"); ok( r==5, "return count wrong\n");
format = "%#-012p";
r = sprintf(buffer,format,(void *)57);
ok(!strcmp(buffer,"0X00000039 "),"Pointer formatted incorrectly\n");
ok( r==12, "return count wrong\n");
format = "hello"; format = "hello";
r = sprintf(buffer, format); r = sprintf(buffer, format);
ok(!strcmp(buffer,"hello"), "failed\n"); ok(!strcmp(buffer,"hello"), "failed\n");
...@@ -455,8 +480,16 @@ static void test_sprintf( void ) ...@@ -455,8 +480,16 @@ static void test_sprintf( void )
format = "%p"; format = "%p";
r = sprintf(buffer, format,0); r = sprintf(buffer, format,0);
if (sizeof(void *) == 8)
{
ok(!strcmp(buffer,"0000000000000000"), "failed\n");
ok( r==16, "return count wrong\n");
}
else
{
ok(!strcmp(buffer,"00000000"), "failed\n"); ok(!strcmp(buffer,"00000000"), "failed\n");
ok( r==8, "return count wrong\n"); ok( r==8, "return count wrong\n");
}
format = "%s"; format = "%s";
r = sprintf(buffer, format,0); r = sprintf(buffer, format,0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment