OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef PLATFORM_ASSERT_H_ | 5 #ifndef PLATFORM_ASSERT_H_ |
6 #define PLATFORM_ASSERT_H_ | 6 #define PLATFORM_ASSERT_H_ |
7 | 7 |
8 // TODO(5411406): include sstream for now, once we have a Utils::toString() | 8 // TODO(5411406): include sstream for now, once we have a Utils::toString() |
9 // implemented for all the primitive types we can replace the usage of | 9 // implemented for all the primitive types we can replace the usage of |
10 // sstream by Utils::toString() | 10 // sstream by Utils::toString() |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 // COMPILE_ASSERT(sizeof(foo) < 128, foo_too_large); | 282 // COMPILE_ASSERT(sizeof(foo) < 128, foo_too_large); |
283 // | 283 // |
284 // The second argument to the macro is the name of the variable. If | 284 // The second argument to the macro is the name of the variable. If |
285 // the expression is false, most compilers will issue a warning/error | 285 // the expression is false, most compilers will issue a warning/error |
286 // containing the name of the variable. | 286 // containing the name of the variable. |
287 | 287 |
288 template <bool> | 288 template <bool> |
289 struct CompileAssert { | 289 struct CompileAssert { |
290 }; | 290 }; |
291 | 291 |
292 #define COMPILE_ASSERT(expr, msg) \ | 292 #define COMPILE_ASSERT(expr, msg) \ |
293 typedef CompileAssert<(static_cast<bool>(expr))> \ | 293 DART_UNUSED typedef CompileAssert<(static_cast<bool>(expr))> \ |
294 msg[static_cast<bool>(expr) ? 1 : -1] | 294 msg[static_cast<bool>(expr) ? 1 : -1] |
295 | 295 |
296 | 296 |
297 #if defined(TESTING) | 297 #if defined(TESTING) |
298 #define EXPECT(condition) \ | 298 #define EXPECT(condition) \ |
299 if (!(condition)) { \ | 299 if (!(condition)) { \ |
300 dart::Expect(__FILE__, __LINE__).Fail("expected: %s", #condition); \ | 300 dart::Expect(__FILE__, __LINE__).Fail("expected: %s", #condition); \ |
301 } | 301 } |
302 | 302 |
303 #define EXPECT_EQ(expected, actual) \ | 303 #define EXPECT_EQ(expected, actual) \ |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 #define WARN(error) \ | 342 #define WARN(error) \ |
343 dart::Expect(__FILE__, __LINE__).Fail("%s", error) | 343 dart::Expect(__FILE__, __LINE__).Fail("%s", error) |
344 | 344 |
345 #define WARN1(format, p1) \ | 345 #define WARN1(format, p1) \ |
346 dart::Expect(__FILE__, __LINE__).Fail(format, (p1)) | 346 dart::Expect(__FILE__, __LINE__).Fail(format, (p1)) |
347 | 347 |
348 #define WARN2(format, p1, p2) \ | 348 #define WARN2(format, p1, p2) \ |
349 dart::Expect(__FILE__, __LINE__).Fail(format, (p1), (p2)) | 349 dart::Expect(__FILE__, __LINE__).Fail(format, (p1), (p2)) |
350 | 350 |
351 #endif // PLATFORM_ASSERT_H_ | 351 #endif // PLATFORM_ASSERT_H_ |
OLD | NEW |