X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Ffunctional%2Fsnprintf.c;h=c96f151ace1908c1e811ee6024edc0646feccc1a;hb=fb642f74e29e37ca2d2188627d9c66525b3cf8e1;hp=fefe814bbfddbe3bd2b4d0ca36b54cf2905ddae8;hpb=2cf89517c5b25c2524fe0c0c01ed277d7307a852;p=libc-test diff --git a/src/functional/snprintf.c b/src/functional/snprintf.c index fefe814..c96f151 100644 --- a/src/functional/snprintf.c +++ b/src/functional/snprintf.c @@ -12,11 +12,11 @@ #define TEST(r, f, x, m) ( \ ((r) = (f)) == (x) || \ - (error("%s failed (" m ")\n", #f, r, x), 0) ) + (t_error("%s failed (" m ")\n", #f, r, x), 0) ) #define TEST_S(s, x, m) ( \ !strcmp((s),(x)) || \ - (error("[%s] != [%s] (%s)\n", s, x, m), 0) ) + (t_error("[%s] != [%s] (%s)\n", s, x, m), 0) ) static const struct { const char *fmt; @@ -36,11 +36,11 @@ static const struct { { "%0-5d", 12, "12 " }, { "%-05d", 12, "12 " }, - /* ...explicit precision of 0 shall be no characters. */ + /* ...explicit precision of 0 shall be no characters except for alt-octal. */ { "%.0d", 0, "" }, { "%.0o", 0, "" }, { "%#.0d", 0, "" }, - { "%#.0o", 0, "" }, + { "%#.0o", 0, "0" }, { "%#.0x", 0, "" }, /* ...but it still has to honor width and flags. */ @@ -86,7 +86,8 @@ static const struct { { "%f", 1.3, "1.300000" }, { "%f", 1.4, "1.400000" }, { "%f", 1.5, "1.500000" }, - { "%.4f", 1.06125, "1.0612" }, + { "%.4f", 1.06125, "1.0613" }, /* input is not representible exactly as double */ + { "%.4f", 1.03125, "1.0312" }, /* 0x1.08p0 */ { "%.2f", 1.375, "1.38" }, { "%.1f", 1.375, "1.4" }, { "%.1lf", 1.375, "1.4" }, @@ -162,23 +163,23 @@ int main(void) for (j=0; int_tests[j].fmt; j++) { i = snprintf(b, sizeof b, int_tests[j].fmt, int_tests[j].i); if (i != strlen(int_tests[j].expect)) { - error("snprintf(b, sizeof b, \"%s\", %d) returned %d wanted %d\n", + t_error("snprintf(b, sizeof b, \"%s\", %d) returned %d wanted %d\n", int_tests[j].fmt, int_tests[j].i, i, strlen(int_tests[j].expect)); } if (strcmp(b, int_tests[j].expect) != 0) - error("bad integer conversion: got \"%s\", want \"%s\"\n", b, int_tests[j].expect); + t_error("bad integer conversion: got \"%s\", want \"%s\"\n", b, int_tests[j].expect); } for (j=0; fp_tests[j].fmt; j++) { i = snprintf(b, sizeof b, fp_tests[j].fmt, fp_tests[j].f); if (i != strlen(fp_tests[j].expect)) { - error("snprintf(b, sizeof b, \"%s\", %f) returned %d wanted %d\n", + t_error("snprintf(b, sizeof b, \"%s\", %f) returned %d wanted %d\n", fp_tests[j].fmt, fp_tests[j].f, i, strlen(fp_tests[j].expect)); } if (strcmp(b, fp_tests[j].expect) != 0) - error("bad floating-point conversion: got \"%s\", want \"%s\"\n", b, fp_tests[j].expect); + t_error("bad floating-point conversion: got \"%s\", want \"%s\"\n", b, fp_tests[j].expect); } TEST(i, snprintf(0, 0, "%.4a", 1.0), 11, "%d != %d"); - return test_status; + return t_status; }