Back to index

glibc  2.9
bug13.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 
00003 
00004 
00005 int
00006 main (void)
00007 {
00008   int res = 0;
00009   char buf[100];
00010 
00011 #define TEST(nr, result, format, args...) \
00012   if (sprintf (buf, format, ## args) != result)                             \
00013     {                                                                \
00014       printf ("test %d failed (\"%s\",  %d)\n", nr, buf, result);           \
00015       res = 1;                                                              \
00016     }
00017 
00018   TEST (1, 2, "%d", -1);
00019   TEST (2, 2, "% 2d", 1);
00020   TEST (3, 3, "%#x", 1);
00021   TEST (4, 2, "%+d", 1);
00022   TEST (5, 2, "% d", 1);
00023   TEST (6, 2, "%-d", -1);
00024   TEST (7, 2, "%- 2d", 1);
00025   TEST (8, 3, "%-#x", 1);
00026   TEST (9, 2, "%-+d", 1);
00027   TEST (10, 2, "%- d", 1);
00028 
00029   return res;
00030 }