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

Side by Side Diff: base/time/time_win_unittest.cc

Issue 1467003002: Switch to static_assert in base/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: / Created 5 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 unified diff | Download patch
« no previous file with comments | « base/time/time_mac.cc ('k') | base/win/i18n.cc » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <windows.h> 5 #include <windows.h>
6 #include <mmsystem.h> 6 #include <mmsystem.h>
7 #include <process.h> 7 #include <process.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <limits> 10 #include <limits>
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 // Note: This is a somewhat arbitrary test. 180 // Note: This is a somewhat arbitrary test.
181 const int kLoops = 10000; 181 const int kLoops = 10000;
182 182
183 typedef TimeTicks (*TestFunc)(); 183 typedef TimeTicks (*TestFunc)();
184 struct TestCase { 184 struct TestCase {
185 TestFunc func; 185 TestFunc func;
186 const char *description; 186 const char *description;
187 }; 187 };
188 // Cheating a bit here: assumes sizeof(TimeTicks) == sizeof(Time) 188 // Cheating a bit here: assumes sizeof(TimeTicks) == sizeof(Time)
189 // in order to create a single test case list. 189 // in order to create a single test case list.
190 COMPILE_ASSERT(sizeof(TimeTicks) == sizeof(Time), 190 static_assert(sizeof(TimeTicks) == sizeof(Time),
191 test_only_works_with_same_sizes); 191 "TimeTicks and Time must be the same size");
192 std::vector<TestCase> cases; 192 std::vector<TestCase> cases;
193 cases.push_back({reinterpret_cast<TestFunc>(&Time::Now), "Time::Now"}); 193 cases.push_back({reinterpret_cast<TestFunc>(&Time::Now), "Time::Now"});
194 cases.push_back({&TimeTicks::Now, "TimeTicks::Now"}); 194 cases.push_back({&TimeTicks::Now, "TimeTicks::Now"});
195 195
196 if (ThreadTicks::IsSupported()) { 196 if (ThreadTicks::IsSupported()) {
197 ThreadTicks::WaitUntilInitialized(); 197 ThreadTicks::WaitUntilInitialized();
198 cases.push_back( 198 cases.push_back(
199 {reinterpret_cast<TestFunc>(&ThreadTicks::Now), "ThreadTicks::Now"}); 199 {reinterpret_cast<TestFunc>(&ThreadTicks::Now), "ThreadTicks::Now"});
200 } 200 }
201 201
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 static_cast<double>((converted_value - TimeTicks()).InMicroseconds()); 287 static_cast<double>((converted_value - TimeTicks()).InMicroseconds());
288 EXPECT_NEAR(expected_microseconds_since_origin, 288 EXPECT_NEAR(expected_microseconds_since_origin,
289 converted_microseconds_since_origin, 289 converted_microseconds_since_origin,
290 1.0) 290 1.0)
291 << "ticks=" << ticks << ", to be converted via logic path: " 291 << "ticks=" << ticks << ", to be converted via logic path: "
292 << (ticks < Time::kQPCOverflowThreshold ? "FAST" : "SAFE"); 292 << (ticks < Time::kQPCOverflowThreshold ? "FAST" : "SAFE");
293 } 293 }
294 } 294 }
295 295
296 } // namespace base 296 } // namespace base
OLDNEW
« no previous file with comments | « base/time/time_mac.cc ('k') | base/win/i18n.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698