1#include <stdio.h>
2#include <string.h>
3
4static int
5do_test (void)
6{
7 static const char expect[] = "0, 0, 0";
8 char buf[100];
9 int status = 0;
10
11 static const char fmt1[] = "%0d, %0ld, %0lld";
12 snprintf (s: buf, maxlen: sizeof (buf), format: fmt1, 0, 0L, 0LL);
13 if (strcmp (buf, expect) != 0)
14 {
15 printf (format: "\"%s\": got \"%s\", expected \"%s\"\n", fmt1, buf, expect);
16 status = 1;
17 }
18
19 static const char fmt2[] = "%0u, %0lu, %0llu";
20 snprintf (s: buf, maxlen: sizeof (buf), format: fmt2, 0u, 0uL, 0uLL);
21 if (strcmp (buf, expect) != 0)
22 {
23 printf (format: "\"%s\": got \"%s\", expected \"%s\"\n", fmt2, buf, expect);
24 status = 1;
25 }
26
27 return status;
28}
29
30#define TEST_FUNCTION do_test ()
31#include "../test-skeleton.c"
32

source code of glibc/stdio-common/bug17.c