diff options
author | Joshua Haberman <jhaberman@gmail.com> | 2019-01-15 03:37:34 -0800 |
---|---|---|
committer | Joshua Haberman <jhaberman@gmail.com> | 2019-01-15 03:37:34 -0800 |
commit | 754b9f1cfdf59104fa62cfaf99f21e5a817d281b (patch) | |
tree | 4272965f29708dcdc72fef096d85569c1dd59643 /tests/test_util.h | |
parent | cb26d883d1290ed258e5594454c2ffe0526b13f9 (diff) |
All tests pass again!
Diffstat (limited to 'tests/test_util.h')
-rw-r--r-- | tests/test_util.h | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/tests/test_util.h b/tests/test_util.h index 04ca3fb..680673d 100644 --- a/tests/test_util.h +++ b/tests/test_util.h @@ -32,21 +32,6 @@ class VerboseParserEnvironment { /* Pass verbose=true to print detailed diagnostics to stderr. */ VerboseParserEnvironment(bool verbose) : verbose_(verbose) {} - static bool OnError(void *ud, const upb::Status* status) { - VerboseParserEnvironment* env = static_cast<VerboseParserEnvironment*>(ud); - - if (env->expect_error_ && env->verbose_) { - fprintf(stderr, "Encountered error, as expected: "); - } else if (!env->expect_error_) { - fprintf(stderr, "Encountered unexpected error: "); - } else { - return false; - } - - fprintf(stderr, "%s\n", status->error_message()); - return false; - } - void Reset(const char *buf, size_t len, bool may_skip, bool expect_error) { buf_ = buf; len_ = len; @@ -99,6 +84,17 @@ class VerboseParserEnvironment { return false; } + if (!status_.ok()) { + if (expect_error_ && verbose_) { + fprintf(stderr, "Encountered error, as expected: %s", + status_.error_message()); + } else if (!expect_error_) { + fprintf(stderr, "Encountered unexpected error: %s", + status_.error_message()); + return false; + } + } + return true; } @@ -175,6 +171,7 @@ class VerboseParserEnvironment { bool SkippedWithNull() { return skipped_with_null_; } upb::Arena* arena() { return &arena_; } + upb::Status* status() { return &status_; } private: upb::Arena arena_; |