| 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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 | 262 |
| 263 // In order to avoid variable unused warnings for code that only uses | 263 // In order to avoid variable unused warnings for code that only uses |
| 264 // a variable in an ASSERT or EXPECT, we make sure to use the macro | 264 // a variable in an ASSERT or EXPECT, we make sure to use the macro |
| 265 // argument. | 265 // argument. |
| 266 #define ASSERT(condition) do {} while (false && (condition)) | 266 #define ASSERT(condition) do {} while (false && (condition)) |
| 267 | 267 |
| 268 #define DEBUG_ASSERT(cond) | 268 #define DEBUG_ASSERT(cond) |
| 269 | 269 |
| 270 #endif // if defined(DEBUG) | 270 #endif // if defined(DEBUG) |
| 271 | 271 |
| 272 #define RELEASE_ASSERT(cond) \ |
| 273 do { \ |
| 274 if (!(cond)) dart::Assert(__FILE__, __LINE__).Fail("expected: %s", #cond); \ |
| 275 } while (false) |
| 276 |
| 272 | 277 |
| 273 // The COMPILE_ASSERT macro can be used to verify that a compile time | 278 // The COMPILE_ASSERT macro can be used to verify that a compile time |
| 274 // expression is true. For example, you could use it to verify the | 279 // expression is true. For example, you could use it to verify the |
| 275 // size of a static array: | 280 // size of a static array: |
| 276 // | 281 // |
| 277 // COMPILE_ASSERT(ARRAYSIZE(content_type_names) == CONTENT_NUM_TYPES); | 282 // COMPILE_ASSERT(ARRAYSIZE(content_type_names) == CONTENT_NUM_TYPES); |
| 278 // | 283 // |
| 279 // or to make sure a struct is smaller than a certain size: | 284 // or to make sure a struct is smaller than a certain size: |
| 280 // | 285 // |
| 281 // COMPILE_ASSERT(sizeof(foo) < 128); | 286 // COMPILE_ASSERT(sizeof(foo) < 128); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 | 348 |
| 344 #define FAIL1(format, p1) \ | 349 #define FAIL1(format, p1) \ |
| 345 dart::Expect(__FILE__, __LINE__).Fail(format, (p1)) | 350 dart::Expect(__FILE__, __LINE__).Fail(format, (p1)) |
| 346 | 351 |
| 347 #define FAIL2(format, p1, p2) \ | 352 #define FAIL2(format, p1, p2) \ |
| 348 dart::Expect(__FILE__, __LINE__).Fail(format, (p1), (p2)) | 353 dart::Expect(__FILE__, __LINE__).Fail(format, (p1), (p2)) |
| 349 | 354 |
| 350 #endif // defined(TESTING) | 355 #endif // defined(TESTING) |
| 351 | 356 |
| 352 #endif // PLATFORM_ASSERT_H_ | 357 #endif // PLATFORM_ASSERT_H_ |
| OLD | NEW |