* commit 'c44b5bf207ef08b0035a2fec0ede29ad7267da59': Fix modf* tests
This commit is contained in:
commit
b183936e57
@ -1224,36 +1224,23 @@ TEST(math, frexpl) {
|
||||
|
||||
TEST(math, modf) {
|
||||
double di;
|
||||
double df = modf(123.456, &di);
|
||||
double df = modf(123.75, &di);
|
||||
ASSERT_DOUBLE_EQ(123.0, di);
|
||||
// ASSERT_DOUBLE uses more decimals than the double precision when performing
|
||||
// the comparison which can result in false failures. And it seems that modf
|
||||
// results are not 100% precise as expected but within the acceptable delta.
|
||||
// Work around this by tweaking the expected value (taken) from the result of
|
||||
// glibc modf).
|
||||
ASSERT_DOUBLE_EQ(0.45600000000000307, df);
|
||||
ASSERT_DOUBLE_EQ(0.75, df);
|
||||
}
|
||||
|
||||
TEST(math, modff) {
|
||||
float fi;
|
||||
float ff = modff(123.456f, &fi);
|
||||
float ff = modff(123.75f, &fi);
|
||||
ASSERT_FLOAT_EQ(123.0f, fi);
|
||||
// See modf comment on why we don't use 0.456f as an excepted value.
|
||||
ASSERT_FLOAT_EQ(0.45600128f, ff);
|
||||
ASSERT_FLOAT_EQ(0.75f, ff);
|
||||
}
|
||||
|
||||
TEST(math, modfl) {
|
||||
long double ldi;
|
||||
long double ldf = modfl(123.456l, &ldi);
|
||||
ASSERT_DOUBLE_EQ(123.0l, ldi);
|
||||
// See modf comment on why we don't use 0.456l as an excepted value when the
|
||||
// modf == modfl. For LP64, where long double != double, modfl algorithm
|
||||
// gives precise results and thus we don't need to tweak the expected value.
|
||||
#if defined(__LP64__) || !defined(__BIONIC__)
|
||||
ASSERT_DOUBLE_EQ(0.456l, ldf);
|
||||
#else
|
||||
ASSERT_DOUBLE_EQ(0.45600000000000307, ldf);
|
||||
#endif // __LP64__ || !__BIONIC__
|
||||
long double ldf = modfl(123.75L, &ldi);
|
||||
ASSERT_DOUBLE_EQ(123.0L, ldi);
|
||||
ASSERT_DOUBLE_EQ(0.75L, ldf);
|
||||
}
|
||||
|
||||
TEST(math, remquo) {
|
||||
|
Loading…
Reference in New Issue
Block a user