Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: base/time_unittest.cc

Issue 10883061: Add 'base::Time::Max()' to explicitly refer to the end of time. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/time.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.h" 5 #include "base/time.h"
6 6
7 #include <time.h> 7 #include <time.h>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/threading/platform_thread.h" 10 #include "base/threading/platform_thread.h"
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 // Should be 1970-01-01 00:00:01 1 millisecond. 472 // Should be 1970-01-01 00:00:01 1 millisecond.
473 EXPECT_EQ(kUnixEpochYear, exploded.year); 473 EXPECT_EQ(kUnixEpochYear, exploded.year);
474 EXPECT_EQ(1, exploded.month); 474 EXPECT_EQ(1, exploded.month);
475 EXPECT_EQ(1, exploded.day_of_month); 475 EXPECT_EQ(1, exploded.day_of_month);
476 EXPECT_EQ(0, exploded.hour); 476 EXPECT_EQ(0, exploded.hour);
477 EXPECT_EQ(0, exploded.minute); 477 EXPECT_EQ(0, exploded.minute);
478 EXPECT_EQ(1, exploded.second); 478 EXPECT_EQ(1, exploded.second);
479 EXPECT_EQ(1, exploded.millisecond); 479 EXPECT_EQ(1, exploded.millisecond);
480 } 480 }
481 481
482 TEST_F(TimeTest, Max) {
483 EXPECT_EQ(base::Time::Max(), base::Time::Max());
484 EXPECT_GT(base::Time::Max(), base::Time::Now());
485 EXPECT_GT(base::Time::Max(), base::Time());
486 }
487
482 TEST(TimeTicks, Deltas) { 488 TEST(TimeTicks, Deltas) {
483 for (int index = 0; index < 50; index++) { 489 for (int index = 0; index < 50; index++) {
484 TimeTicks ticks_start = TimeTicks::Now(); 490 TimeTicks ticks_start = TimeTicks::Now();
485 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10)); 491 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10));
486 TimeTicks ticks_stop = TimeTicks::Now(); 492 TimeTicks ticks_stop = TimeTicks::Now();
487 TimeDelta delta = ticks_stop - ticks_start; 493 TimeDelta delta = ticks_stop - ticks_start;
488 // Note: Although we asked for a 10ms sleep, if the 494 // Note: Although we asked for a 10ms sleep, if the
489 // time clock has a finer granularity than the Sleep() 495 // time clock has a finer granularity than the Sleep()
490 // clock, it is quite possible to wakeup early. Here 496 // clock, it is quite possible to wakeup early. Here
491 // is how that works: 497 // is how that works:
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 exploded.minute = 0; 611 exploded.minute = 0;
606 exploded.second = 0; 612 exploded.second = 0;
607 exploded.millisecond = 0; 613 exploded.millisecond = 0;
608 Time t = Time::FromUTCExploded(exploded); 614 Time t = Time::FromUTCExploded(exploded);
609 // Unix 1970 epoch. 615 // Unix 1970 epoch.
610 EXPECT_EQ(GG_INT64_C(11644473600000000), t.ToInternalValue()); 616 EXPECT_EQ(GG_INT64_C(11644473600000000), t.ToInternalValue());
611 617
612 // We can't test 1601 epoch, since the system time functions on Linux 618 // We can't test 1601 epoch, since the system time functions on Linux
613 // only compute years starting from 1900. 619 // only compute years starting from 1900.
614 } 620 }
OLDNEW
« no previous file with comments | « base/time.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698