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

Unified Diff: base/time_unittest.cc

Issue 496007: Make ProcessWatcher use kqueues on Mac. (Closed)
Patch Set: No need for a thread Created 11 years 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 | « base/time_posix.cc ('k') | chrome/browser/child_process_launcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/time_unittest.cc
diff --git a/base/time_unittest.cc b/base/time_unittest.cc
index 81daab0733debdf8867bfbeb32639d2489d56155..76b357a680101f2168263830bd28a9ccf8a9e905 100644
--- a/base/time_unittest.cc
+++ b/base/time_unittest.cc
@@ -142,6 +142,27 @@ TEST(TimeDelta, FromAndIn) {
EXPECT_EQ(13, TimeDelta::FromMicroseconds(13).InMicroseconds());
}
+#if defined(OS_POSIX)
+TEST(TimeDelta, TimeSpecConversion) {
+ struct timespec result = TimeDelta::FromSeconds(0).ToTimeSpec();
+ EXPECT_EQ(result.tv_sec, 0);
+ EXPECT_EQ(result.tv_nsec, 0);
+
+ result = TimeDelta::FromSeconds(1).ToTimeSpec();
+ EXPECT_EQ(result.tv_sec, 1);
+ EXPECT_EQ(result.tv_nsec, 0);
+
+ result = TimeDelta::FromMicroseconds(1).ToTimeSpec();
+ EXPECT_EQ(result.tv_sec, 0);
+ EXPECT_EQ(result.tv_nsec, 1000);
+
+ result = TimeDelta::FromMicroseconds(
+ Time::kMicrosecondsPerSecond + 1).ToTimeSpec();
+ EXPECT_EQ(result.tv_sec, 1);
+ EXPECT_EQ(result.tv_nsec, 1000);
+}
+#endif // OS_POSIX
+
// Our internal time format is serialized in things like databases, so it's
// important that it's consistent across all our platforms. We use the 1601
// Windows epoch as the internal format across all platforms.
« no previous file with comments | « base/time_posix.cc ('k') | chrome/browser/child_process_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698