summaryrefslogtreecommitdiffstats
path: root/base/time/time_unittest.cc
diff options
context:
space:
mode:
authorgavinp@chromium.org <gavinp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-05 20:02:05 +0000
committergavinp@chromium.org <gavinp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-05 20:02:05 +0000
commitac90e05b7ba311cb3624787758390930c732b59c (patch)
tree5a7ef9b6ba1df20e6643a7e49ab4c2116982bbcb /base/time/time_unittest.cc
parente82c66ea8c39f96796bebfc4618457a2864622be (diff)
downloadchromium_src-ac90e05b7ba311cb3624787758390930c732b59c.zip
chromium_src-ac90e05b7ba311cb3624787758390930c732b59c.tar.gz
chromium_src-ac90e05b7ba311cb3624787758390930c732b59c.tar.bz2
Reland "Add base::TimeDelta::Max()" again.
Webkit layout tests found more media logs serializing infinite durations to JSON. R=scherkus@chromium.org TBR=ajwong@chromium.org,jar@chromium.org,jamesr@chomium.org,acolwell@chromium.org,nick@chromium.org BUG=None Review URL: https://codereview.chromium.org/186683002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255128 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/time/time_unittest.cc')
-rw-r--r--base/time/time_unittest.cc40
1 files changed, 40 insertions, 0 deletions
diff --git a/base/time/time_unittest.cc b/base/time/time_unittest.cc
index b5d2493..40d7bd4 100644
--- a/base/time/time_unittest.cc
+++ b/base/time/time_unittest.cc
@@ -481,6 +481,46 @@ TEST_F(TimeTest, ExplodeBeforeUnixEpoch) {
EXPECT_EQ(1, exploded.millisecond);
}
+TEST_F(TimeTest, TimeDeltaMax) {
+ TimeDelta max = TimeDelta::Max();
+ EXPECT_TRUE(max.is_max());
+ EXPECT_EQ(max, TimeDelta::Max());
+ EXPECT_GT(max, TimeDelta::FromDays(100 * 365));
+ EXPECT_GT(max, TimeDelta());
+}
+
+TEST_F(TimeTest, TimeDeltaMaxConversions) {
+ TimeDelta t = TimeDelta::Max();
+ EXPECT_EQ(std::numeric_limits<int64>::max(), t.ToInternalValue());
+
+ EXPECT_EQ(std::numeric_limits<int>::max(), t.InDays());
+ EXPECT_EQ(std::numeric_limits<int>::max(), t.InHours());
+ EXPECT_EQ(std::numeric_limits<int>::max(), t.InMinutes());
+ EXPECT_EQ(std::numeric_limits<double>::infinity(), t.InSecondsF());
+ EXPECT_EQ(std::numeric_limits<int64>::max(), t.InSeconds());
+ EXPECT_EQ(std::numeric_limits<double>::infinity(), t.InMillisecondsF());
+ EXPECT_EQ(std::numeric_limits<int64>::max(), t.InMilliseconds());
+ EXPECT_EQ(std::numeric_limits<int64>::max(), t.InMillisecondsRoundedUp());
+
+ t = TimeDelta::FromDays(std::numeric_limits<int>::max());
+ EXPECT_TRUE(t.is_max());
+
+ t = TimeDelta::FromHours(std::numeric_limits<int>::max());
+ EXPECT_TRUE(t.is_max());
+
+ t = TimeDelta::FromMinutes(std::numeric_limits<int>::max());
+ EXPECT_TRUE(t.is_max());
+
+ t = TimeDelta::FromSeconds(std::numeric_limits<int64>::max());
+ EXPECT_TRUE(t.is_max());
+
+ t = TimeDelta::FromMilliseconds(std::numeric_limits<int64>::max());
+ EXPECT_TRUE(t.is_max());
+
+ t = TimeDelta::FromMicroseconds(std::numeric_limits<int64>::max());
+ EXPECT_TRUE(t.is_max());
+}
+
TEST_F(TimeTest, Max) {
Time max = Time::Max();
EXPECT_TRUE(max.is_max());