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

Unified Diff: base/string_number_conversions_unittest.cc

Issue 10332159: Add some unittests for DoubleToString. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/string_number_conversions_unittest.cc
diff --git a/base/string_number_conversions_unittest.cc b/base/string_number_conversions_unittest.cc
index 438db077a953225adac1d4bf9c8881aca750cb5b..e243663e844e76d5deb2d248fcb7b3ae7c713777 100644
--- a/base/string_number_conversions_unittest.cc
+++ b/base/string_number_conversions_unittest.cc
@@ -344,6 +344,25 @@ TEST(StringNumberConversionsTest, StringToDouble) {
EXPECT_DOUBLE_EQ(3.14, output);
}
+TEST(StringNumberConversionsTest, DoubleToString) {
+ static const struct {
+ double input;
+ std::string expected;
eroman 2012/05/14 22:52:39 I would suggest making this a |const char*| instea
Mark Mentovai 2012/05/14 23:20:32 eroman wrote:
+ } cases[] = {
+ {0.0, "0"},
+ {1.25, "1.25"},
+ {1.33518e+012, "1.33518e+12"},
eroman 2012/05/14 22:52:39 Note that these are NOT the exact same values as I
+ {1.33489e+012, "1.33489e+12"},
+ {1.33505e+012, "1.33505e+12"},
+ {1.33545e+009, "1335450000"},
+ {1.33503e+009, "1335030000"},
+ };
+
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
+ EXPECT_EQ(cases[i].expected, DoubleToString(cases[i].input));
+ }
+}
+
TEST(StringNumberConversionsTest, HexEncode) {
std::string hex(HexEncode(NULL, 0));
EXPECT_EQ(hex.length(), 0U);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698