diff options
author | Stefan <29021710+Saalvage@users.noreply.github.com> | 2022-01-15 22:54:14 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-15 22:54:14 +0300 |
commit | d9c290a2698019c83102e292aee42e798ac911f1 (patch) | |
tree | faf7e4f8f4390e1ecee39c6a42a329ed2d3f6590 /examples | |
parent | 58f3ec87df8d10de97b5a28cfe9cdc0fb244b001 (diff) |
Feature config ret vals (#589)
* Implement #588
* Move DOCTEST_FUNC_EMPTY outside of relevant scopes
* Adjust docs
* Update assertions.md
* Update assertions.md
Diffstat (limited to 'examples')
-rw-r--r-- | examples/all_features/assert_returns_disabled.cpp | 10 | ||||
-rw-r--r-- | examples/all_features/assertion_macros.cpp | 1 |
2 files changed, 7 insertions, 4 deletions
diff --git a/examples/all_features/assert_returns_disabled.cpp b/examples/all_features/assert_returns_disabled.cpp index d2774b4a..368c1e6f 100644 --- a/examples/all_features/assert_returns_disabled.cpp +++ b/examples/all_features/assert_returns_disabled.cpp @@ -1,3 +1,4 @@ +#define DOCTEST_CONFIG_ASSERTS_RETURN_VALUES #include <doctest/doctest.h> #include <cstdio> @@ -18,10 +19,11 @@ static int test_disabled_var_ = [] { if (TEST_FLIP ^ CHECK_UNARY(true)) { TEST_FAIL(); } if (TEST_FLIP ^ CHECK_UNARY_FALSE(false)) { TEST_FAIL(); } #ifndef DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS - if (TEST_FLIP ^ CHECK_THROWS([] { throw 2; }())) { TEST_FAIL(); } - if (TEST_FLIP ^ CHECK_THROWS_AS([] { throw 2; }(), int)) { TEST_FAIL(); } - if (TEST_FLIP ^ CHECK_NOTHROW([]{ }())) { TEST_FAIL(); } - if (CHECK_THROWS_WITH([] { throw 2; }(), "2")) { TEST_FAIL(); } + int i = 2; (void)i; + if (TEST_FLIP ^ CHECK_THROWS([=] { throw i; }())) { TEST_FAIL(); } + if (TEST_FLIP ^ CHECK_THROWS_AS([=] { throw i; }(), int)) { TEST_FAIL(); } + if (TEST_FLIP ^ CHECK_NOTHROW([=]{ }())) { TEST_FAIL(); } + if (CHECK_THROWS_WITH([=] { throw i; }(), "2")) { TEST_FAIL(); } #endif return 0; diff --git a/examples/all_features/assertion_macros.cpp b/examples/all_features/assertion_macros.cpp index 524751ca..f0fbe9b0 100644 --- a/examples/all_features/assertion_macros.cpp +++ b/examples/all_features/assertion_macros.cpp @@ -1,3 +1,4 @@ +#define DOCTEST_CONFIG_ASSERTS_RETURN_VALUES #include <doctest/doctest.h> #include "header.h" |