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

Side by Side Diff: base/strings/string_number_conversions_unittest.cc

Issue 2364123002: Merge latest changes from http://www.netlib.org/fp/dtoa.c into dtoa.cc (Closed)
Patch Set: Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | base/third_party/dmg_fp/README.chromium » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/strings/string_number_conversions.h" 5 #include "base/strings/string_number_conversions.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <limits.h> 8 #include <limits.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 {"8.32116e+55", 0x4b8b2628393e02cdULL}, 883 {"8.32116e+55", 0x4b8b2628393e02cdULL},
884 }; 884 };
885 885
886 for (const auto& test : cases) { 886 for (const auto& test : cases) {
887 double output; 887 double output;
888 EXPECT_TRUE(StringToDouble(test.input, &output)); 888 EXPECT_TRUE(StringToDouble(test.input, &output));
889 EXPECT_EQ(bit_cast<uint64_t>(output), test.expected); 889 EXPECT_EQ(bit_cast<uint64_t>(output), test.expected);
890 } 890 }
891 } 891 }
892 892
893 TEST(StringNumberConversionsTest, StringToDoubleBugs) {
894 static const struct {
895 std::string input;
896 double output;
897 bool success;
898 } cases[] = {
899 // crbug.com/588726 timeout
900 {"-0.0010000000000000000000000000000000000000001e-256",
901 -1.0000000000000001e-259, true},
902 };
903
904 for (size_t i = 0; i < arraysize(cases); ++i) {
scottmg 2016/09/23 18:12:40 Since there's only one case, it would be clearer t
kcwu 2016/09/23 19:23:06 Done.
905 double output;
906 errno = 1;
907 EXPECT_EQ(cases[i].success, StringToDouble(cases[i].input, &output));
908 if (cases[i].success)
909 EXPECT_EQ(1, errno) << i; // confirm that errno is unchanged.
910 EXPECT_DOUBLE_EQ(cases[i].output, output);
911 }
912 }
913
893 } // namespace base 914 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/third_party/dmg_fp/README.chromium » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698