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

Side by Side Diff: test/cctest/test-time.cc

Issue 23748003: Cleanup Semaphore class. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Build fix for Mac OS X. Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-threads.cc ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 CHECK_EQ(static_cast<int64_t>(13), TimeDelta::FromSeconds(13).InSeconds()); 49 CHECK_EQ(static_cast<int64_t>(13), TimeDelta::FromSeconds(13).InSeconds());
50 CHECK_EQ(13.0, TimeDelta::FromSeconds(13).InSecondsF()); 50 CHECK_EQ(13.0, TimeDelta::FromSeconds(13).InSecondsF());
51 CHECK_EQ(static_cast<int64_t>(13), 51 CHECK_EQ(static_cast<int64_t>(13),
52 TimeDelta::FromMilliseconds(13).InMilliseconds()); 52 TimeDelta::FromMilliseconds(13).InMilliseconds());
53 CHECK_EQ(13.0, TimeDelta::FromMilliseconds(13).InMillisecondsF()); 53 CHECK_EQ(13.0, TimeDelta::FromMilliseconds(13).InMillisecondsF());
54 CHECK_EQ(static_cast<int64_t>(13), 54 CHECK_EQ(static_cast<int64_t>(13),
55 TimeDelta::FromMicroseconds(13).InMicroseconds()); 55 TimeDelta::FromMicroseconds(13).InMicroseconds());
56 } 56 }
57 57
58 58
59 #if V8_OS_MACOSX
60 TEST(TimeDeltaFromMachTimespec) {
61 TimeDelta null = TimeDelta();
62 CHECK(null == TimeDelta::FromMachTimespec(null.ToMachTimespec()));
63 TimeDelta delta1 = TimeDelta::FromMilliseconds(42);
64 CHECK(delta1 == TimeDelta::FromMachTimespec(delta1.ToMachTimespec()));
65 TimeDelta delta2 = TimeDelta::FromDays(42);
66 CHECK(delta2 == TimeDelta::FromMachTimespec(delta2.ToMachTimespec()));
67 }
68 #endif
69
70
59 TEST(TimeJsTime) { 71 TEST(TimeJsTime) {
60 Time t = Time::FromJsTime(700000.3); 72 Time t = Time::FromJsTime(700000.3);
61 CHECK_EQ(700000.3, t.ToJsTime()); 73 CHECK_EQ(700000.3, t.ToJsTime());
62 } 74 }
63 75
64 76
65 #if V8_OS_POSIX 77 #if V8_OS_POSIX
66 TEST(TimeFromTimeVal) { 78 TEST(TimeFromTimespec) {
79 Time null;
80 CHECK(null.IsNull());
81 CHECK(null == Time::FromTimespec(null.ToTimespec()));
82 Time now = Time::Now();
83 CHECK(now == Time::FromTimespec(now.ToTimespec()));
84 Time now_sys = Time::NowFromSystemTime();
85 CHECK(now_sys == Time::FromTimespec(now_sys.ToTimespec()));
86 Time unix_epoch = Time::UnixEpoch();
87 CHECK(unix_epoch == Time::FromTimespec(unix_epoch.ToTimespec()));
88 Time max = Time::Max();
89 CHECK(max.IsMax());
90 CHECK(max == Time::FromTimespec(max.ToTimespec()));
91 }
92
93
94 TEST(TimeFromTimeval) {
67 Time null; 95 Time null;
68 CHECK(null.IsNull()); 96 CHECK(null.IsNull());
69 CHECK(null == Time::FromTimeval(null.ToTimeval())); 97 CHECK(null == Time::FromTimeval(null.ToTimeval()));
70 Time now = Time::Now(); 98 Time now = Time::Now();
71 CHECK(now == Time::FromTimeval(now.ToTimeval())); 99 CHECK(now == Time::FromTimeval(now.ToTimeval()));
72 Time now_sys = Time::NowFromSystemTime(); 100 Time now_sys = Time::NowFromSystemTime();
73 CHECK(now_sys == Time::FromTimeval(now_sys.ToTimeval())); 101 CHECK(now_sys == Time::FromTimeval(now_sys.ToTimeval()));
74 Time unix_epoch = Time::UnixEpoch(); 102 Time unix_epoch = Time::UnixEpoch();
75 CHECK(unix_epoch == Time::FromTimeval(unix_epoch.ToTimeval())); 103 CHECK(unix_epoch == Time::FromTimeval(unix_epoch.ToTimeval()));
76 Time max = Time::Max(); 104 Time max = Time::Max();
(...skipping 30 matching lines...) Expand all
107 TimeTicks normal_ticks = TimeTicks::Now(); 135 TimeTicks normal_ticks = TimeTicks::Now();
108 TimeTicks highres_ticks = TimeTicks::HighResNow(); 136 TimeTicks highres_ticks = TimeTicks::HighResNow();
109 CHECK_GE(normal_ticks, previous_normal_ticks); 137 CHECK_GE(normal_ticks, previous_normal_ticks);
110 CHECK_GE((normal_ticks - previous_normal_ticks).InMicroseconds(), 0); 138 CHECK_GE((normal_ticks - previous_normal_ticks).InMicroseconds(), 0);
111 CHECK_GE(highres_ticks, previous_highres_ticks); 139 CHECK_GE(highres_ticks, previous_highres_ticks);
112 CHECK_GE((highres_ticks - previous_highres_ticks).InMicroseconds(), 0); 140 CHECK_GE((highres_ticks - previous_highres_ticks).InMicroseconds(), 0);
113 previous_normal_ticks = normal_ticks; 141 previous_normal_ticks = normal_ticks;
114 previous_highres_ticks = highres_ticks; 142 previous_highres_ticks = highres_ticks;
115 } 143 }
116 } 144 }
OLDNEW
« no previous file with comments | « test/cctest/test-threads.cc ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698