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

Unified Diff: base/time/time_unittest.cc

Issue 2241603002: Add explicit TimeDelta constexpr copy constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« base/time/time.h ('K') | « base/time/time.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/time/time_unittest.cc
diff --git a/base/time/time_unittest.cc b/base/time/time_unittest.cc
index 4f47d56522b0d30b883f86b236110ca9722750f5..8e880edf5182105b8f72766847554dc3da2d1730 100644
--- a/base/time/time_unittest.cc
+++ b/base/time/time_unittest.cc
@@ -21,6 +21,11 @@ namespace base {
namespace {
+// For TimeDelta::ConstexprInitialization
+enum { kExpectedDeltaInMilliseconds = 10 };
miu 2016/08/11 21:48:56 Is it necessary for this to be an enum to trigger
liberato (no reviews please) 2016/08/11 22:10:35 it's not necessary. originally, i had it as const
+constexpr TimeDelta kConstexprTimeDelta =
+ TimeDelta::FromMilliseconds(kExpectedDeltaInMilliseconds);
+
TEST(TimeTestOutOfBounds, FromExplodedOutOfBoundsTime) {
// FromUTCExploded must set time to Time(0) and failure, if the day is set to
// 31 on a 28-30 day month. Test |exploded| returns Time(0) on 31st of
@@ -1093,6 +1098,11 @@ TEST(TimeDelta, Overflows) {
EXPECT_EQ(one_second, (ticks_now + one_second) - ticks_now);
}
+TEST(TimeDelta, ConstexprInitialization) {
miu 2016/08/11 21:48:56 Please put these changes in time_win_unittest.cc i
liberato (no reviews please) 2016/08/11 22:10:35 Done.
+ // Make sure that TimeDelta works around crbug.com/635974
+ EXPECT_EQ(kExpectedDeltaInMilliseconds, kConstexprTimeDelta.InMilliseconds());
+}
+
TEST(TimeDeltaLogging, DCheckEqCompiles) {
DCHECK_EQ(TimeDelta(), TimeDelta());
}
« base/time/time.h ('K') | « base/time/time.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698