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

Unified Diff: base/time/time_unittest.cc

Issue 797893003: [Windows] One TimeTicks clock: efficient/reliable high-res, with low-res fallback. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: base/time/time_unittest.cc
diff --git a/base/time/time_unittest.cc b/base/time/time_unittest.cc
index 16d6fe9c3a2918f19d109318f8af605845d3259a..07b1e6b77e704b25fc5198a8c3d4756245ea51aa 100644
--- a/base/time/time_unittest.cc
+++ b/base/time/time_unittest.cc
@@ -6,6 +6,7 @@
#include <time.h>
+#include <limits>
#include <string>
#include "base/compiler_specific.h"
@@ -642,12 +643,10 @@ TEST(TimeTicks, Deltas) {
}
static void HighResClockTest(TimeTicks (*GetTicks)()) {
-#if defined(OS_WIN)
// HighResNow doesn't work on some systems. Since the product still works
// even if it doesn't work, it makes this entire test questionable.
- if (!TimeTicks::IsHighResClockWorking())
+ if (!TimeTicks::IsHighResolution())
return;
-#endif
// Why do we loop here?
// We're trying to measure that intervals increment in a VERY small amount
@@ -792,6 +791,26 @@ std::string AnyToString(Any any) {
return oss.str();
}
+TEST(TimeDelta, Magnitude) {
+ const int64 zero = 0;
+ EXPECT_EQ(TimeDelta::FromMicroseconds(zero),
+ TimeDelta::FromMicroseconds(zero).magnitude());
+
+ const int64 one = 1;
+ const int64 negative_one = -1;
+ EXPECT_EQ(TimeDelta::FromMicroseconds(one),
+ TimeDelta::FromMicroseconds(one).magnitude());
+ EXPECT_EQ(TimeDelta::FromMicroseconds(one),
+ TimeDelta::FromMicroseconds(negative_one).magnitude());
+
+ const int64 max_int64_minus_one = std::numeric_limits<int64>::max() - 1;
+ const int64 min_int64_plus_two = std::numeric_limits<int64>::min() + 2;
+ EXPECT_EQ(TimeDelta::FromMicroseconds(max_int64_minus_one),
+ TimeDelta::FromMicroseconds(max_int64_minus_one).magnitude());
+ EXPECT_EQ(TimeDelta::FromMicroseconds(max_int64_minus_one),
+ TimeDelta::FromMicroseconds(min_int64_plus_two).magnitude());
+}
+
TEST(TimeDeltaLogging, DCheckEqCompiles) {
DCHECK_EQ(TimeDelta(), TimeDelta());
}
« no previous file with comments | « base/time/time_posix.cc ('k') | base/time/time_win.cc » ('j') | base/time/time_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698