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 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
721 } cases[] = { | 721 } cases[] = { |
722 {"0", 0.0, true}, | 722 {"0", 0.0, true}, |
723 {"42", 42.0, true}, | 723 {"42", 42.0, true}, |
724 {"-42", -42.0, true}, | 724 {"-42", -42.0, true}, |
725 {"123.45", 123.45, true}, | 725 {"123.45", 123.45, true}, |
726 {"-123.45", -123.45, true}, | 726 {"-123.45", -123.45, true}, |
727 {"+123.45", 123.45, true}, | 727 {"+123.45", 123.45, true}, |
728 {"2.99792458e8", 299792458.0, true}, | 728 {"2.99792458e8", 299792458.0, true}, |
729 {"149597870.691E+3", 149597870691.0, true}, | 729 {"149597870.691E+3", 149597870691.0, true}, |
730 {"6.", 6.0, true}, | 730 {"6.", 6.0, true}, |
731 {"9e307", 9e307, true}, | |
732 {"1.7976e308", 1.7976e308, true}, | |
danakj
2016/09/01 23:49:23
Can you drop a comment on all these new ones where
Lei Zhang
2016/09/02 01:07:10
- Added comments for all the groups of cases.
- Ad
| |
733 {"1.7977e308", HUGE_VAL, false}, | |
734 {"9e308", HUGE_VAL, false}, | |
735 {"9e309", HUGE_VAL, false}, | |
736 {"9e999", HUGE_VAL, false}, | |
737 {"9e1999", HUGE_VAL, false}, | |
738 {"9e19999", HUGE_VAL, false}, | |
731 {"9e99999999999999999999", HUGE_VAL, false}, | 739 {"9e99999999999999999999", HUGE_VAL, false}, |
740 {"-9e307", -9e307, true}, | |
741 {"-1.7976e308", -1.7976e308, true}, | |
742 {"-1.7977e308", -HUGE_VAL, false}, | |
743 {"-9e308", -HUGE_VAL, false}, | |
744 {"-9e309", -HUGE_VAL, false}, | |
745 {"-9e999", -HUGE_VAL, false}, | |
746 {"-9e1999", -HUGE_VAL, false}, | |
747 {"-9e19999", -HUGE_VAL, false}, | |
732 {"-9e99999999999999999999", -HUGE_VAL, false}, | 748 {"-9e99999999999999999999", -HUGE_VAL, false}, |
733 {"1e-2", 0.01, true}, | 749 {"1e-2", 0.01, true}, |
734 {"42 ", 42.0, false}, | 750 {"42 ", 42.0, false}, |
735 {" 1e-2", 0.01, false}, | 751 {" 1e-2", 0.01, false}, |
736 {"1e-2 ", 0.01, false}, | 752 {"1e-2 ", 0.01, false}, |
737 {"-1E-7", -0.0000001, true}, | 753 {"-1E-7", -0.0000001, true}, |
738 {"01e02", 100, true}, | 754 {"01e02", 100, true}, |
739 {"2.3e15", 2.3e15, true}, | 755 {"2.3e15", 2.3e15, true}, |
740 {"\t\n\v\f\r -123.45e2", -12345.0, false}, | 756 {"\t\n\v\f\r -123.45e2", -12345.0, false}, |
741 {"+123 e4", 123.0, false}, | 757 {"+123 e4", 123.0, false}, |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
850 }; | 866 }; |
851 | 867 |
852 for (const auto& test : cases) { | 868 for (const auto& test : cases) { |
853 double output; | 869 double output; |
854 EXPECT_TRUE(StringToDouble(test.input, &output)); | 870 EXPECT_TRUE(StringToDouble(test.input, &output)); |
855 EXPECT_EQ(bit_cast<uint64_t>(output), test.expected); | 871 EXPECT_EQ(bit_cast<uint64_t>(output), test.expected); |
856 } | 872 } |
857 } | 873 } |
858 | 874 |
859 } // namespace base | 875 } // namespace base |
OLD | NEW |