14 { "%2000Y", 2000, 4000 },
15 { "%02000Y", 2000, 4000 },
16 { "%_2000Y", 2000, 4000 },
17 { "%-2000Y", 2000, 4000 },
19 #define ntests (sizeof (tests) / sizeof (tests[0]))
28 time_t tnow = time (NULL);
29 struct tm *now = localtime (&tnow);
31 for (cnt = 0; cnt < ntests; ++cnt)
40 buf = (char *) realloc (buf, size);
43 puts ("out of memory");
47 res = strftime (buf, size, tests[cnt].fmt, now);
51 while (size < tests[cnt].max);
55 printf ("%Zu: %s: res == 0 despite size == %Zu\n",
56 cnt, tests[cnt].fmt, size);
59 else if (size < tests[cnt].min)
61 printf ("%Zu: %s: size == %Zu was enough\n",
62 cnt, tests[cnt].fmt, size);
66 printf ("%Zu: %s: size == %Zu: OK\n", cnt, tests[cnt].fmt, size);
73 /* Initialize the fields which are needed in the tests. */
88 #define nftests (sizeof (ftests) / sizeof (ftests[0]))
89 for (cnt = 0; cnt < nftests; ++cnt)
92 size_t r = strftime (buf, sizeof (buf), ftests[cnt].fmt, &ttm);
93 if (r != ftests[cnt].n)
95 printf ("strftime(\"%s\") returned %zu not %zu\n",
96 ftests[cnt].fmt, r, ftests[cnt].n);
99 if (strcmp (buf, ftests[cnt].exp) != 0)
101 printf ("strftime(\"%s\") produced \"%s\" not \"%s\"\n",
102 ftests[cnt].fmt, buf, ftests[cnt].exp);
110 #define TEST_FUNCTION do_test ()
111 #include "../test-skeleton.c"