diff options
author | HÃ¥vard Pettersen <3535158+havardpe@users.noreply.github.com> | 2021-02-02 13:05:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-02 13:05:04 +0100 |
commit | 8e2aeae47fcf3b21d13fef8794dbac1b27728e62 (patch) | |
tree | 8260cd151706db132e3f90e53b357e630cb53d85 /vespalib | |
parent | d2b40aa63fb94282177771b0949a5a83e82bfb85 (diff) | |
parent | add5dcb82527b280208a9526a0dd21ba3f01e271 (diff) |
Merge pull request #16330 from vespa-engine/arnej/use-genspec-in-unit-tests-2
Arnej/use genspec in unit tests 2
Diffstat (limited to 'vespalib')
-rw-r--r-- | vespalib/src/vespa/vespalib/gtest/gtest.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/vespalib/src/vespa/vespalib/gtest/gtest.h b/vespalib/src/vespa/vespalib/gtest/gtest.h index 87362687103..f4aaa670e76 100644 --- a/vespalib/src/vespa/vespalib/gtest/gtest.h +++ b/vespalib/src/vespa/vespalib/gtest/gtest.h @@ -26,3 +26,16 @@ main(int argc, char* argv[]) \ #else #define VESPA_GTEST_TYPED_TEST_SUITE TYPED_TEST_CASE #endif + +#define VESPA_EXPECT_EXCEPTION(TRY_BLOCK, EXCEPTION_TYPE, MESSAGE) \ + try { \ + TRY_BLOCK; \ + FAIL() << "exception '" << MESSAGE << "' not thrown at all!"; \ + } catch(EXCEPTION_TYPE& e) { \ + EXPECT_TRUE(contains(stringref(e.what()), stringref(MESSAGE))) << \ + " e.what(): " << e.what() << "\n"; \ + } catch(...) { \ + FAIL() << "wrong exception type thrown"; \ + throw; \ + } + |