Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1841)

Unified Diff: Source/platform/DecimalTest.cpp

Issue 977593004: Avoid uint64_t overflow in Decimal::operator/() and fix Decimal::ceil() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-03-04T15:05:41 Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/Decimal.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/DecimalTest.cpp
diff --git a/Source/platform/DecimalTest.cpp b/Source/platform/DecimalTest.cpp
index fe18de948cca28770a473b777c0dabc06a8b0603..38dd2c47322d1c0916f23490a63be0b42f1b84b0 100644
--- a/Source/platform/DecimalTest.cpp
+++ b/Source/platform/DecimalTest.cpp
@@ -242,6 +242,7 @@ TEST_F(DecimalTest, Ceil)
EXPECT_EQ(Decimal(0), encode(199, -3, Negative).ceil());
EXPECT_EQ(Decimal(-1), encode(199, -2, Negative).ceil());
EXPECT_EQ(Decimal(-2), encode(209, -2, Negative).ceil());
+ EXPECT_EQ(Decimal(1), encode(UINT64_C(123456789012345678), -18, Positive).ceil());
}
TEST_F(DecimalTest, CeilingBigExponent)
@@ -493,8 +494,9 @@ TEST_F(DecimalTest, Division)
EXPECT_EQ(encode(5, -1, Negative), Decimal(-1) / Decimal(2));
EXPECT_EQ(encode(99, 0, Positive), Decimal(99) / Decimal(1));
EXPECT_EQ(Decimal(1), Decimal(-50) / Decimal(-50));
- EXPECT_EQ(encode(UINT64_C(33333333333333333), -17, Positive), Decimal(1) / Decimal(3));
+ EXPECT_EQ(encode(UINT64_C(333333333333333333), -18, Positive), Decimal(1) / Decimal(3));
EXPECT_EQ(encode(UINT64_C(12345678901234), -1, Positive), encode(UINT64_C(12345678901234), 0, Positive) / Decimal(10));
+ EXPECT_EQ(encode(UINT64_C(500005000050000500), -18, Positive), Decimal(50000) / Decimal(99999));
}
TEST_F(DecimalTest, DivisionBigExponent)
« no previous file with comments | « Source/platform/Decimal.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698