enum_name
Loading...
Searching...
No Matches
assert_returns_disabled.cpp
1#define DOCTEST_CONFIG_ASSERTS_RETURN_VALUES
2#include <doctest/doctest.h>
3
4DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN
5#include <iostream>
6DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END
7
8#ifndef TEST_FLIP
9#define TEST_FLIP 0
10#endif
11
12#define TEST_FAIL() std::cout << "FAILED ON: " << __LINE__ \
13 << "(" << (TEST_FLIP ? "EVALUATED" : "DISABLED") << ")" << std::endl
14
15static int test_disabled_var_ = [] { // NOLINT
16 // none may return true
17 if (TEST_FLIP ^ CHECK(0 == 0)) { TEST_FAIL(); }
18 if (TEST_FLIP ^ CHECK_FALSE(0 != 0)) { TEST_FAIL(); }
19 if (TEST_FLIP ^ CHECK_EQ(0, 0)) { TEST_FAIL(); }
20 if (TEST_FLIP ^ CHECK_UNARY(true)) { TEST_FAIL(); }
21 if (TEST_FLIP ^ CHECK_UNARY_FALSE(false)) { TEST_FAIL(); }
22#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS
23 int i = 2; (void)i;
24 if (TEST_FLIP ^ CHECK_THROWS([=] { throw i; }())) { TEST_FAIL(); }
25 if (TEST_FLIP ^ CHECK_THROWS_AS([=] { throw i; }(), int)) { TEST_FAIL(); }
26 if (TEST_FLIP ^ CHECK_NOTHROW([=]{ }())) { TEST_FAIL(); }
27#endif
28
29 return 0;
30}();