| 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/time/time.h" | 5 #include "base/time/time.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <time.h> | 8 #include <time.h> |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 {{2016, 3, 0, 14, 10, 78, 0, 0}, false}, | 52 {{2016, 3, 0, 14, 10, 78, 0, 0}, false}, |
| 53 // Seconds are too large | 53 // Seconds are too large |
| 54 {{2016, 10, 0, 25, 7, 47, 234, 0}, false}, | 54 {{2016, 10, 0, 25, 7, 47, 234, 0}, false}, |
| 55 // Milliseconds are too large | 55 // Milliseconds are too large |
| 56 {{2016, 10, 0, 25, 6, 31, 23, 1643}, false}, | 56 {{2016, 10, 0, 25, 6, 31, 23, 1643}, false}, |
| 57 // Test overflow. Time is valid, but overflow case | 57 // Test overflow. Time is valid, but overflow case |
| 58 // results in Time(0). | 58 // results in Time(0). |
| 59 {{9840633, 1, 0, 1, 1, 1, 0, 0}, true}, | 59 {{9840633, 1, 0, 1, 1, 1, 0, 0}, true}, |
| 60 // Underflow will fail as well. | 60 // Underflow will fail as well. |
| 61 {{-9840633, 1, 0, 1, 1, 1, 0, 0}, true}, | 61 {{-9840633, 1, 0, 1, 1, 1, 0, 0}, true}, |
| 62 // Test integer overflow and underflow cases for the values themselves. |
| 63 {{std::numeric_limits<int>::min(), 1, 0, 1, 1, 1, 0, 0}, true}, |
| 64 {{std::numeric_limits<int>::max(), 1, 0, 1, 1, 1, 0, 0}, true}, |
| 65 {{2016, std::numeric_limits<int>::min(), 0, 1, 1, 1, 0, 0}, false}, |
| 66 {{2016, std::numeric_limits<int>::max(), 0, 1, 1, 1, 0, 0}, false}, |
| 62 }; | 67 }; |
| 63 | 68 |
| 64 for (const auto& test : kDateTestData) { | 69 for (const auto& test : kDateTestData) { |
| 65 EXPECT_EQ(test.explode.HasValidValues(), test.is_valid); | 70 EXPECT_EQ(test.explode.HasValidValues(), test.is_valid); |
| 66 | 71 |
| 67 base::Time result; | 72 base::Time result; |
| 68 EXPECT_FALSE(base::Time::FromUTCExploded(test.explode, &result)); | 73 EXPECT_FALSE(base::Time::FromUTCExploded(test.explode, &result)); |
| 69 EXPECT_TRUE(result.is_null()); | 74 EXPECT_TRUE(result.is_null()); |
| 70 EXPECT_FALSE(base::Time::FromLocalExploded(test.explode, &result)); | 75 EXPECT_FALSE(base::Time::FromLocalExploded(test.explode, &result)); |
| 71 EXPECT_TRUE(result.is_null()); | 76 EXPECT_TRUE(result.is_null()); |
| (...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1185 | 1190 |
| 1186 TEST(TimeTicksLogging, DoesNotMakeStreamBad) { | 1191 TEST(TimeTicksLogging, DoesNotMakeStreamBad) { |
| 1187 std::ostringstream oss; | 1192 std::ostringstream oss; |
| 1188 oss << TimeTicks(); | 1193 oss << TimeTicks(); |
| 1189 EXPECT_TRUE(oss.good()); | 1194 EXPECT_TRUE(oss.good()); |
| 1190 } | 1195 } |
| 1191 | 1196 |
| 1192 } // namespace | 1197 } // namespace |
| 1193 | 1198 |
| 1194 } // namespace base | 1199 } // namespace base |
| OLD | NEW |