X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fregression%2Ffpclassify-invalid-ld80.c;h=fe8eeb5babaf2bc84af558a96b95d4564a90f306;hb=50ab48b035c2555e09cc9ac94c74f45b74b234f4;hp=b97fe9c4ef13b522fb91365b1064310e00e5c0d4;hpb=9d9900e57c5cb65cd87d85db24ea77d0fdbd3917;p=libc-test diff --git a/src/regression/fpclassify-invalid-ld80.c b/src/regression/fpclassify-invalid-ld80.c index b97fe9c..fe8eeb5 100644 --- a/src/regression/fpclassify-invalid-ld80.c +++ b/src/regression/fpclassify-invalid-ld80.c @@ -1,8 +1,11 @@ // commit: f657fe4b9f734d7fdea515af8dffbf7c28ce4fbc 2013-09-05 // classify invalid x86 ld80 representations (this is ub, we follow the fpu) +// test printf("%La") as well #include #include #include +#include +#include #include "test.h" #if LDBL_MANT_DIG==64 @@ -19,8 +22,15 @@ static char *strclass(int c) return "invalid"; } -#define T(desc,got,want) do{ \ -if (got!=want) t_error("fpclassify(%s) failed: got %s want %s\n", desc, strclass(got), #want); \ +#define T(f, desc, c, cwant, s, swant) do{ \ + c = fpclassify(f); \ + if (c != cwant) \ + t_error("fpclassify(%s) failed: got %s want %s\n", desc, strclass(c), #cwant); \ + memset(s, 0, sizeof(s)); \ + if (snprintf(s, sizeof(s), "%La", f) >= sizeof(s)) \ + t_error("snprintf(\"%%La\", %s) failed with invalid return value\n", desc); \ + if (strcmp(s,swant) != 0) \ + t_error("snprintf(\"%%La\", %s) failed: got \"%.*s\" want %s\n", desc, sizeof(s), s, #swant); \ }while(0) int main(void) @@ -33,26 +43,23 @@ int main(void) } i; } u; int c; + int r; + char s[32]; u.f = 0; u.i.m = (uint64_t)1<<63; - c = fpclassify(u.f); - T("zero with msb set", c, FP_NORMAL); + T(u.f, "zero with msb set", c, FP_NORMAL, s, "0x1p-16382"); u.i.m++; - c = fpclassify(u.f); - T("subnormal with msb set", c, FP_NORMAL); + T(u.f, "subnormal with msb set", c, FP_NORMAL, s, "0x1.0000000000000002p-16382"); u.f=1; u.i.m=0; - c = fpclassify(u.f); - T("normal with msb unset", c, FP_NAN); + T(u.f, "normal with msb unset", c, FP_NAN, s, "nan"); u.f=INFINITY; u.i.m=0; - c = fpclassify(u.f); - T("infinity with msb unset", c, FP_NAN); + T(u.f, "infinity with msb unset", c, FP_NAN, s, "nan"); u.f=NAN; u.i.m&=(uint64_t)-1/2; - c = fpclassify(u.f); - T("nan with msb unset", c, FP_NAN); + T(u.f, "nan with msb unset", c, FP_NAN, s, "nan"); return t_status; } #else