fix swprintf("%#.0o")
[libc-test] / src / functional / swprintf.c
index 10a8380..243fae8 100644 (file)
 
 #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) ( \
        !wcscmp((s),(x)) || \
-       (error("[%ls] != [%ls] (%s)\n", s, x, m), 0) )
+       (t_error("[%ls] != [%ls] (%s)\n", s, x, m), 0) )
 
 static const struct {
        const wchar_t *fmt;
@@ -37,11 +37,11 @@ static const struct {
        { L"%0-5d", 12, L"12   " },
        { L"%-05d", 12, L"12   " },
 
-       /* ...explicit precision of 0 shall be no characters. */
+       /* ...explicit precision of 0 shall be no characters except for alt-octal. */
        { L"%.0d", 0, L"" },
        { L"%.0o", 0, L"" },
        { L"%#.0d", 0, L"" },
-       { L"%#.0o", 0, L"" },
+       { L"%#.0o", 0, L"0" },
        { L"%#.0x", 0, L"" },
 
        /* hex: test alt form and case */
@@ -131,21 +131,21 @@ int main(void)
        for (j=0; int_tests[j].fmt; j++) {
                i = swprintf(b, sizeof b, int_tests[j].fmt, int_tests[j].i);
                if (i != wcslen(int_tests[j].expect)) {
-                       error("swprintf(b, sizeof b, \"%ls\", %d) returned %d wanted %d\n",
+                       t_error("swprintf(b, sizeof b, \"%ls\", %d) returned %d wanted %d\n",
                                int_tests[j].fmt, int_tests[j].i, i, wcslen(int_tests[j].expect));
                }
                if (wcscmp(b, int_tests[j].expect) != 0)
-                       error("bad integer conversion: got \"%ls\", want \"%ls\"\n", b, int_tests[j].expect);
+                       t_error("bad integer conversion: got \"%ls\", want \"%ls\"\n", b, int_tests[j].expect);
        }
 
        for (j=0; fp_tests[j].fmt; j++) {
                i = swprintf(b, sizeof b, fp_tests[j].fmt, fp_tests[j].f);
                if (i != wcslen(fp_tests[j].expect)) {
-                       error("swprintf(b, sizeof b, \"%ls\", %f) returned %d wanted %d\n",
+                       t_error("swprintf(b, sizeof b, \"%ls\", %f) returned %d wanted %d\n",
                                fp_tests[j].fmt, fp_tests[j].f, i, wcslen(fp_tests[j].expect));
                }
                if (wcscmp(b, fp_tests[j].expect) != 0)
-                       error("bad floating-point conversion: got \"%ls\", want \"%ls\"\n", b, fp_tests[j].expect);
+                       t_error("bad floating-point conversion: got \"%ls\", want \"%ls\"\n", b, fp_tests[j].expect);
        }
-       return test_status;
+       return t_status;
 }