From a68dec3b03b9c163ad79192cbe837208b2f90de1 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Tue, 6 Oct 2015 22:41:49 +0000 Subject: Add more tests of lrint, llrint, lround, llround. This patch adds more tests of lrint, llrint, lround and llround, to cover various standard special cases not previously covered, and more tests of overflow. Tested for x86_64 and x86. * math/libm-test.inc (lrint_test_data): Add more tests. (llrint_test_data): Likewise. (lround_test_data): Likewise. (llround_test_data): Likewise. --- ChangeLog | 5 +++ math/libm-test.inc | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) diff --git a/ChangeLog b/ChangeLog index cb03807..b49f35d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2015-10-06 Joseph Myers + * math/libm-test.inc (lrint_test_data): Add more tests. + (llrint_test_data): Likewise. + (lround_test_data): Likewise. + (llround_test_data): Likewise. + * math/libm-test.inc (lrint_test_data): Add tests used for llrint. (llrint_test_data): Add tests used for lrint. diff --git a/math/libm-test.inc b/math/libm-test.inc index 4c32364..54f62f8 100644 --- a/math/libm-test.inc +++ b/math/libm-test.inc @@ -7781,8 +7781,39 @@ static const struct test_f_l_data lrint_test_data[] = TEST_f_l (lrint, plus_infty, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), TEST_f_l (lrint, minus_infty, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), TEST_f_l (lrint, qnan_value, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_l (lrint, -qnan_value, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_l (lrint, max_value, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_l (lrint, -max_value, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), +#if LONG_MAX > 0x7fffffff + TEST_f_l (lrint, 0x1p31, 0x80000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_l (lrint, 0x1p32, 0x100000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_l (lrint, 0x1p33, 0x200000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), +#else + TEST_f_l (lrint, 0x1p31, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_l (lrint, 0x1p32, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_l (lrint, 0x1p33, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), +#endif + TEST_f_l (lrint, 0x1p63, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_l (lrint, 0x1p64, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_l (lrint, 0x1p65, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_l (lrint, -0x1p31, -0x80000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), +#if LONG_MAX > 0x7fffffff + TEST_f_l (lrint, -0x1p32, -0x100000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_l (lrint, -0x1p33, -0x200000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_l (lrint, -0x1p63, LLONG_MIN, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), +#else + TEST_f_l (lrint, -0x1p32, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_l (lrint, -0x1p33, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_l (lrint, -0x1p63, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), +#endif + TEST_f_l (lrint, -0x1p64, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_l (lrint, -0x1p65, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), TEST_f_l (lrint, 0.0, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), TEST_f_l (lrint, minus_zero, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_l (lrint, min_value, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 1, INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_l (lrint, -min_value, -1, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_l (lrint, min_subnorm_value, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 1, INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_l (lrint, -min_subnorm_value, -1, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED), TEST_f_l (lrint, 0.2L, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 1, INEXACT_EXCEPTION|ERRNO_UNCHANGED), TEST_f_l (lrint, -0.2L, -1, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED), TEST_f_l (lrint, 0.5L, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 1, INEXACT_EXCEPTION|ERRNO_UNCHANGED), @@ -7929,8 +7960,27 @@ static const struct test_f_L_data llrint_test_data[] = TEST_f_L (llrint, plus_infty, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), TEST_f_L (llrint, minus_infty, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), TEST_f_L (llrint, qnan_value, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_L (llrint, -qnan_value, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_L (llrint, max_value, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_L (llrint, -max_value, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_L (llrint, 0x1p31, 0x80000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_L (llrint, 0x1p32, 0x100000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_L (llrint, 0x1p33, 0x200000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_L (llrint, 0x1p63, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_L (llrint, 0x1p64, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_L (llrint, 0x1p65, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_L (llrint, -0x1p31, -0x80000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_L (llrint, -0x1p32, -0x100000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_L (llrint, -0x1p33, -0x200000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_L (llrint, -0x1p63, LLONG_MIN, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_L (llrint, -0x1p64, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_L (llrint, -0x1p65, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), TEST_f_L (llrint, 0.0, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), TEST_f_L (llrint, minus_zero, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_L (llrint, min_value, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 1, INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_L (llrint, -min_value, -1, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_L (llrint, min_subnorm_value, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 1, INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_L (llrint, -min_subnorm_value, -1, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED), TEST_f_L (llrint, 0.2L, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 1, INEXACT_EXCEPTION|ERRNO_UNCHANGED), TEST_f_L (llrint, -0.2L, -1, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED), TEST_f_L (llrint, 0.5L, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 0, INEXACT_EXCEPTION|ERRNO_UNCHANGED, 1, INEXACT_EXCEPTION|ERRNO_UNCHANGED), @@ -8205,8 +8255,39 @@ static const struct test_f_l_data lround_test_data[] = TEST_f_l (lround, plus_infty, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), TEST_f_l (lround, minus_infty, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), TEST_f_l (lround, qnan_value, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_l (lround, -qnan_value, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_l (lround, max_value, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_l (lround, -max_value, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), +#if LONG_MAX > 0x7fffffff + TEST_f_l (lround, 0x1p31, 0x80000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_l (lround, 0x1p32, 0x100000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_l (lround, 0x1p33, 0x200000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), +#else + TEST_f_l (lround, 0x1p31, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_l (lround, 0x1p32, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_l (lround, 0x1p33, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), +#endif + TEST_f_l (lround, 0x1p63, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_l (lround, 0x1p64, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_l (lround, 0x1p65, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_l (lround, -0x1p31, -0x80000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), +#if LONG_MAX > 0x7fffffff + TEST_f_l (lround, -0x1p32, -0x100000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_l (lround, -0x1p33, -0x200000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_l (lround, -0x1p63, LLONG_MIN, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), +#else + TEST_f_l (lround, -0x1p32, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_l (lround, -0x1p33, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_l (lround, -0x1p63, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), +#endif + TEST_f_l (lround, -0x1p64, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_l (lround, -0x1p65, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), TEST_f_l (lround, 0, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), TEST_f_l (lround, minus_zero, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_l (lround, min_value, 0.0, ERRNO_UNCHANGED), + TEST_f_l (lround, -min_value, 0, ERRNO_UNCHANGED), + TEST_f_l (lround, min_subnorm_value, 0.0, ERRNO_UNCHANGED), + TEST_f_l (lround, -min_subnorm_value, 0, ERRNO_UNCHANGED), TEST_f_l (lround, 0.2L, 0.0, ERRNO_UNCHANGED), TEST_f_l (lround, -0.2L, 0, ERRNO_UNCHANGED), TEST_f_l (lround, 0.5, 1, ERRNO_UNCHANGED), @@ -8396,8 +8477,27 @@ static const struct test_f_L_data llround_test_data[] = TEST_f_L (llround, plus_infty, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), TEST_f_L (llround, minus_infty, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), TEST_f_L (llround, qnan_value, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_L (llround, -qnan_value, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_L (llround, max_value, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_L (llround, -max_value, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_L (llround, 0x1p31, 0x80000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_L (llround, 0x1p32, 0x100000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_L (llround, 0x1p33, 0x200000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_L (llround, 0x1p63, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_L (llround, 0x1p64, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_L (llround, 0x1p65, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_L (llround, -0x1p31, -0x80000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_L (llround, -0x1p32, -0x100000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_L (llround, -0x1p33, -0x200000000LL, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_L (llround, -0x1p63, LLONG_MIN, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_L (llround, -0x1p64, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), + TEST_f_L (llround, -0x1p65, IGNORE, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION), TEST_f_L (llround, 0, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), TEST_f_L (llround, minus_zero, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED), + TEST_f_L (llround, min_value, 0.0, ERRNO_UNCHANGED), + TEST_f_L (llround, -min_value, 0, ERRNO_UNCHANGED), + TEST_f_L (llround, min_subnorm_value, 0.0, ERRNO_UNCHANGED), + TEST_f_L (llround, -min_subnorm_value, 0, ERRNO_UNCHANGED), TEST_f_L (llround, 0.2L, 0.0, ERRNO_UNCHANGED), TEST_f_L (llround, -0.2L, 0, ERRNO_UNCHANGED), TEST_f_L (llround, 0.5, 1, ERRNO_UNCHANGED), -- cgit v1.1