diff options
author | Josh Haberman <haberman@google.com> | 2013-02-15 16:27:18 -0800 |
---|---|---|
committer | Josh Haberman <haberman@google.com> | 2013-02-15 16:27:18 -0800 |
commit | 7d3e2bd2c4cfd1296d1d6f996d7548de26540d41 (patch) | |
tree | b4b35967b3322c65cfb1a32220e8718de09d85fc /tests/upb_test.h | |
parent | ea198bdcf947ba4bd51474bdd4f7b82b5e4cf41d (diff) |
Sync with 8 months of Google-internal development.
Many things have changed and been simplified.
The memory-management story for upb_def and upb_handlers
is much more robust; upb_def and upb_handlers should be
fairly stable interfaces now. There is still much work
to do for the runtime component (upb_sink).
Diffstat (limited to 'tests/upb_test.h')
-rw-r--r-- | tests/upb_test.h | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/tests/upb_test.h b/tests/upb_test.h index 652977b..60714ba 100644 --- a/tests/upb_test.h +++ b/tests/upb_test.h @@ -9,25 +9,35 @@ #include <stdio.h> #include <stdlib.h> +#include <stdint.h> #ifdef __cplusplus extern "C" { #endif int num_assertions = 0; +uint32_t testhash = 0; + +#define PRINT_FAILURE(expr) \ + fprintf(stderr, "Assertion failed: %s:%d\n", __FILE__, __LINE__); \ + fprintf(stderr, "expr: %s\n", #expr); \ + if (testhash) { \ + fprintf(stderr, "assertion failed running test %x. " \ + "Run with the arg %x to run only this test.\n", \ + testhash, testhash); \ + } + #define ASSERT(expr) do { \ ++num_assertions; \ if (!(expr)) { \ - fprintf(stderr, "Assertion failed: %s:%d\n", __FILE__, __LINE__); \ - fprintf(stderr, "expr: %s\n", #expr); \ + PRINT_FAILURE(expr) \ abort(); \ } \ } while (0) #define ASSERT_NOCOUNT(expr) do { \ if (!(expr)) { \ - fprintf(stderr, "Assertion failed: %s:%d\n", __FILE__, __LINE__); \ - fprintf(stderr, "expr: %s\n", #expr); \ + PRINT_FAILURE(expr) \ abort(); \ } \ } while (0) @@ -35,8 +45,7 @@ int num_assertions = 0; #define ASSERT_STATUS(expr, status) do { \ ++num_assertions; \ if (!(expr)) { \ - fprintf(stderr, "Assertion failed: %s:%d\n", __FILE__, __LINE__); \ - fprintf(stderr, "expr: %s\n", #expr); \ + PRINT_FAILURE(expr) \ fprintf(stderr, "failed status: %s\n", upb_status_getstr(status)); \ abort(); \ } \ |