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

Unified Diff: tests/Time.cpp

Issue 714633002: Fix SkTime::GetDateTime Posix implementation, add unit test. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: limit the year check in the test to the next 50 years Created 6 years, 1 month 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
« no previous file with comments | « src/ports/SkTime_Unix.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/Time.cpp
diff --git a/tests/Time.cpp b/tests/Time.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..65c01e26ffc2136e706fa941ceb57579cb85af30
--- /dev/null
+++ b/tests/Time.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkTime.h"
+#include "Test.h"
+
+// Sanity checks for the GetDateTime function.
+DEF_TEST(Time_GetDateTime, r) {
+ SkTime::DateTime dateTime;
+ SkTime::GetDateTime(&dateTime);
+
+ // TODO(future generation): update these values.
+ const uint16_t kMinimumSaneYear = 2014;
+ const uint16_t kMaximumSaneYear = 2064;
+ REPORTER_ASSERT(r, dateTime.fYear >= kMinimumSaneYear);
+ REPORTER_ASSERT(r, dateTime.fYear <= kMaximumSaneYear);
+
+ REPORTER_ASSERT(r, dateTime.fMonth >= 1);
+ REPORTER_ASSERT(r, dateTime.fMonth <= 12);
+
+ REPORTER_ASSERT(r, dateTime.fDay >= 1);
+ REPORTER_ASSERT(r, dateTime.fDay <= 31);
+
+ REPORTER_ASSERT(r, dateTime.fHour <= 23);
+
+ REPORTER_ASSERT(r, dateTime.fMinute <= 59);
+
+ REPORTER_ASSERT(r, dateTime.fSecond <= 60); // leap seconds are 23:59:60
+}
« no previous file with comments | « src/ports/SkTime_Unix.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698