Chromium Code Reviews| Index: base/time/time_unittest.cc |
| diff --git a/base/time/time_unittest.cc b/base/time/time_unittest.cc |
| index 16d6fe9c3a2918f19d109318f8af605845d3259a..fc07d25df3ce9d833914067ab52922dd1cdf2f51 100644 |
| --- a/base/time/time_unittest.cc |
| +++ b/base/time/time_unittest.cc |
| @@ -6,7 +6,9 @@ |
| #include <time.h> |
| +#include <limits> |
| #include <string> |
| +#include <type_traits> |
| #include "base/compiler_specific.h" |
| #include "base/logging.h" |
| @@ -642,12 +644,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 +792,21 @@ std::string AnyToString(Any any) { |
| return oss.str(); |
| } |
| +// Paranoia test: Since std::abs(int64) is new to C++11, make sure incomplete |
| +// toolchains don't silently pull in an alternate overload when the needed |
| +// function is missing. |
| +TEST(TimeDelta, ParanoidAboutAbsFunction) { |
|
brianderson
2015/01/07 00:53:44
Do you plan to remove this test before landing?
miu
2015/01/07 05:22:45
The trybots on PS1 forced me to change tactics. S
|
| + int64 max_int64_minus_one = std::numeric_limits<int64>::max() - 1; |
| + int64 min_int64_plus_two = std::numeric_limits<int64>::min() + 2; |
| + static_assert(std::is_same<decltype(max_int64_minus_one), |
| + decltype(std::abs(max_int64_minus_one))>::value, |
| + "compiler is choosing incorrect std::abs() overload"); |
| + 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()); |
| } |