summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 13dcb88)
raw | patch | inline | side by side (parent: 13dcb88)
author | Elliott Hughes <enh@google.com> | |
Wed, 29 Oct 2014 00:54:23 +0000 (17:54 -0700) | ||
committer | Elliott Hughes <enh@google.com> | |
Wed, 29 Oct 2014 00:54:23 +0000 (17:54 -0700) |
Check that libc doesn't suffer from a couple of bugs that affected
Java in the past.
Bug: 2206701
Change-Id: I9eb64d7ff2fa0b79e93079b897a5fb78bef866be
Java in the past.
Bug: 2206701
Change-Id: I9eb64d7ff2fa0b79e93079b897a5fb78bef866be
tests/stdlib_test.cpp | patch | blob | history |
diff --git a/tests/stdlib_test.cpp b/tests/stdlib_test.cpp
index 9ad96fd81f1747714a79ea2f5a4c569eab95fbd6..ea88f39b75b8ac5cecb1761ad951ec81e5253bef 100644 (file)
--- a/tests/stdlib_test.cpp
+++ b/tests/stdlib_test.cpp
ASSERT_DOUBLE_EQ(1.23, strtold("1.23", NULL));
}
+TEST(stdlib, strtof_2206701) {
+ ASSERT_EQ(0.0f, strtof("7.0064923216240853546186479164495e-46", NULL));
+ ASSERT_EQ(1.4e-45f, strtof("7.0064923216240853546186479164496e-46", NULL));
+}
+
+TEST(stdlib, strtod_largest_subnormal) {
+ // This value has been known to cause javac and java to infinite loop.
+ // http://www.exploringbinary.com/java-hangs-when-converting-2-2250738585072012e-308/
+ ASSERT_EQ(2.2250738585072014e-308, strtod("2.2250738585072012e-308", NULL));
+ ASSERT_EQ(2.2250738585072014e-308, strtod("0.00022250738585072012e-304", NULL));
+ ASSERT_EQ(2.2250738585072014e-308, strtod("00000002.2250738585072012e-308", NULL));
+ ASSERT_EQ(2.2250738585072014e-308, strtod("2.225073858507201200000e-308", NULL));
+ ASSERT_EQ(2.2250738585072014e-308, strtod("2.2250738585072012e-00308", NULL));
+ ASSERT_EQ(2.2250738585072014e-308, strtod("2.22507385850720129978001e-308", NULL));
+ ASSERT_EQ(-2.2250738585072014e-308, strtod("-2.2250738585072012e-308", NULL));
+}
+
TEST(stdlib, quick_exit) {
pid_t pid = fork();
ASSERT_NE(-1, pid) << strerror(errno);