Fix modf* tests
Use a value that can be exactly represented. Change-Id: Idf3b1db5e6042fb49c1f591f25f9eee656659ece
This commit is contained in:
parent
b7afa9df25
commit
d8d6feed3a
@ -1224,36 +1224,23 @@ TEST(math, frexpl) {
|
|||||||
|
|
||||||
TEST(math, modf) {
|
TEST(math, modf) {
|
||||||
double di;
|
double di;
|
||||||
double df = modf(123.456, &di);
|
double df = modf(123.75, &di);
|
||||||
ASSERT_DOUBLE_EQ(123.0, di);
|
ASSERT_DOUBLE_EQ(123.0, di);
|
||||||
// ASSERT_DOUBLE uses more decimals than the double precision when performing
|
ASSERT_DOUBLE_EQ(0.75, df);
|
||||||
// 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(math, modff) {
|
TEST(math, modff) {
|
||||||
float fi;
|
float fi;
|
||||||
float ff = modff(123.456f, &fi);
|
float ff = modff(123.75f, &fi);
|
||||||
ASSERT_FLOAT_EQ(123.0f, 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.75f, ff);
|
||||||
ASSERT_FLOAT_EQ(0.45600128f, ff);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(math, modfl) {
|
TEST(math, modfl) {
|
||||||
long double ldi;
|
long double ldi;
|
||||||
long double ldf = modfl(123.456l, &ldi);
|
long double ldf = modfl(123.75L, &ldi);
|
||||||
ASSERT_DOUBLE_EQ(123.0l, ldi);
|
ASSERT_DOUBLE_EQ(123.0L, ldi);
|
||||||
// See modf comment on why we don't use 0.456l as an excepted value when the
|
ASSERT_DOUBLE_EQ(0.75L, ldf);
|
||||||
// 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__
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(math, remquo) {
|
TEST(math, remquo) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user