diff options
author | John McCall <rjmccall@apple.com> | 2010-02-26 22:20:41 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-02-26 22:20:41 +0000 |
commit | 8b3f3307a26c5911eef034db565aec22ed74f13b (patch) | |
tree | c60ed1b96cb35c3045511be0ffce77fedbd6048c /unittests/ADT | |
parent | 1869ac8b716da4fdbaaf3e5484238f36881fc14b (diff) | |
download | external_llvm-8b3f3307a26c5911eef034db565aec22ed74f13b.zip external_llvm-8b3f3307a26c5911eef034db565aec22ed74f13b.tar.gz external_llvm-8b3f3307a26c5911eef034db565aec22ed74f13b.tar.bz2 |
Make APFloat's string-parsing routines a bit safer against very large exponents.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97278 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/ADT')
-rw-r--r-- | unittests/ADT/APFloatTest.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/unittests/ADT/APFloatTest.cpp b/unittests/ADT/APFloatTest.cpp index b02cc3e..3277c83 100644 --- a/unittests/ADT/APFloatTest.cpp +++ b/unittests/ADT/APFloatTest.cpp @@ -236,6 +236,13 @@ TEST(APFloatTest, fromDecimalString) { EXPECT_EQ(2.05e12, APFloat(APFloat::IEEEdouble, "002.05000e12").convertToDouble()); EXPECT_EQ(2.05e+12, APFloat(APFloat::IEEEdouble, "002.05000e+12").convertToDouble()); EXPECT_EQ(2.05e-12, APFloat(APFloat::IEEEdouble, "002.05000e-12").convertToDouble()); + + // These are "carefully selected" to overflow the fast log-base + // calculations in APFloat.cpp + EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "99e99999").isInfinity()); + EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "-99e99999").isInfinity()); + EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "1e-99999").isPosZero()); + EXPECT_TRUE(APFloat(APFloat::IEEEdouble, "-1e-99999").isNegZero()); } TEST(APFloatTest, fromHexadecimalString) { |