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

Side by Side Diff: base/time/time_unittest.cc

Issue 1130953002: Revert of Fixit: Factor out common base::Time* math operator overloads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « base/time/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/time.h" 5 #include "base/time/time.h"
6 6
7 #include <time.h> 7 #include <time.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <string> 10 #include <string>
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 } 710 }
711 } 711 }
712 712
713 TEST(TimeTicks, NowFromSystemTraceTime) { 713 TEST(TimeTicks, NowFromSystemTraceTime) {
714 // Re-use HighRes test for now since clock properties are identical. 714 // Re-use HighRes test for now since clock properties are identical.
715 HighResClockTest(&TimeTicks::NowFromSystemTraceTime); 715 HighResClockTest(&TimeTicks::NowFromSystemTraceTime);
716 } 716 }
717 717
718 TEST(TimeTicks, SnappedToNextTickBasic) { 718 TEST(TimeTicks, SnappedToNextTickBasic) {
719 base::TimeTicks phase = base::TimeTicks::FromInternalValue(4000); 719 base::TimeTicks phase = base::TimeTicks::FromInternalValue(4000);
720 base::TimeDelta interval = base::TimeDelta::FromMicroseconds(1000); 720 base::TimeDelta interval = base::TimeDelta::FromInternalValue(1000);
721 base::TimeTicks timestamp; 721 base::TimeTicks timestamp;
722 722
723 // Timestamp in previous interval. 723 // Timestamp in previous interval.
724 timestamp = base::TimeTicks::FromInternalValue(3500); 724 timestamp = base::TimeTicks::FromInternalValue(3500);
725 EXPECT_EQ(4000, 725 EXPECT_EQ(4000,
726 timestamp.SnappedToNextTick(phase, interval).ToInternalValue()); 726 timestamp.SnappedToNextTick(phase, interval).ToInternalValue());
727 727
728 // Timestamp in next interval. 728 // Timestamp in next interval.
729 timestamp = base::TimeTicks::FromInternalValue(4500); 729 timestamp = base::TimeTicks::FromInternalValue(4500);
730 EXPECT_EQ(5000, 730 EXPECT_EQ(5000,
(...skipping 22 matching lines...) Expand all
753 // Timestamp equal to phase. 753 // Timestamp equal to phase.
754 timestamp = base::TimeTicks::FromInternalValue(4000); 754 timestamp = base::TimeTicks::FromInternalValue(4000);
755 EXPECT_EQ(4000, 755 EXPECT_EQ(4000,
756 timestamp.SnappedToNextTick(phase, interval).ToInternalValue()); 756 timestamp.SnappedToNextTick(phase, interval).ToInternalValue());
757 } 757 }
758 758
759 TEST(TimeTicks, SnappedToNextTickOverflow) { 759 TEST(TimeTicks, SnappedToNextTickOverflow) {
760 // int(big_timestamp / interval) < 0, so this causes a crash if the number of 760 // int(big_timestamp / interval) < 0, so this causes a crash if the number of
761 // intervals elapsed is attempted to be stored in an int. 761 // intervals elapsed is attempted to be stored in an int.
762 base::TimeTicks phase = base::TimeTicks::FromInternalValue(0); 762 base::TimeTicks phase = base::TimeTicks::FromInternalValue(0);
763 base::TimeDelta interval = base::TimeDelta::FromMicroseconds(4000); 763 base::TimeDelta interval = base::TimeDelta::FromInternalValue(4000);
764 base::TimeTicks big_timestamp = 764 base::TimeTicks big_timestamp =
765 base::TimeTicks::FromInternalValue(8635916564000); 765 base::TimeTicks::FromInternalValue(8635916564000);
766 766
767 EXPECT_EQ(8635916564000, 767 EXPECT_EQ(8635916564000,
768 big_timestamp.SnappedToNextTick(phase, interval).ToInternalValue()); 768 big_timestamp.SnappedToNextTick(phase, interval).ToInternalValue());
769 EXPECT_EQ(8635916564000, 769 EXPECT_EQ(8635916564000,
770 big_timestamp.SnappedToNextTick(big_timestamp, interval) 770 big_timestamp.SnappedToNextTick(big_timestamp, interval)
771 .ToInternalValue()); 771 .ToInternalValue());
772 } 772 }
773 773
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 1093
1094 TEST(TimeTicksLogging, DoesNotMakeStreamBad) { 1094 TEST(TimeTicksLogging, DoesNotMakeStreamBad) {
1095 std::ostringstream oss; 1095 std::ostringstream oss;
1096 oss << TimeTicks(); 1096 oss << TimeTicks();
1097 EXPECT_TRUE(oss.good()); 1097 EXPECT_TRUE(oss.good());
1098 } 1098 }
1099 1099
1100 } // namespace 1100 } // namespace
1101 1101
1102 } // namespace base 1102 } // namespace base
OLDNEW
« no previous file with comments | « base/time/time.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698