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-02-26 17:57:40 +0000
committergavinp@chromium.org <gavinp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-26 17:57:40 +0000
commit37a78c32eaf3b6c35c944373505bed37afe16b45 (patch)
treefc0d367eab34e2032f43294204e8a208b6ee4f2e /base/time/time_unittest.cc
parent69de8e069b343f0c1a6c206e09ab0b028a517b5e (diff)
downloadchromium_src-37a78c32eaf3b6c35c944373505bed37afe16b45.zip
chromium_src-37a78c32eaf3b6c35c944373505bed37afe16b45.tar.gz
chromium_src-37a78c32eaf3b6c35c944373505bed37afe16b45.tar.bz2
Add base::TimeDelta::Max().
TimeDelta::Max() is a maximum timedelta, larger than any timedelta you can compare it to. The results of adding it to a time, or another time delta are undefined. R=ajwong@chromium.org,mkwst@chromium.org,jar@chromium.org TBR=jamesr@chomium.org,acolwell@chromium.org,nick@chromium.org BUG=None Review URL: https://codereview.chromium.org/163413004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253502 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());