| 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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 DART_UNUSED 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 |
| 299 // EXPECT and FAIL are equivalent to ASSERT and FATAL except that they do not |
| 300 // cause early termination of the unit test. This allows testing to proceed |
| 301 // further to be able to report other failures before reporting the overall |
| 302 // unit tests as failing. |
| 303 |
| 298 #define EXPECT(condition) \ | 304 #define EXPECT(condition) \ |
| 299 if (!(condition)) { \ | 305 if (!(condition)) { \ |
| 300 dart::Expect(__FILE__, __LINE__).Fail("expected: %s", #condition); \ | 306 dart::Expect(__FILE__, __LINE__).Fail("expected: %s", #condition); \ |
| 301 } | 307 } |
| 302 | 308 |
| 303 #define EXPECT_EQ(expected, actual) \ | 309 #define EXPECT_EQ(expected, actual) \ |
| 304 dart::Expect(__FILE__, __LINE__).Equals((expected), (actual)) | 310 dart::Expect(__FILE__, __LINE__).Equals((expected), (actual)) |
| 305 | 311 |
| 306 #define EXPECT_NE(not_expected, actual) \ | 312 #define EXPECT_NE(not_expected, actual) \ |
| 307 dart::Expect(__FILE__, __LINE__).NotEquals((not_expected), (actual)) | 313 dart::Expect(__FILE__, __LINE__).NotEquals((not_expected), (actual)) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 325 dart::Expect(__FILE__, __LINE__).LessEqual((left), (right)) | 331 dart::Expect(__FILE__, __LINE__).LessEqual((left), (right)) |
| 326 | 332 |
| 327 #define EXPECT_GT(left, right) \ | 333 #define EXPECT_GT(left, right) \ |
| 328 dart::Expect(__FILE__, __LINE__).GreaterThan((left), (right)) | 334 dart::Expect(__FILE__, __LINE__).GreaterThan((left), (right)) |
| 329 | 335 |
| 330 #define EXPECT_GE(left, right) \ | 336 #define EXPECT_GE(left, right) \ |
| 331 dart::Expect(__FILE__, __LINE__).GreaterEqual((left), (right)) | 337 dart::Expect(__FILE__, __LINE__).GreaterEqual((left), (right)) |
| 332 | 338 |
| 333 #define EXPECT_NOTNULL(ptr) \ | 339 #define EXPECT_NOTNULL(ptr) \ |
| 334 dart::Expect(__FILE__, __LINE__).NotNull((ptr)) | 340 dart::Expect(__FILE__, __LINE__).NotNull((ptr)) |
| 335 #endif | |
| 336 | 341 |
| 337 // TODO(iposva): provide a better way to get extra info on an EXPECT | 342 #define FAIL(error) \ |
| 338 // fail - you suggested EXPECT_EQ(expected, actual, msg_format, | |
| 339 // parameters_for_msg...), I quite like the google3 method | |
| 340 // EXPECT_EQ(a, b) << "more stuff here...". (benl). | |
| 341 | |
| 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 FAIL1(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 FAIL2(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 // defined(TESTING) |
| 352 |
| 351 #endif // PLATFORM_ASSERT_H_ | 353 #endif // PLATFORM_ASSERT_H_ |
| OLD | NEW |