Chromium Code Reviews| Index: base/time/time_unittest.cc |
| diff --git a/base/time/time_unittest.cc b/base/time/time_unittest.cc |
| index 8a6a7f517728335660c180788cadcd158abcb78a..b755cc0819dd38ff8270d8412b1b51f3b98da53d 100644 |
| --- a/base/time/time_unittest.cc |
| +++ b/base/time/time_unittest.cc |
| @@ -1,4 +1,4 @@ |
| -// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| @@ -125,6 +125,41 @@ TEST_F(TimeTest, FromExplodedWithMilliseconds) { |
| EXPECT_EQ(exploded1.millisecond, exploded2.millisecond); |
| } |
| +TEST_F(TimeTest, FromExplodedError) { |
|
mmenke
2016/05/18 17:32:01
Maybe call this test "FromExplodedOutOfBoundsTime"
maksims (do not use this acc)
2016/05/19 09:57:20
Done.
|
| + // FromUTCExploded might return Time(0), if the day is set to 31 on a |
|
mmenke
2016/05/18 17:32:01
nit: might -> must
maksims (do not use this acc)
2016/05/19 09:57:20
Done.
|
| + // 28-30 day month. Test |exploded| returns Time(0) on 31st of February and |
| + // 31st of April; |
| + base::Time::Exploded exploded = {0}; |
| + exploded.year = 2016; |
| + exploded.month = 2; |
| + exploded.day_of_month = 31; |
| + exploded.hour = 12; |
| + exploded.minute = 30; |
| + exploded.second = 0; |
| + |
| + EXPECT_TRUE(exploded.HasValidValues()); |
| + |
| + base::Time t_time = base::Time::FromUTCExploded(exploded); |
| + EXPECT_TRUE(t_time.is_null()); |
| + t_time = base::Time::FromLocalExploded(exploded); |
| + EXPECT_TRUE(t_time.is_null()); |
| + |
| + // 31st of April |
| + exploded.year = 2016; |
| + exploded.month = 4; |
| + exploded.day_of_month = 31; |
| + exploded.hour = 12; |
| + exploded.minute = 30; |
|
eroman
2016/05/18 19:35:17
Good start, but will also want tests for:
* nega
maksims (do not use this acc)
2016/05/19 09:57:20
Done.
|
| + exploded.second = 0; |
| + |
| + EXPECT_TRUE(exploded.HasValidValues()); |
| + |
| + t_time = base::Time::FromUTCExploded(exploded); |
| + EXPECT_TRUE(t_time.is_null()); |
| + t_time = base::Time::FromLocalExploded(exploded); |
| + EXPECT_TRUE(t_time.is_null()); |
| +} |
| + |
| TEST_F(TimeTest, ZeroIsSymmetric) { |
| Time zero_time(Time::FromTimeT(0)); |
| EXPECT_EQ(0, zero_time.ToTimeT()); |