 Chromium Code Reviews
 Chromium Code Reviews Issue 10916089:
  Fixing Time::Max()'s behavior with Time::ToTimeT() and friends.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 10916089:
  Fixing Time::Max()'s behavior with Time::ToTimeT() and friends.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| Index: base/time_unittest.cc | 
| diff --git a/base/time_unittest.cc b/base/time_unittest.cc | 
| index 5421ed1ea5d0011fc397153eb01ca33a167f6446..77ba2115401376d436563c794c8930962017f24f 100644 | 
| --- a/base/time_unittest.cc | 
| +++ b/base/time_unittest.cc | 
| @@ -86,6 +86,13 @@ TEST_F(TimeTest, TimeT) { | 
| // Conversions of 0 should stay 0. | 
| EXPECT_EQ(0, Time().ToTimeT()); | 
| EXPECT_EQ(0, Time::FromTimeT(0).ToInternalValue()); | 
| + | 
| + // Conversions of Max() should stay max. | 
| + EXPECT_EQ(std::numeric_limits<time_t>::max(), Time::Max().ToTimeT()); | 
| + EXPECT_EQ(std::numeric_limits<time_t>::max(), | 
| + Time().FromTimeT(std::numeric_limits<time_t>::max()).ToTimeT()); | 
| + EXPECT_EQ(std::numeric_limits<int64>::max(), | 
| + Time::FromTimeT(std::numeric_limits<time_t>::max()).ToInternalValue()); | 
| } | 
| // Test conversions to/from javascript time. | 
| @@ -96,6 +103,12 @@ TEST_F(TimeTest, JsTime) { | 
| EXPECT_EQ(700.0003, t.ToDoubleT()); | 
| t = Time::FromDoubleT(800.73); | 
| EXPECT_EQ(800730.0, t.ToJsTime()); | 
| + | 
| + // Conversions of Max() should stay max. | 
| + t = Time::FromJsTime(std::numeric_limits<double>::max()); | 
| + EXPECT_TRUE(t.is_max()); | 
| + t = Time::Max(); | 
| + EXPECT_EQ(std::numeric_limits<double>::max(), t.ToDoubleT()); | 
| } | 
| #if defined(OS_POSIX) | 
| 
Mark Mentovai
2012/09/05 15:27:53
Here’s an example of a platform-specific test.
 | 
| @@ -480,9 +493,11 @@ TEST_F(TimeTest, ExplodeBeforeUnixEpoch) { | 
| } | 
| TEST_F(TimeTest, Max) { | 
| - EXPECT_EQ(base::Time::Max(), base::Time::Max()); | 
| - EXPECT_GT(base::Time::Max(), base::Time::Now()); | 
| - EXPECT_GT(base::Time::Max(), base::Time()); | 
| + Time max = Time::Max(); | 
| + EXPECT_TRUE(max.is_max()); | 
| + EXPECT_EQ(max, Time::Max()); | 
| + EXPECT_GT(max, Time::Now()); | 
| + EXPECT_GT(max, Time()); | 
| } | 
| TEST(TimeTicks, Deltas) { |