OLD | NEW |
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 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 {"\t\n\v\f\r -123.45e2", -12345.0, false}, | 774 {"\t\n\v\f\r -123.45e2", -12345.0, false}, |
775 {"+123 e4", 123.0, false}, | 775 {"+123 e4", 123.0, false}, |
776 {"123e ", 123.0, false}, | 776 {"123e ", 123.0, false}, |
777 {"123e", 123.0, false}, | 777 {"123e", 123.0, false}, |
778 {" 2.99", 2.99, false}, | 778 {" 2.99", 2.99, false}, |
779 {"1e3.4", 1000.0, false}, | 779 {"1e3.4", 1000.0, false}, |
780 {"nothing", 0.0, false}, | 780 {"nothing", 0.0, false}, |
781 {"-", 0.0, false}, | 781 {"-", 0.0, false}, |
782 {"+", 0.0, false}, | 782 {"+", 0.0, false}, |
783 {"", 0.0, false}, | 783 {"", 0.0, false}, |
| 784 |
| 785 // crbug.org/588726 |
| 786 {"-0.0010000000000000000000000000000000000000001e-256", |
| 787 -1.0000000000000001e-259, true}, |
784 }; | 788 }; |
785 | 789 |
786 for (size_t i = 0; i < arraysize(cases); ++i) { | 790 for (size_t i = 0; i < arraysize(cases); ++i) { |
787 double output; | 791 double output; |
788 errno = 1; | 792 errno = 1; |
789 EXPECT_EQ(cases[i].success, StringToDouble(cases[i].input, &output)); | 793 EXPECT_EQ(cases[i].success, StringToDouble(cases[i].input, &output)); |
790 if (cases[i].success) | 794 if (cases[i].success) |
791 EXPECT_EQ(1, errno) << i; // confirm that errno is unchanged. | 795 EXPECT_EQ(1, errno) << i; // confirm that errno is unchanged. |
792 EXPECT_DOUBLE_EQ(cases[i].output, output); | 796 EXPECT_DOUBLE_EQ(cases[i].output, output); |
793 } | 797 } |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 }; | 888 }; |
885 | 889 |
886 for (const auto& test : cases) { | 890 for (const auto& test : cases) { |
887 double output; | 891 double output; |
888 EXPECT_TRUE(StringToDouble(test.input, &output)); | 892 EXPECT_TRUE(StringToDouble(test.input, &output)); |
889 EXPECT_EQ(bit_cast<uint64_t>(output), test.expected); | 893 EXPECT_EQ(bit_cast<uint64_t>(output), test.expected); |
890 } | 894 } |
891 } | 895 } |
892 | 896 |
893 } // namespace base | 897 } // namespace base |
OLD | NEW |