Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/onqtam/doctest.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoronqtam <vik.kirilov@gmail.com>2019-09-22 16:33:47 +0300
committeronqtam <vik.kirilov@gmail.com>2019-09-22 21:14:41 +0300
commit5856bb93a63c43c6562eb2773d9a3d4d6f677f15 (patch)
treef6406fc4809d1ebf79d50345c2da0d06d80887c9
parent33cc7f9b622197eaea5d8aeb1fb206d0fe9f039f (diff)
implemented <LEVEL>_THROWS_WITH_AS() assert which combines <LEVEL>_THROWS_WITH with <LEVEL>_THROWS_AS - fixed #295
-rw-r--r--doc/markdown/assertions.md8
-rw-r--r--doctest/doctest.h119
-rw-r--r--doctest/parts/doctest.cpp51
-rw-r--r--doctest/parts/doctest_fwd.h68
-rw-r--r--examples/all_features/assertion_macros.cpp26
-rw-r--r--examples/all_features/doctest_proxy.h4
-rw-r--r--examples/all_features/test_output/assertion_macros.cpp.txt44
-rw-r--r--examples/all_features/test_output/assertion_macros.cpp_xml.txt148
-rw-r--r--examples/all_features/test_output/filter_2.txt2
-rw-r--r--examples/all_features/test_output/filter_2_xml.txt8
10 files changed, 377 insertions, 101 deletions
diff --git a/doc/markdown/assertions.md b/doc/markdown/assertions.md
index 0d5bdd6d..82fe18a1 100644
--- a/doc/markdown/assertions.md
+++ b/doc/markdown/assertions.md
@@ -105,6 +105,14 @@ Expects that an exception is thrown during evaluation of the expression and is s
CHECK_THROWS_WITH(func(), "invalid operation!");
```
+- ```<LEVEL>_THROWS_WITH_AS(expression, c_string, exception_type)```
+
+This is a combination of ```<LEVEL>_THROWS_WITH``` and ```<LEVEL>_THROWS_AS```.
+
+```c++
+CHECK_THROWS_WITH_AS(func(), "invalid operation!", std::runtime_error);
+```
+
- ```<LEVEL>_NOTHROW(expression)```
Expects that no exception is thrown during evaluation of the expression.
diff --git a/doctest/doctest.h b/doctest/doctest.h
index a1c6df33..037dd56f 100644
--- a/doctest/doctest.h
+++ b/doctest/doctest.h
@@ -594,6 +594,10 @@ namespace assertType {
DT_WARN_THROWS_WITH = is_throws_with | is_warn,
DT_CHECK_THROWS_WITH = is_throws_with | is_check,
DT_REQUIRE_THROWS_WITH = is_throws_with | is_require,
+
+ DT_WARN_THROWS_WITH_AS = is_throws_with | is_throws_as | is_warn,
+ DT_CHECK_THROWS_WITH_AS = is_throws_with | is_throws_as | is_check,
+ DT_REQUIRE_THROWS_WITH_AS = is_throws_with | is_throws_as | is_require,
DT_WARN_NOTHROW = is_nothrow | is_warn,
DT_CHECK_NOTHROW = is_nothrow | is_check,
@@ -674,6 +678,7 @@ struct DOCTEST_INTERFACE AssertData
// for specific exception-related asserts
bool m_threw_as;
const char* m_exception_type;
+ const char* m_exception_string;
DOCTEST_DECLARE_DEFAULTS(AssertData);
DOCTEST_DELETE_COPIES(AssertData);
@@ -1339,7 +1344,7 @@ namespace detail {
struct DOCTEST_INTERFACE ResultBuilder : public AssertData
{
ResultBuilder(assertType::Enum at, const char* file, int line, const char* expr,
- const char* exception_type = "");
+ const char* exception_type = "", const char* exception_string = "");
DOCTEST_DECLARE_DEFAULTS(ResultBuilder);
DOCTEST_DELETE_COPIES(ResultBuilder);
@@ -2074,11 +2079,11 @@ int registerReporter(const char* name, int priority, bool isReporter) {
#define DOCTEST_REQUIRE_FALSE_MESSAGE(cond, msg) do { DOCTEST_INFO(msg); DOCTEST_ASSERT_IMPLEMENT_2(DT_REQUIRE_FALSE, cond); } while((void)0, 0)
// clang-format on
-#define DOCTEST_ASSERT_THROWS_AS(expr, assert_type, ...) \
+#define DOCTEST_ASSERT_THROWS_AS(expr, assert_type, message, ...) \
do { \
if(!doctest::getContextOptions()->no_throw) { \
doctest::detail::ResultBuilder _DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \
- __LINE__, #expr, #__VA_ARGS__); \
+ __LINE__, #expr, #__VA_ARGS__, message); \
try { \
DOCTEST_CAST_TO_VOID(expr) \
} catch(const doctest::detail::remove_const< \
@@ -2094,7 +2099,7 @@ int registerReporter(const char* name, int priority, bool isReporter) {
do { \
if(!doctest::getContextOptions()->no_throw) { \
doctest::detail::ResultBuilder _DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \
- __LINE__, #expr, __VA_ARGS__); \
+ __LINE__, #expr, "", __VA_ARGS__); \
try { \
DOCTEST_CAST_TO_VOID(expr) \
} catch(...) { _DOCTEST_RB.translateException(); } \
@@ -2117,14 +2122,18 @@ int registerReporter(const char* name, int priority, bool isReporter) {
#define DOCTEST_CHECK_THROWS(expr) DOCTEST_ASSERT_THROWS_WITH(expr, DT_CHECK_THROWS, "")
#define DOCTEST_REQUIRE_THROWS(expr) DOCTEST_ASSERT_THROWS_WITH(expr, DT_REQUIRE_THROWS, "")
-#define DOCTEST_WARN_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_WARN_THROWS_AS, __VA_ARGS__)
-#define DOCTEST_CHECK_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_CHECK_THROWS_AS, __VA_ARGS__)
-#define DOCTEST_REQUIRE_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_REQUIRE_THROWS_AS, __VA_ARGS__)
+#define DOCTEST_WARN_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_WARN_THROWS_AS, "", __VA_ARGS__)
+#define DOCTEST_CHECK_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_CHECK_THROWS_AS, "", __VA_ARGS__)
+#define DOCTEST_REQUIRE_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_REQUIRE_THROWS_AS, "", __VA_ARGS__)
#define DOCTEST_WARN_THROWS_WITH(expr, ...) DOCTEST_ASSERT_THROWS_WITH(expr, DT_WARN_THROWS_WITH, __VA_ARGS__)
#define DOCTEST_CHECK_THROWS_WITH(expr, ...) DOCTEST_ASSERT_THROWS_WITH(expr, DT_CHECK_THROWS_WITH, __VA_ARGS__)
#define DOCTEST_REQUIRE_THROWS_WITH(expr, ...) DOCTEST_ASSERT_THROWS_WITH(expr, DT_REQUIRE_THROWS_WITH, __VA_ARGS__)
+#define DOCTEST_WARN_THROWS_WITH_AS(expr, message, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_WARN_THROWS_WITH_AS, message, __VA_ARGS__)
+#define DOCTEST_CHECK_THROWS_WITH_AS(expr, message, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_CHECK_THROWS_WITH_AS, message, __VA_ARGS__)
+#define DOCTEST_REQUIRE_THROWS_WITH_AS(expr, message, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_REQUIRE_THROWS_WITH_AS, message, __VA_ARGS__)
+
#define DOCTEST_WARN_NOTHROW(expr) DOCTEST_ASSERT_NOTHROW(expr, DT_WARN_NOTHROW)
#define DOCTEST_CHECK_NOTHROW(expr) DOCTEST_ASSERT_NOTHROW(expr, DT_CHECK_NOTHROW)
#define DOCTEST_REQUIRE_NOTHROW(expr) DOCTEST_ASSERT_NOTHROW(expr, DT_REQUIRE_NOTHROW)
@@ -2135,9 +2144,12 @@ int registerReporter(const char* name, int priority, bool isReporter) {
#define DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, msg) do { DOCTEST_INFO(msg); DOCTEST_WARN_THROWS_AS(expr, ex); } while((void)0, 0)
#define DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, msg) do { DOCTEST_INFO(msg); DOCTEST_CHECK_THROWS_AS(expr, ex); } while((void)0, 0)
#define DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, msg) do { DOCTEST_INFO(msg); DOCTEST_REQUIRE_THROWS_AS(expr, ex); } while((void)0, 0)
-#define DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, ex, msg) do { DOCTEST_INFO(msg); DOCTEST_WARN_THROWS_WITH(expr, ex); } while((void)0, 0)
-#define DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, ex, msg) do { DOCTEST_INFO(msg); DOCTEST_CHECK_THROWS_WITH(expr, ex); } while((void)0, 0)
-#define DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, ex, msg) do { DOCTEST_INFO(msg); DOCTEST_REQUIRE_THROWS_WITH(expr, ex); } while((void)0, 0)
+#define DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, with, msg) do { DOCTEST_INFO(msg); DOCTEST_WARN_THROWS_WITH(expr, with); } while((void)0, 0)
+#define DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, with, msg) do { DOCTEST_INFO(msg); DOCTEST_CHECK_THROWS_WITH(expr, with); } while((void)0, 0)
+#define DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, with, msg) do { DOCTEST_INFO(msg); DOCTEST_REQUIRE_THROWS_WITH(expr, with); } while((void)0, 0)
+#define DOCTEST_WARN_THROWS_WITH_AS_MESSAGE(expr, with, ex, msg) do { DOCTEST_INFO(msg); DOCTEST_WARN_THROWS_WITH_AS(expr, with, ex); } while((void)0, 0)
+#define DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE(expr, with, ex, msg) do { DOCTEST_INFO(msg); DOCTEST_CHECK_THROWS_WITH_AS(expr, with, ex); } while((void)0, 0)
+#define DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE(expr, with, ex, msg) do { DOCTEST_INFO(msg); DOCTEST_REQUIRE_THROWS_WITH_AS(expr, with, ex); } while((void)0, 0)
#define DOCTEST_WARN_NOTHROW_MESSAGE(expr, msg) do { DOCTEST_INFO(msg); DOCTEST_WARN_NOTHROW(expr); } while((void)0, 0)
#define DOCTEST_CHECK_NOTHROW_MESSAGE(expr, msg) do { DOCTEST_INFO(msg); DOCTEST_CHECK_NOTHROW(expr); } while((void)0, 0)
#define DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, msg) do { DOCTEST_INFO(msg); DOCTEST_REQUIRE_NOTHROW(expr); } while((void)0, 0)
@@ -2212,6 +2224,9 @@ int registerReporter(const char* name, int priority, bool isReporter) {
#undef DOCTEST_WARN_THROWS_WITH
#undef DOCTEST_CHECK_THROWS_WITH
#undef DOCTEST_REQUIRE_THROWS_WITH
+#undef DOCTEST_WARN_THROWS_WITH_AS
+#undef DOCTEST_CHECK_THROWS_WITH_AS
+#undef DOCTEST_REQUIRE_THROWS_WITH_AS
#undef DOCTEST_WARN_NOTHROW
#undef DOCTEST_CHECK_NOTHROW
#undef DOCTEST_REQUIRE_NOTHROW
@@ -2225,6 +2240,9 @@ int registerReporter(const char* name, int priority, bool isReporter) {
#undef DOCTEST_WARN_THROWS_WITH_MESSAGE
#undef DOCTEST_CHECK_THROWS_WITH_MESSAGE
#undef DOCTEST_REQUIRE_THROWS_WITH_MESSAGE
+#undef DOCTEST_WARN_THROWS_WITH_AS_MESSAGE
+#undef DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE
+#undef DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE
#undef DOCTEST_WARN_NOTHROW_MESSAGE
#undef DOCTEST_CHECK_NOTHROW_MESSAGE
#undef DOCTEST_REQUIRE_NOTHROW_MESSAGE
@@ -2240,6 +2258,9 @@ int registerReporter(const char* name, int priority, bool isReporter) {
#define DOCTEST_WARN_THROWS_WITH(expr, ...) ((void)0)
#define DOCTEST_CHECK_THROWS_WITH(expr, ...) ((void)0)
#define DOCTEST_REQUIRE_THROWS_WITH(expr, ...) ((void)0)
+#define DOCTEST_WARN_THROWS_WITH_AS(expr, with, ...) ((void)0)
+#define DOCTEST_CHECK_THROWS_WITH_AS(expr, with, ...) ((void)0)
+#define DOCTEST_REQUIRE_THROWS_WITH_AS(expr, with, ...) ((void)0)
#define DOCTEST_WARN_NOTHROW(expr) ((void)0)
#define DOCTEST_CHECK_NOTHROW(expr) ((void)0)
#define DOCTEST_REQUIRE_NOTHROW(expr) ((void)0)
@@ -2250,9 +2271,12 @@ int registerReporter(const char* name, int priority, bool isReporter) {
#define DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, msg) ((void)0)
#define DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, msg) ((void)0)
#define DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, msg) ((void)0)
-#define DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, ex, msg) ((void)0)
-#define DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, ex, msg) ((void)0)
-#define DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, ex, msg) ((void)0)
+#define DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, with, msg) ((void)0)
+#define DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, with, msg) ((void)0)
+#define DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, with, msg) ((void)0)
+#define DOCTEST_WARN_THROWS_WITH_AS_MESSAGE(expr, with, ex, msg) ((void)0)
+#define DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE(expr, with, ex, msg) ((void)0)
+#define DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE(expr, with, ex, msg) ((void)0)
#define DOCTEST_WARN_NOTHROW_MESSAGE(expr, msg) ((void)0)
#define DOCTEST_CHECK_NOTHROW_MESSAGE(expr, msg) ((void)0)
#define DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, msg) ((void)0)
@@ -2378,6 +2402,9 @@ int registerReporter(const char* name, int priority, bool isReporter) {
#define DOCTEST_WARN_THROWS_WITH(expr, ...) ((void)0)
#define DOCTEST_CHECK_THROWS_WITH(expr, ...) ((void)0)
#define DOCTEST_REQUIRE_THROWS_WITH(expr, ...) ((void)0)
+#define DOCTEST_WARN_THROWS_WITH_AS(expr, with, ...) ((void)0)
+#define DOCTEST_CHECK_THROWS_WITH_AS(expr, with, ...) ((void)0)
+#define DOCTEST_REQUIRE_THROWS_WITH_AS(expr, with, ...) ((void)0)
#define DOCTEST_WARN_NOTHROW(expr) ((void)0)
#define DOCTEST_CHECK_NOTHROW(expr) ((void)0)
#define DOCTEST_REQUIRE_NOTHROW(expr) ((void)0)
@@ -2388,9 +2415,12 @@ int registerReporter(const char* name, int priority, bool isReporter) {
#define DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, msg) ((void)0)
#define DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, msg) ((void)0)
#define DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, msg) ((void)0)
-#define DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, ex, msg) ((void)0)
-#define DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, ex, msg) ((void)0)
-#define DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, ex, msg) ((void)0)
+#define DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, with, msg) ((void)0)
+#define DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, with, msg) ((void)0)
+#define DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, with, msg) ((void)0)
+#define DOCTEST_WARN_THROWS_WITH_AS_MESSAGE(expr, with, ex, msg) ((void)0)
+#define DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE(expr, with, ex, msg) ((void)0)
+#define DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE(expr, with, ex, msg) ((void)0)
#define DOCTEST_WARN_NOTHROW_MESSAGE(expr, msg) ((void)0)
#define DOCTEST_CHECK_NOTHROW_MESSAGE(expr, msg) ((void)0)
#define DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, msg) ((void)0)
@@ -2501,18 +2531,21 @@ int registerReporter(const char* name, int priority, bool isReporter) {
#define WARN_THROWS DOCTEST_WARN_THROWS
#define WARN_THROWS_AS DOCTEST_WARN_THROWS_AS
#define WARN_THROWS_WITH DOCTEST_WARN_THROWS_WITH
+#define WARN_THROWS_WITH_AS DOCTEST_WARN_THROWS_WITH_AS
#define WARN_NOTHROW DOCTEST_WARN_NOTHROW
#define CHECK DOCTEST_CHECK
#define CHECK_FALSE DOCTEST_CHECK_FALSE
#define CHECK_THROWS DOCTEST_CHECK_THROWS
#define CHECK_THROWS_AS DOCTEST_CHECK_THROWS_AS
#define CHECK_THROWS_WITH DOCTEST_CHECK_THROWS_WITH
+#define CHECK_THROWS_WITH_AS DOCTEST_CHECK_THROWS_WITH_AS
#define CHECK_NOTHROW DOCTEST_CHECK_NOTHROW
#define REQUIRE DOCTEST_REQUIRE
#define REQUIRE_FALSE DOCTEST_REQUIRE_FALSE
#define REQUIRE_THROWS DOCTEST_REQUIRE_THROWS
#define REQUIRE_THROWS_AS DOCTEST_REQUIRE_THROWS_AS
#define REQUIRE_THROWS_WITH DOCTEST_REQUIRE_THROWS_WITH
+#define REQUIRE_THROWS_WITH_AS DOCTEST_REQUIRE_THROWS_WITH_AS
#define REQUIRE_NOTHROW DOCTEST_REQUIRE_NOTHROW
#define WARN_MESSAGE DOCTEST_WARN_MESSAGE
@@ -2520,18 +2553,21 @@ int registerReporter(const char* name, int priority, bool isReporter) {
#define WARN_THROWS_MESSAGE DOCTEST_WARN_THROWS_MESSAGE
#define WARN_THROWS_AS_MESSAGE DOCTEST_WARN_THROWS_AS_MESSAGE
#define WARN_THROWS_WITH_MESSAGE DOCTEST_WARN_THROWS_WITH_MESSAGE
+#define WARN_THROWS_WITH_AS_MESSAGE DOCTEST_WARN_THROWS_WITH_AS_MESSAGE
#define WARN_NOTHROW_MESSAGE DOCTEST_WARN_NOTHROW_MESSAGE
#define CHECK_MESSAGE DOCTEST_CHECK_MESSAGE
#define CHECK_FALSE_MESSAGE DOCTEST_CHECK_FALSE_MESSAGE
#define CHECK_THROWS_MESSAGE DOCTEST_CHECK_THROWS_MESSAGE
#define CHECK_THROWS_AS_MESSAGE DOCTEST_CHECK_THROWS_AS_MESSAGE
#define CHECK_THROWS_WITH_MESSAGE DOCTEST_CHECK_THROWS_WITH_MESSAGE
+#define CHECK_THROWS_WITH_AS_MESSAGE DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE
#define CHECK_NOTHROW_MESSAGE DOCTEST_CHECK_NOTHROW_MESSAGE
#define REQUIRE_MESSAGE DOCTEST_REQUIRE_MESSAGE
#define REQUIRE_FALSE_MESSAGE DOCTEST_REQUIRE_FALSE_MESSAGE
#define REQUIRE_THROWS_MESSAGE DOCTEST_REQUIRE_THROWS_MESSAGE
#define REQUIRE_THROWS_AS_MESSAGE DOCTEST_REQUIRE_THROWS_AS_MESSAGE
#define REQUIRE_THROWS_WITH_MESSAGE DOCTEST_REQUIRE_THROWS_WITH_MESSAGE
+#define REQUIRE_THROWS_WITH_AS_MESSAGE DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE
#define REQUIRE_NOTHROW_MESSAGE DOCTEST_REQUIRE_NOTHROW_MESSAGE
#define SCENARIO DOCTEST_SCENARIO
@@ -3226,6 +3262,10 @@ const char* assertString(assertType::Enum at) {
case assertType::DT_CHECK_THROWS_WITH : return "CHECK_THROWS_WITH";
case assertType::DT_REQUIRE_THROWS_WITH : return "REQUIRE_THROWS_WITH";
+ case assertType::DT_WARN_THROWS_WITH_AS : return "WARN_THROWS_WITH_AS";
+ case assertType::DT_CHECK_THROWS_WITH_AS : return "CHECK_THROWS_WITH_AS";
+ case assertType::DT_REQUIRE_THROWS_WITH_AS : return "REQUIRE_THROWS_WITH_AS";
+
case assertType::DT_WARN_NOTHROW : return "WARN_NOTHROW";
case assertType::DT_CHECK_NOTHROW : return "CHECK_NOTHROW";
case assertType::DT_REQUIRE_NOTHROW : return "REQUIRE_NOTHROW";
@@ -4139,16 +4179,17 @@ namespace {
namespace detail {
ResultBuilder::ResultBuilder(assertType::Enum at, const char* file, int line, const char* expr,
- const char* exception_type) {
- m_test_case = g_cs->currentTest;
- m_at = at;
- m_file = file;
- m_line = line;
- m_expr = expr;
- m_failed = true;
- m_threw = false;
- m_threw_as = false;
- m_exception_type = exception_type;
+ const char* exception_type, const char* exception_string) {
+ m_test_case = g_cs->currentTest;
+ m_at = at;
+ m_file = file;
+ m_line = line;
+ m_expr = expr;
+ m_failed = true;
+ m_threw = false;
+ m_threw_as = false;
+ m_exception_type = exception_type;
+ m_exception_string = exception_string;
#if DOCTEST_MSVC
if(m_expr[0] == ' ') // this happens when variadic macros are disabled under MSVC
++m_expr;
@@ -4170,10 +4211,12 @@ namespace detail {
bool ResultBuilder::log() {
if(m_at & assertType::is_throws) { //!OCLINT bitwise operator in conditional
m_failed = !m_threw;
+ } else if((m_at & assertType::is_throws_as) && (m_at & assertType::is_throws_with)) { //!OCLINT
+ m_failed = !m_threw_as || (m_exception != m_exception_string);
} else if(m_at & assertType::is_throws_as) { //!OCLINT bitwise operator in conditional
m_failed = !m_threw_as;
} else if(m_at & assertType::is_throws_with) { //!OCLINT bitwise operator in conditional
- m_failed = m_exception != m_exception_type;
+ m_failed = m_exception != m_exception_string;
} else if(m_at & assertType::is_nothrow) { //!OCLINT bitwise operator in conditional
m_failed = m_threw;
}
@@ -4844,11 +4887,12 @@ namespace {
if(rb.m_threw)
xml.scopedElement("Exception").writeText(rb.m_exception.c_str());
- if(rb.m_at & (assertType::is_throws_as | assertType::is_throws_with)) {
+ if(rb.m_at & assertType::is_throws_as)
xml.scopedElement("ExpectedException").writeText(rb.m_exception_type);
- } else if((rb.m_at & assertType::is_normal) && !rb.m_threw) {
+ if(rb.m_at & assertType::is_throws_with)
+ xml.scopedElement("ExpectedExceptionString").writeText(rb.m_exception_string);
+ if((rb.m_at & assertType::is_normal) && !rb.m_threw)
xml.scopedElement("Expanded").writeText(rb.m_decomp.c_str());
- }
log_contexts();
@@ -5299,6 +5343,19 @@ namespace {
if(rb.m_at & assertType::is_throws) { //!OCLINT bitwise operator in conditional
s << (rb.m_threw ? "threw as expected!" : "did NOT throw at all!") << "\n";
+ } else if((rb.m_at & assertType::is_throws_as) &&
+ (rb.m_at & assertType::is_throws_with)) { //!OCLINT
+ s << Color::Cyan << assertString(rb.m_at) << "( " << rb.m_expr << ", \""
+ << rb.m_exception_string << "\", " << rb.m_exception_type << " ) " << Color::None;
+ if(rb.m_threw) {
+ if(!rb.m_failed) {
+ s << "threw as expected!\n";
+ } else {
+ s << "threw a DIFFERENT exception! (contents: " << rb.m_exception << ")\n";
+ }
+ } else {
+ s << "did NOT throw at all!\n";
+ }
} else if(rb.m_at &
assertType::is_throws_as) { //!OCLINT bitwise operator in conditional
s << Color::Cyan << assertString(rb.m_at) << "( " << rb.m_expr << ", "
@@ -5310,7 +5367,7 @@ namespace {
} else if(rb.m_at &
assertType::is_throws_with) { //!OCLINT bitwise operator in conditional
s << Color::Cyan << assertString(rb.m_at) << "( " << rb.m_expr << ", \""
- << rb.m_exception_type << "\" ) " << Color::None
+ << rb.m_exception_string << "\" ) " << Color::None
<< (rb.m_threw ? (!rb.m_failed ? "threw as expected!" :
"threw a DIFFERENT exception: ") :
"did NOT throw at all!")
diff --git a/doctest/parts/doctest.cpp b/doctest/parts/doctest.cpp
index 1838b3be..ab9df2ea 100644
--- a/doctest/parts/doctest.cpp
+++ b/doctest/parts/doctest.cpp
@@ -585,6 +585,10 @@ const char* assertString(assertType::Enum at) {
case assertType::DT_CHECK_THROWS_WITH : return "CHECK_THROWS_WITH";
case assertType::DT_REQUIRE_THROWS_WITH : return "REQUIRE_THROWS_WITH";
+ case assertType::DT_WARN_THROWS_WITH_AS : return "WARN_THROWS_WITH_AS";
+ case assertType::DT_CHECK_THROWS_WITH_AS : return "CHECK_THROWS_WITH_AS";
+ case assertType::DT_REQUIRE_THROWS_WITH_AS : return "REQUIRE_THROWS_WITH_AS";
+
case assertType::DT_WARN_NOTHROW : return "WARN_NOTHROW";
case assertType::DT_CHECK_NOTHROW : return "CHECK_NOTHROW";
case assertType::DT_REQUIRE_NOTHROW : return "REQUIRE_NOTHROW";
@@ -1498,16 +1502,17 @@ namespace {
namespace detail {
ResultBuilder::ResultBuilder(assertType::Enum at, const char* file, int line, const char* expr,
- const char* exception_type) {
- m_test_case = g_cs->currentTest;
- m_at = at;
- m_file = file;
- m_line = line;
- m_expr = expr;
- m_failed = true;
- m_threw = false;
- m_threw_as = false;
- m_exception_type = exception_type;
+ const char* exception_type, const char* exception_string) {
+ m_test_case = g_cs->currentTest;
+ m_at = at;
+ m_file = file;
+ m_line = line;
+ m_expr = expr;
+ m_failed = true;
+ m_threw = false;
+ m_threw_as = false;
+ m_exception_type = exception_type;
+ m_exception_string = exception_string;
#if DOCTEST_MSVC
if(m_expr[0] == ' ') // this happens when variadic macros are disabled under MSVC
++m_expr;
@@ -1529,10 +1534,12 @@ namespace detail {
bool ResultBuilder::log() {
if(m_at & assertType::is_throws) { //!OCLINT bitwise operator in conditional
m_failed = !m_threw;
+ } else if((m_at & assertType::is_throws_as) && (m_at & assertType::is_throws_with)) { //!OCLINT
+ m_failed = !m_threw_as || (m_exception != m_exception_string);
} else if(m_at & assertType::is_throws_as) { //!OCLINT bitwise operator in conditional
m_failed = !m_threw_as;
} else if(m_at & assertType::is_throws_with) { //!OCLINT bitwise operator in conditional
- m_failed = m_exception != m_exception_type;
+ m_failed = m_exception != m_exception_string;
} else if(m_at & assertType::is_nothrow) { //!OCLINT bitwise operator in conditional
m_failed = m_threw;
}
@@ -2203,11 +2210,12 @@ namespace {
if(rb.m_threw)
xml.scopedElement("Exception").writeText(rb.m_exception.c_str());
- if(rb.m_at & (assertType::is_throws_as | assertType::is_throws_with)) {
+ if(rb.m_at & assertType::is_throws_as)
xml.scopedElement("ExpectedException").writeText(rb.m_exception_type);
- } else if((rb.m_at & assertType::is_normal) && !rb.m_threw) {
+ if(rb.m_at & assertType::is_throws_with)
+ xml.scopedElement("ExpectedExceptionString").writeText(rb.m_exception_string);
+ if((rb.m_at & assertType::is_normal) && !rb.m_threw)
xml.scopedElement("Expanded").writeText(rb.m_decomp.c_str());
- }
log_contexts();
@@ -2658,6 +2666,19 @@ namespace {
if(rb.m_at & assertType::is_throws) { //!OCLINT bitwise operator in conditional
s << (rb.m_threw ? "threw as expected!" : "did NOT throw at all!") << "\n";
+ } else if((rb.m_at & assertType::is_throws_as) &&
+ (rb.m_at & assertType::is_throws_with)) { //!OCLINT
+ s << Color::Cyan << assertString(rb.m_at) << "( " << rb.m_expr << ", \""
+ << rb.m_exception_string << "\", " << rb.m_exception_type << " ) " << Color::None;
+ if(rb.m_threw) {
+ if(!rb.m_failed) {
+ s << "threw as expected!\n";
+ } else {
+ s << "threw a DIFFERENT exception! (contents: " << rb.m_exception << ")\n";
+ }
+ } else {
+ s << "did NOT throw at all!\n";
+ }
} else if(rb.m_at &
assertType::is_throws_as) { //!OCLINT bitwise operator in conditional
s << Color::Cyan << assertString(rb.m_at) << "( " << rb.m_expr << ", "
@@ -2669,7 +2690,7 @@ namespace {
} else if(rb.m_at &
assertType::is_throws_with) { //!OCLINT bitwise operator in conditional
s << Color::Cyan << assertString(rb.m_at) << "( " << rb.m_expr << ", \""
- << rb.m_exception_type << "\" ) " << Color::None
+ << rb.m_exception_string << "\" ) " << Color::None
<< (rb.m_threw ? (!rb.m_failed ? "threw as expected!" :
"threw a DIFFERENT exception: ") :
"did NOT throw at all!")
diff --git a/doctest/parts/doctest_fwd.h b/doctest/parts/doctest_fwd.h
index 37bb961e..0e9938e9 100644
--- a/doctest/parts/doctest_fwd.h
+++ b/doctest/parts/doctest_fwd.h
@@ -591,6 +591,10 @@ namespace assertType {
DT_WARN_THROWS_WITH = is_throws_with | is_warn,
DT_CHECK_THROWS_WITH = is_throws_with | is_check,
DT_REQUIRE_THROWS_WITH = is_throws_with | is_require,
+
+ DT_WARN_THROWS_WITH_AS = is_throws_with | is_throws_as | is_warn,
+ DT_CHECK_THROWS_WITH_AS = is_throws_with | is_throws_as | is_check,
+ DT_REQUIRE_THROWS_WITH_AS = is_throws_with | is_throws_as | is_require,
DT_WARN_NOTHROW = is_nothrow | is_warn,
DT_CHECK_NOTHROW = is_nothrow | is_check,
@@ -671,6 +675,7 @@ struct DOCTEST_INTERFACE AssertData
// for specific exception-related asserts
bool m_threw_as;
const char* m_exception_type;
+ const char* m_exception_string;
DOCTEST_DECLARE_DEFAULTS(AssertData);
DOCTEST_DELETE_COPIES(AssertData);
@@ -1336,7 +1341,7 @@ namespace detail {
struct DOCTEST_INTERFACE ResultBuilder : public AssertData
{
ResultBuilder(assertType::Enum at, const char* file, int line, const char* expr,
- const char* exception_type = "");
+ const char* exception_type = "", const char* exception_string = "");
DOCTEST_DECLARE_DEFAULTS(ResultBuilder);
DOCTEST_DELETE_COPIES(ResultBuilder);
@@ -2071,11 +2076,11 @@ int registerReporter(const char* name, int priority, bool isReporter) {
#define DOCTEST_REQUIRE_FALSE_MESSAGE(cond, msg) do { DOCTEST_INFO(msg); DOCTEST_ASSERT_IMPLEMENT_2(DT_REQUIRE_FALSE, cond); } while((void)0, 0)
// clang-format on
-#define DOCTEST_ASSERT_THROWS_AS(expr, assert_type, ...) \
+#define DOCTEST_ASSERT_THROWS_AS(expr, assert_type, message, ...) \
do { \
if(!doctest::getContextOptions()->no_throw) { \
doctest::detail::ResultBuilder _DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \
- __LINE__, #expr, #__VA_ARGS__); \
+ __LINE__, #expr, #__VA_ARGS__, message); \
try { \
DOCTEST_CAST_TO_VOID(expr) \
} catch(const doctest::detail::remove_const< \
@@ -2091,7 +2096,7 @@ int registerReporter(const char* name, int priority, bool isReporter) {
do { \
if(!doctest::getContextOptions()->no_throw) { \
doctest::detail::ResultBuilder _DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \
- __LINE__, #expr, __VA_ARGS__); \
+ __LINE__, #expr, "", __VA_ARGS__); \
try { \
DOCTEST_CAST_TO_VOID(expr) \
} catch(...) { _DOCTEST_RB.translateException(); } \
@@ -2114,14 +2119,18 @@ int registerReporter(const char* name, int priority, bool isReporter) {
#define DOCTEST_CHECK_THROWS(expr) DOCTEST_ASSERT_THROWS_WITH(expr, DT_CHECK_THROWS, "")
#define DOCTEST_REQUIRE_THROWS(expr) DOCTEST_ASSERT_THROWS_WITH(expr, DT_REQUIRE_THROWS, "")
-#define DOCTEST_WARN_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_WARN_THROWS_AS, __VA_ARGS__)
-#define DOCTEST_CHECK_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_CHECK_THROWS_AS, __VA_ARGS__)
-#define DOCTEST_REQUIRE_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_REQUIRE_THROWS_AS, __VA_ARGS__)
+#define DOCTEST_WARN_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_WARN_THROWS_AS, "", __VA_ARGS__)
+#define DOCTEST_CHECK_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_CHECK_THROWS_AS, "", __VA_ARGS__)
+#define DOCTEST_REQUIRE_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_REQUIRE_THROWS_AS, "", __VA_ARGS__)
#define DOCTEST_WARN_THROWS_WITH(expr, ...) DOCTEST_ASSERT_THROWS_WITH(expr, DT_WARN_THROWS_WITH, __VA_ARGS__)
#define DOCTEST_CHECK_THROWS_WITH(expr, ...) DOCTEST_ASSERT_THROWS_WITH(expr, DT_CHECK_THROWS_WITH, __VA_ARGS__)
#define DOCTEST_REQUIRE_THROWS_WITH(expr, ...) DOCTEST_ASSERT_THROWS_WITH(expr, DT_REQUIRE_THROWS_WITH, __VA_ARGS__)
+#define DOCTEST_WARN_THROWS_WITH_AS(expr, message, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_WARN_THROWS_WITH_AS, message, __VA_ARGS__)
+#define DOCTEST_CHECK_THROWS_WITH_AS(expr, message, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_CHECK_THROWS_WITH_AS, message, __VA_ARGS__)
+#define DOCTEST_REQUIRE_THROWS_WITH_AS(expr, message, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_REQUIRE_THROWS_WITH_AS, message, __VA_ARGS__)
+
#define DOCTEST_WARN_NOTHROW(expr) DOCTEST_ASSERT_NOTHROW(expr, DT_WARN_NOTHROW)
#define DOCTEST_CHECK_NOTHROW(expr) DOCTEST_ASSERT_NOTHROW(expr, DT_CHECK_NOTHROW)
#define DOCTEST_REQUIRE_NOTHROW(expr) DOCTEST_ASSERT_NOTHROW(expr, DT_REQUIRE_NOTHROW)
@@ -2132,9 +2141,12 @@ int registerReporter(const char* name, int priority, bool isReporter) {
#define DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, msg) do { DOCTEST_INFO(msg); DOCTEST_WARN_THROWS_AS(expr, ex); } while((void)0, 0)
#define DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, msg) do { DOCTEST_INFO(msg); DOCTEST_CHECK_THROWS_AS(expr, ex); } while((void)0, 0)
#define DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, msg) do { DOCTEST_INFO(msg); DOCTEST_REQUIRE_THROWS_AS(expr, ex); } while((void)0, 0)
-#define DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, ex, msg) do { DOCTEST_INFO(msg); DOCTEST_WARN_THROWS_WITH(expr, ex); } while((void)0, 0)
-#define DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, ex, msg) do { DOCTEST_INFO(msg); DOCTEST_CHECK_THROWS_WITH(expr, ex); } while((void)0, 0)
-#define DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, ex, msg) do { DOCTEST_INFO(msg); DOCTEST_REQUIRE_THROWS_WITH(expr, ex); } while((void)0, 0)
+#define DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, with, msg) do { DOCTEST_INFO(msg); DOCTEST_WARN_THROWS_WITH(expr, with); } while((void)0, 0)
+#define DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, with, msg) do { DOCTEST_INFO(msg); DOCTEST_CHECK_THROWS_WITH(expr, with); } while((void)0, 0)
+#define DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, with, msg) do { DOCTEST_INFO(msg); DOCTEST_REQUIRE_THROWS_WITH(expr, with); } while((void)0, 0)
+#define DOCTEST_WARN_THROWS_WITH_AS_MESSAGE(expr, with, ex, msg) do { DOCTEST_INFO(msg); DOCTEST_WARN_THROWS_WITH_AS(expr, with, ex); } while((void)0, 0)
+#define DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE(expr, with, ex, msg) do { DOCTEST_INFO(msg); DOCTEST_CHECK_THROWS_WITH_AS(expr, with, ex); } while((void)0, 0)
+#define DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE(expr, with, ex, msg) do { DOCTEST_INFO(msg); DOCTEST_REQUIRE_THROWS_WITH_AS(expr, with, ex); } while((void)0, 0)
#define DOCTEST_WARN_NOTHROW_MESSAGE(expr, msg) do { DOCTEST_INFO(msg); DOCTEST_WARN_NOTHROW(expr); } while((void)0, 0)
#define DOCTEST_CHECK_NOTHROW_MESSAGE(expr, msg) do { DOCTEST_INFO(msg); DOCTEST_CHECK_NOTHROW(expr); } while((void)0, 0)
#define DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, msg) do { DOCTEST_INFO(msg); DOCTEST_REQUIRE_NOTHROW(expr); } while((void)0, 0)
@@ -2209,6 +2221,9 @@ int registerReporter(const char* name, int priority, bool isReporter) {
#undef DOCTEST_WARN_THROWS_WITH
#undef DOCTEST_CHECK_THROWS_WITH
#undef DOCTEST_REQUIRE_THROWS_WITH
+#undef DOCTEST_WARN_THROWS_WITH_AS
+#undef DOCTEST_CHECK_THROWS_WITH_AS
+#undef DOCTEST_REQUIRE_THROWS_WITH_AS
#undef DOCTEST_WARN_NOTHROW
#undef DOCTEST_CHECK_NOTHROW
#undef DOCTEST_REQUIRE_NOTHROW
@@ -2222,6 +2237,9 @@ int registerReporter(const char* name, int priority, bool isReporter) {
#undef DOCTEST_WARN_THROWS_WITH_MESSAGE
#undef DOCTEST_CHECK_THROWS_WITH_MESSAGE
#undef DOCTEST_REQUIRE_THROWS_WITH_MESSAGE
+#undef DOCTEST_WARN_THROWS_WITH_AS_MESSAGE
+#undef DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE
+#undef DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE
#undef DOCTEST_WARN_NOTHROW_MESSAGE
#undef DOCTEST_CHECK_NOTHROW_MESSAGE
#undef DOCTEST_REQUIRE_NOTHROW_MESSAGE
@@ -2237,6 +2255,9 @@ int registerReporter(const char* name, int priority, bool isReporter) {
#define DOCTEST_WARN_THROWS_WITH(expr, ...) ((void)0)
#define DOCTEST_CHECK_THROWS_WITH(expr, ...) ((void)0)
#define DOCTEST_REQUIRE_THROWS_WITH(expr, ...) ((void)0)
+#define DOCTEST_WARN_THROWS_WITH_AS(expr, with, ...) ((void)0)
+#define DOCTEST_CHECK_THROWS_WITH_AS(expr, with, ...) ((void)0)
+#define DOCTEST_REQUIRE_THROWS_WITH_AS(expr, with, ...) ((void)0)
#define DOCTEST_WARN_NOTHROW(expr) ((void)0)
#define DOCTEST_CHECK_NOTHROW(expr) ((void)0)
#define DOCTEST_REQUIRE_NOTHROW(expr) ((void)0)
@@ -2247,9 +2268,12 @@ int registerReporter(const char* name, int priority, bool isReporter) {
#define DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, msg) ((void)0)
#define DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, msg) ((void)0)
#define DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, msg) ((void)0)
-#define DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, ex, msg) ((void)0)
-#define DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, ex, msg) ((void)0)
-#define DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, ex, msg) ((void)0)
+#define DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, with, msg) ((void)0)
+#define DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, with, msg) ((void)0)
+#define DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, with, msg) ((void)0)
+#define DOCTEST_WARN_THROWS_WITH_AS_MESSAGE(expr, with, ex, msg) ((void)0)
+#define DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE(expr, with, ex, msg) ((void)0)
+#define DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE(expr, with, ex, msg) ((void)0)
#define DOCTEST_WARN_NOTHROW_MESSAGE(expr, msg) ((void)0)
#define DOCTEST_CHECK_NOTHROW_MESSAGE(expr, msg) ((void)0)
#define DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, msg) ((void)0)
@@ -2375,6 +2399,9 @@ int registerReporter(const char* name, int priority, bool isReporter) {
#define DOCTEST_WARN_THROWS_WITH(expr, ...) ((void)0)
#define DOCTEST_CHECK_THROWS_WITH(expr, ...) ((void)0)
#define DOCTEST_REQUIRE_THROWS_WITH(expr, ...) ((void)0)
+#define DOCTEST_WARN_THROWS_WITH_AS(expr, with, ...) ((void)0)
+#define DOCTEST_CHECK_THROWS_WITH_AS(expr, with, ...) ((void)0)
+#define DOCTEST_REQUIRE_THROWS_WITH_AS(expr, with, ...) ((void)0)
#define DOCTEST_WARN_NOTHROW(expr) ((void)0)
#define DOCTEST_CHECK_NOTHROW(expr) ((void)0)
#define DOCTEST_REQUIRE_NOTHROW(expr) ((void)0)
@@ -2385,9 +2412,12 @@ int registerReporter(const char* name, int priority, bool isReporter) {
#define DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, msg) ((void)0)
#define DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, msg) ((void)0)
#define DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, msg) ((void)0)
-#define DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, ex, msg) ((void)0)
-#define DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, ex, msg) ((void)0)
-#define DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, ex, msg) ((void)0)
+#define DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, with, msg) ((void)0)
+#define DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, with, msg) ((void)0)
+#define DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, with, msg) ((void)0)
+#define DOCTEST_WARN_THROWS_WITH_AS_MESSAGE(expr, with, ex, msg) ((void)0)
+#define DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE(expr, with, ex, msg) ((void)0)
+#define DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE(expr, with, ex, msg) ((void)0)
#define DOCTEST_WARN_NOTHROW_MESSAGE(expr, msg) ((void)0)
#define DOCTEST_CHECK_NOTHROW_MESSAGE(expr, msg) ((void)0)
#define DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, msg) ((void)0)
@@ -2498,18 +2528,21 @@ int registerReporter(const char* name, int priority, bool isReporter) {
#define WARN_THROWS DOCTEST_WARN_THROWS
#define WARN_THROWS_AS DOCTEST_WARN_THROWS_AS
#define WARN_THROWS_WITH DOCTEST_WARN_THROWS_WITH
+#define WARN_THROWS_WITH_AS DOCTEST_WARN_THROWS_WITH_AS
#define WARN_NOTHROW DOCTEST_WARN_NOTHROW
#define CHECK DOCTEST_CHECK
#define CHECK_FALSE DOCTEST_CHECK_FALSE
#define CHECK_THROWS DOCTEST_CHECK_THROWS
#define CHECK_THROWS_AS DOCTEST_CHECK_THROWS_AS
#define CHECK_THROWS_WITH DOCTEST_CHECK_THROWS_WITH
+#define CHECK_THROWS_WITH_AS DOCTEST_CHECK_THROWS_WITH_AS
#define CHECK_NOTHROW DOCTEST_CHECK_NOTHROW
#define REQUIRE DOCTEST_REQUIRE
#define REQUIRE_FALSE DOCTEST_REQUIRE_FALSE
#define REQUIRE_THROWS DOCTEST_REQUIRE_THROWS
#define REQUIRE_THROWS_AS DOCTEST_REQUIRE_THROWS_AS
#define REQUIRE_THROWS_WITH DOCTEST_REQUIRE_THROWS_WITH
+#define REQUIRE_THROWS_WITH_AS DOCTEST_REQUIRE_THROWS_WITH_AS
#define REQUIRE_NOTHROW DOCTEST_REQUIRE_NOTHROW
#define WARN_MESSAGE DOCTEST_WARN_MESSAGE
@@ -2517,18 +2550,21 @@ int registerReporter(const char* name, int priority, bool isReporter) {
#define WARN_THROWS_MESSAGE DOCTEST_WARN_THROWS_MESSAGE
#define WARN_THROWS_AS_MESSAGE DOCTEST_WARN_THROWS_AS_MESSAGE
#define WARN_THROWS_WITH_MESSAGE DOCTEST_WARN_THROWS_WITH_MESSAGE
+#define WARN_THROWS_WITH_AS_MESSAGE DOCTEST_WARN_THROWS_WITH_AS_MESSAGE
#define WARN_NOTHROW_MESSAGE DOCTEST_WARN_NOTHROW_MESSAGE
#define CHECK_MESSAGE DOCTEST_CHECK_MESSAGE
#define CHECK_FALSE_MESSAGE DOCTEST_CHECK_FALSE_MESSAGE
#define CHECK_THROWS_MESSAGE DOCTEST_CHECK_THROWS_MESSAGE
#define CHECK_THROWS_AS_MESSAGE DOCTEST_CHECK_THROWS_AS_MESSAGE
#define CHECK_THROWS_WITH_MESSAGE DOCTEST_CHECK_THROWS_WITH_MESSAGE
+#define CHECK_THROWS_WITH_AS_MESSAGE DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE
#define CHECK_NOTHROW_MESSAGE DOCTEST_CHECK_NOTHROW_MESSAGE
#define REQUIRE_MESSAGE DOCTEST_REQUIRE_MESSAGE
#define REQUIRE_FALSE_MESSAGE DOCTEST_REQUIRE_FALSE_MESSAGE
#define REQUIRE_THROWS_MESSAGE DOCTEST_REQUIRE_THROWS_MESSAGE
#define REQUIRE_THROWS_AS_MESSAGE DOCTEST_REQUIRE_THROWS_AS_MESSAGE
#define REQUIRE_THROWS_WITH_MESSAGE DOCTEST_REQUIRE_THROWS_WITH_MESSAGE
+#define REQUIRE_THROWS_WITH_AS_MESSAGE DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE
#define REQUIRE_NOTHROW_MESSAGE DOCTEST_REQUIRE_NOTHROW_MESSAGE
#define SCENARIO DOCTEST_SCENARIO
diff --git a/examples/all_features/assertion_macros.cpp b/examples/all_features/assertion_macros.cpp
index 42b3147a..10c44f18 100644
--- a/examples/all_features/assertion_macros.cpp
+++ b/examples/all_features/assertion_macros.cpp
@@ -36,6 +36,8 @@ TEST_CASE("exceptions-related macros") {
CHECK_THROWS_AS(throw_if(false, 0), int); // fails
CHECK_THROWS_WITH(throw_if(true, "whops!"), "whops! no match!"); // fails
+ CHECK_THROWS_WITH_AS(throw_if(true, "whops!"), "whops! no match!", bool); // fails
+ CHECK_THROWS_WITH_AS(throw_if(true, "whops!"), "whops!", int); // fails
CHECK_NOTHROW(throw_if(true, 0)); // fails
CHECK_NOTHROW(throw_if(false, 0));
@@ -64,6 +66,8 @@ TEST_CASE("WARN level of asserts don't fail the test case") {
WARN_THROWS_WITH(throw_if(false, ""), "whops!");
WARN_THROWS_AS(throw_if(false, 0), bool);
WARN_THROWS_AS(throw_if(true, 0), bool);
+ WARN_THROWS_WITH_AS(throw_if(false, ""), "whops!", int);
+ WARN_THROWS_WITH_AS(throw_if(true, ""), "whops!", int);
WARN_NOTHROW(throw_if(true, 0));
WARN_EQ(1, 0);
@@ -78,6 +82,7 @@ TEST_CASE("CHECK level of asserts fail the test case but don't abort it") {
CHECK_THROWS_AS(throw_if(false, 0), bool);
CHECK_THROWS_AS(throw_if(true, 0), bool);
CHECK_THROWS_WITH(throw_if(true, 0), "unrecognized");
+ CHECK_THROWS_WITH_AS(throw_if(true, 0), "unrecognized", int);
CHECK_NOTHROW(throw_if(true, 0));
CHECK_EQ(1, 0);
@@ -107,27 +112,35 @@ TEST_CASE("REQUIRE level of asserts fail and abort the test case - 5") {
REQUIRE_THROWS_AS(throw_if(true, 0), bool);
MESSAGE("should not be reached!");
}
-TEST_CASE("REQUIRE level of asserts fail and abort the test case - 4") {
+TEST_CASE("REQUIRE level of asserts fail and abort the test case - 6") {
REQUIRE_THROWS_WITH(throw_if(false, ""), "whops!");
MESSAGE("should not be reached!");
}
-TEST_CASE("REQUIRE level of asserts fail and abort the test case - 5") {
+TEST_CASE("REQUIRE level of asserts fail and abort the test case - 7") {
REQUIRE_THROWS_WITH(throw_if(true, ""), "whops!");
MESSAGE("should not be reached!");
}
-TEST_CASE("REQUIRE level of asserts fail and abort the test case - 6") {
+TEST_CASE("REQUIRE level of asserts fail and abort the test case - 8") {
+ REQUIRE_THROWS_WITH_AS(throw_if(false, ""), "whops!", bool);
+ MESSAGE("should not be reached!");
+}
+TEST_CASE("REQUIRE level of asserts fail and abort the test case - 9") {
+ REQUIRE_THROWS_WITH_AS(throw_if(true, ""), "whops!", bool);
+ MESSAGE("should not be reached!");
+}
+TEST_CASE("REQUIRE level of asserts fail and abort the test case - 10") {
REQUIRE_NOTHROW(throw_if(true, 0));
MESSAGE("should not be reached!");
}
-TEST_CASE("REQUIRE level of asserts fail and abort the test case - 7") {
+TEST_CASE("REQUIRE level of asserts fail and abort the test case - 11") {
REQUIRE_EQ(1, 0);
MESSAGE("should not be reached!");
}
-TEST_CASE("REQUIRE level of asserts fail and abort the test case - 8") {
+TEST_CASE("REQUIRE level of asserts fail and abort the test case - 12") {
REQUIRE_UNARY(0);
MESSAGE("should not be reached!");
}
-TEST_CASE("REQUIRE level of asserts fail and abort the test case - 9") {
+TEST_CASE("REQUIRE level of asserts fail and abort the test case - 13") {
REQUIRE_UNARY_FALSE(1);
MESSAGE("should not be reached!");
}
@@ -167,6 +180,7 @@ static void someAssertsInFunction() {
CHECK_THROWS(throw_if(true, 0));
CHECK_THROWS_AS(throw_if(true, 0), int);
CHECK_THROWS_WITH(throw_if(true, false), "unknown exception");
+ CHECK_THROWS_WITH_AS(throw_if(true, false), "unknown exception", int);
CHECK_NOTHROW(throw_if(false, 0));
CHECK_EQ(a, b);
diff --git a/examples/all_features/doctest_proxy.h b/examples/all_features/doctest_proxy.h
index dccaf4b3..396d673d 100644
--- a/examples/all_features/doctest_proxy.h
+++ b/examples/all_features/doctest_proxy.h
@@ -20,18 +20,20 @@
#define my_warn_throws DOCTEST_WARN_THROWS
#define my_warn_throws_as DOCTEST_WARN_THROWS_AS
#define my_warn_throws_with DOCTEST_WARN_THROWS_WITH
+#define my_warn_throws_with_as DOCTEST_WARN_THROWS_WITH_AS
#define my_warn_nothrow DOCTEST_WARN_NOTHROW
#define my_check DOCTEST_CHECK
#define my_check_false DOCTEST_CHECK_FALSE
#define my_check_throws DOCTEST_CHECK_THROWS
#define my_check_throws_as DOCTEST_CHECK_THROWS_AS
#define my_check_throws_with DOCTEST_CHECK_THROWS_WITH
+#define my_check_throws_with_as DOCTEST_CHECK_THROWS_WITH_AS
#define my_check_nothrow DOCTEST_CHECK_NOTHROW
#define my_require DOCTEST_REQUIRE
#define my_require_false DOCTEST_REQUIRE_FALSE
#define my_require_throws DOCTEST_REQUIRE_THROWS
#define my_require_throws_as DOCTEST_REQUIRE_THROWS_AS
-#define my_require_throws_with DOCTEST_REQUIRE_THROWS_WITH
+#define my_require_throws_with_as DOCTEST_REQUIRE_THROWS_WITH_AS
#define my_require_nothrow DOCTEST_REQUIRE_NOTHROW
#define my_scenario DOCTEST_SCENARIO
diff --git a/examples/all_features/test_output/assertion_macros.cpp.txt b/examples/all_features/test_output/assertion_macros.cpp.txt
index 32e1b302..5de0e29e 100644
--- a/examples/all_features/test_output/assertion_macros.cpp.txt
+++ b/examples/all_features/test_output/assertion_macros.cpp.txt
@@ -20,6 +20,10 @@ assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(false, 0), int ) did N
assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH( throw_if(true, "whops!"), "whops! no match!" ) threw a DIFFERENT exception: "whops!"
+assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH_AS( throw_if(true, "whops!"), "whops! no match!", bool ) threw a DIFFERENT exception! (contents: "whops!")
+
+assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH_AS( throw_if(true, "whops!"), "whops!", int ) threw a DIFFERENT exception! (contents: "whops!")
+
assertion_macros.cpp(0): ERROR: CHECK_NOTHROW( throw_if(true, 0) ) THREW exception: "0"
===============================================================================
@@ -56,6 +60,10 @@ assertion_macros.cpp(0): WARNING: WARN_THROWS_AS( throw_if(false, 0), bool ) did
assertion_macros.cpp(0): WARNING: WARN_THROWS_AS( throw_if(true, 0), bool ) threw a DIFFERENT exception: "0"
+assertion_macros.cpp(0): WARNING: WARN_THROWS_WITH_AS( throw_if(false, ""), "whops!", int ) did NOT throw at all!
+
+assertion_macros.cpp(0): WARNING: WARN_THROWS_WITH_AS( throw_if(true, ""), "whops!", int ) threw a DIFFERENT exception! (contents: )
+
assertion_macros.cpp(0): WARNING: WARN_NOTHROW( throw_if(true, 0) ) THREW exception: "0"
assertion_macros.cpp(0): WARNING: WARN_EQ( 1, 0 ) is NOT correct!
@@ -85,6 +93,8 @@ assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(true, 0), bool ) threw
assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH( throw_if(true, 0), "unrecognized" ) threw a DIFFERENT exception: "0"
+assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH_AS( throw_if(true, 0), "unrecognized", int ) threw a DIFFERENT exception! (contents: "0")
+
assertion_macros.cpp(0): ERROR: CHECK_NOTHROW( throw_if(true, 0) ) THREW exception: "0"
assertion_macros.cpp(0): ERROR: CHECK_EQ( 1, 0 ) is NOT correct!
@@ -132,45 +142,63 @@ assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS_AS( throw_if(true, 0), bool
===============================================================================
assertion_macros.cpp(0):
-TEST CASE: REQUIRE level of asserts fail and abort the test case - 4
+TEST CASE: REQUIRE level of asserts fail and abort the test case - 6
assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS_WITH( throw_if(false, ""), "whops!" ) did NOT throw at all!
===============================================================================
assertion_macros.cpp(0):
-TEST CASE: REQUIRE level of asserts fail and abort the test case - 5
+TEST CASE: REQUIRE level of asserts fail and abort the test case - 7
assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS_WITH( throw_if(true, ""), "whops!" ) threw a DIFFERENT exception:
===============================================================================
assertion_macros.cpp(0):
-TEST CASE: REQUIRE level of asserts fail and abort the test case - 6
+TEST CASE: REQUIRE level of asserts fail and abort the test case - 8
+
+assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS_WITH_AS( throw_if(false, ""), "whops!", bool ) did NOT throw at all!
+
+===============================================================================
+assertion_macros.cpp(0):
+TEST CASE: REQUIRE level of asserts fail and abort the test case - 9
+
+assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS_WITH_AS( throw_if(true, ""), "whops!", bool ) threw a DIFFERENT exception! (contents: )
+
+===============================================================================
+assertion_macros.cpp(0):
+TEST CASE: REQUIRE level of asserts fail and abort the test case - 10
assertion_macros.cpp(0): FATAL ERROR: REQUIRE_NOTHROW( throw_if(true, 0) ) THREW exception: "0"
===============================================================================
assertion_macros.cpp(0):
-TEST CASE: REQUIRE level of asserts fail and abort the test case - 7
+TEST CASE: REQUIRE level of asserts fail and abort the test case - 11
assertion_macros.cpp(0): FATAL ERROR: REQUIRE_EQ( 1, 0 ) is NOT correct!
values: REQUIRE_EQ( 1, 0 )
===============================================================================
assertion_macros.cpp(0):
-TEST CASE: REQUIRE level of asserts fail and abort the test case - 8
+TEST CASE: REQUIRE level of asserts fail and abort the test case - 12
assertion_macros.cpp(0): FATAL ERROR: REQUIRE_UNARY( 0 ) is NOT correct!
values: REQUIRE_UNARY( 0 )
===============================================================================
assertion_macros.cpp(0):
-TEST CASE: REQUIRE level of asserts fail and abort the test case - 9
+TEST CASE: REQUIRE level of asserts fail and abort the test case - 13
assertion_macros.cpp(0): FATAL ERROR: REQUIRE_UNARY_FALSE( 1 ) is NOT correct!
values: REQUIRE_UNARY_FALSE( 1 )
===============================================================================
-[doctest] test cases: 19 | 4 passed | 15 failed |
-[doctest] assertions: 68 | 35 passed | 33 failed |
+assertion_macros.cpp(0):
+TEST CASE: some asserts used in a function called by a test case
+
+assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH_AS( throw_if(true, false), "unknown exception", int ) threw a DIFFERENT exception! (contents: "unknown exception")
+
+===============================================================================
+[doctest] test cases: 21 | 3 passed | 18 failed |
+[doctest] assertions: 74 | 35 passed | 39 failed |
[doctest] Status: FAILURE!
Program code.
diff --git a/examples/all_features/test_output/assertion_macros.cpp_xml.txt b/examples/all_features/test_output/assertion_macros.cpp_xml.txt
index 6fe4cdd5..29234f3b 100644
--- a/examples/all_features/test_output/assertion_macros.cpp_xml.txt
+++ b/examples/all_features/test_output/assertion_macros.cpp_xml.txt
@@ -56,9 +56,37 @@
<Exception>
"whops!"
</Exception>
+ <ExpectedExceptionString>
+ whops! no match!
+ </ExpectedExceptionString>
+ </Expression>
+ <Expression success="false" type="CHECK_THROWS_WITH_AS" filename="assertion_macros.cpp" line="0">
+ <Original>
+ throw_if(true, "whops!")
+ </Original>
+ <Exception>
+ "whops!"
+ </Exception>
<ExpectedException>
+ bool
+ </ExpectedException>
+ <ExpectedExceptionString>
whops! no match!
+ </ExpectedExceptionString>
+ </Expression>
+ <Expression success="false" type="CHECK_THROWS_WITH_AS" filename="assertion_macros.cpp" line="0">
+ <Original>
+ throw_if(true, "whops!")
+ </Original>
+ <Exception>
+ "whops!"
+ </Exception>
+ <ExpectedException>
+ int
</ExpectedException>
+ <ExpectedExceptionString>
+ whops!
+ </ExpectedExceptionString>
</Expression>
<Expression success="false" type="CHECK_NOTHROW" filename="assertion_macros.cpp" line="0">
<Original>
@@ -68,7 +96,7 @@
"0"
</Exception>
</Expression>
- <OverallResultsAsserts successes="3" failures="5"/>
+ <OverallResultsAsserts successes="3" failures="7"/>
</TestCase>
<TestCase name="exceptions-related macros for std::exception" filename="assertion_macros.cpp" line="0">
<Expression success="false" type="CHECK_THROWS" filename="assertion_macros.cpp" line="0">
@@ -99,9 +127,9 @@
<Original>
throw_if(false, "")
</Original>
- <ExpectedException>
+ <ExpectedExceptionString>
whops!
- </ExpectedException>
+ </ExpectedExceptionString>
</Expression>
<Expression success="false" type="REQUIRE_NOTHROW" filename="assertion_macros.cpp" line="0">
<Original>
@@ -140,17 +168,17 @@
throw_if(true, "")
</Original>
<Exception/>
- <ExpectedException>
+ <ExpectedExceptionString>
whops!
- </ExpectedException>
+ </ExpectedExceptionString>
</Expression>
<Expression success="false" type="WARN_THROWS_WITH" filename="assertion_macros.cpp" line="0">
<Original>
throw_if(false, "")
</Original>
- <ExpectedException>
+ <ExpectedExceptionString>
whops!
- </ExpectedException>
+ </ExpectedExceptionString>
</Expression>
<Expression success="false" type="WARN_THROWS_AS" filename="assertion_macros.cpp" line="0">
<Original>
@@ -171,6 +199,29 @@
bool
</ExpectedException>
</Expression>
+ <Expression success="false" type="WARN_THROWS_WITH_AS" filename="assertion_macros.cpp" line="0">
+ <Original>
+ throw_if(false, "")
+ </Original>
+ <ExpectedException>
+ int
+ </ExpectedException>
+ <ExpectedExceptionString>
+ whops!
+ </ExpectedExceptionString>
+ </Expression>
+ <Expression success="false" type="WARN_THROWS_WITH_AS" filename="assertion_macros.cpp" line="0">
+ <Original>
+ throw_if(true, "")
+ </Original>
+ <Exception/>
+ <ExpectedException>
+ int
+ </ExpectedException>
+ <ExpectedExceptionString>
+ whops!
+ </ExpectedExceptionString>
+ </Expression>
<Expression success="false" type="WARN_NOTHROW" filename="assertion_macros.cpp" line="0">
<Original>
throw_if(true, 0)
@@ -253,9 +304,23 @@
<Exception>
"0"
</Exception>
- <ExpectedException>
+ <ExpectedExceptionString>
unrecognized
+ </ExpectedExceptionString>
+ </Expression>
+ <Expression success="false" type="CHECK_THROWS_WITH_AS" filename="assertion_macros.cpp" line="0">
+ <Original>
+ throw_if(true, 0)
+ </Original>
+ <Exception>
+ "0"
+ </Exception>
+ <ExpectedException>
+ int
</ExpectedException>
+ <ExpectedExceptionString>
+ unrecognized
+ </ExpectedExceptionString>
</Expression>
<Expression success="false" type="CHECK_NOTHROW" filename="assertion_macros.cpp" line="0">
<Original>
@@ -294,7 +359,7 @@
reached!
</Text>
</Message>
- <OverallResultsAsserts successes="0" failures="10"/>
+ <OverallResultsAsserts successes="0" failures="11"/>
</TestCase>
<TestCase name="REQUIRE level of asserts fail and abort the test case - 1" filename="assertion_macros.cpp" line="0">
<Expression success="false" type="REQUIRE" filename="assertion_macros.cpp" line="0">
@@ -351,30 +416,59 @@
</Expression>
<OverallResultsAsserts successes="0" failures="1"/>
</TestCase>
- <TestCase name="REQUIRE level of asserts fail and abort the test case - 4" filename="assertion_macros.cpp" line="0">
+ <TestCase name="REQUIRE level of asserts fail and abort the test case - 6" filename="assertion_macros.cpp" line="0">
<Expression success="false" type="REQUIRE_THROWS_WITH" filename="assertion_macros.cpp" line="0">
<Original>
throw_if(false, "")
</Original>
- <ExpectedException>
+ <ExpectedExceptionString>
whops!
- </ExpectedException>
+ </ExpectedExceptionString>
</Expression>
<OverallResultsAsserts successes="0" failures="1"/>
</TestCase>
- <TestCase name="REQUIRE level of asserts fail and abort the test case - 5" filename="assertion_macros.cpp" line="0">
+ <TestCase name="REQUIRE level of asserts fail and abort the test case - 7" filename="assertion_macros.cpp" line="0">
<Expression success="false" type="REQUIRE_THROWS_WITH" filename="assertion_macros.cpp" line="0">
<Original>
throw_if(true, "")
</Original>
<Exception/>
+ <ExpectedExceptionString>
+ whops!
+ </ExpectedExceptionString>
+ </Expression>
+ <OverallResultsAsserts successes="0" failures="1"/>
+ </TestCase>
+ <TestCase name="REQUIRE level of asserts fail and abort the test case - 8" filename="assertion_macros.cpp" line="0">
+ <Expression success="false" type="REQUIRE_THROWS_WITH_AS" filename="assertion_macros.cpp" line="0">
+ <Original>
+ throw_if(false, "")
+ </Original>
<ExpectedException>
+ bool
+ </ExpectedException>
+ <ExpectedExceptionString>
whops!
+ </ExpectedExceptionString>
+ </Expression>
+ <OverallResultsAsserts successes="0" failures="1"/>
+ </TestCase>
+ <TestCase name="REQUIRE level of asserts fail and abort the test case - 9" filename="assertion_macros.cpp" line="0">
+ <Expression success="false" type="REQUIRE_THROWS_WITH_AS" filename="assertion_macros.cpp" line="0">
+ <Original>
+ throw_if(true, "")
+ </Original>
+ <Exception/>
+ <ExpectedException>
+ bool
</ExpectedException>
+ <ExpectedExceptionString>
+ whops!
+ </ExpectedExceptionString>
</Expression>
<OverallResultsAsserts successes="0" failures="1"/>
</TestCase>
- <TestCase name="REQUIRE level of asserts fail and abort the test case - 6" filename="assertion_macros.cpp" line="0">
+ <TestCase name="REQUIRE level of asserts fail and abort the test case - 10" filename="assertion_macros.cpp" line="0">
<Expression success="false" type="REQUIRE_NOTHROW" filename="assertion_macros.cpp" line="0">
<Original>
throw_if(true, 0)
@@ -385,7 +479,7 @@
</Expression>
<OverallResultsAsserts successes="0" failures="1"/>
</TestCase>
- <TestCase name="REQUIRE level of asserts fail and abort the test case - 7" filename="assertion_macros.cpp" line="0">
+ <TestCase name="REQUIRE level of asserts fail and abort the test case - 11" filename="assertion_macros.cpp" line="0">
<Expression success="false" type="REQUIRE_EQ" filename="assertion_macros.cpp" line="0">
<Original>
1, 0
@@ -396,7 +490,7 @@
</Expression>
<OverallResultsAsserts successes="0" failures="1"/>
</TestCase>
- <TestCase name="REQUIRE level of asserts fail and abort the test case - 8" filename="assertion_macros.cpp" line="0">
+ <TestCase name="REQUIRE level of asserts fail and abort the test case - 12" filename="assertion_macros.cpp" line="0">
<Expression success="false" type="REQUIRE_UNARY" filename="assertion_macros.cpp" line="0">
<Original>
0
@@ -407,7 +501,7 @@
</Expression>
<OverallResultsAsserts successes="0" failures="1"/>
</TestCase>
- <TestCase name="REQUIRE level of asserts fail and abort the test case - 9" filename="assertion_macros.cpp" line="0">
+ <TestCase name="REQUIRE level of asserts fail and abort the test case - 13" filename="assertion_macros.cpp" line="0">
<Expression success="false" type="REQUIRE_UNARY_FALSE" filename="assertion_macros.cpp" line="0">
<Original>
1
@@ -422,10 +516,24 @@
<OverallResultsAsserts successes="16" failures="0"/>
</TestCase>
<TestCase name="some asserts used in a function called by a test case" filename="assertion_macros.cpp" line="0">
- <OverallResultsAsserts successes="9" failures="0"/>
+ <Expression success="false" type="CHECK_THROWS_WITH_AS" filename="assertion_macros.cpp" line="0">
+ <Original>
+ throw_if(true, false)
+ </Original>
+ <Exception>
+ "unknown exception"
+ </Exception>
+ <ExpectedException>
+ int
+ </ExpectedException>
+ <ExpectedExceptionString>
+ unknown exception
+ </ExpectedExceptionString>
+ </Expression>
+ <OverallResultsAsserts successes="9" failures="1"/>
</TestCase>
</TestSuite>
- <OverallResultsAsserts successes="35" failures="33"/>
- <OverallResultsTestCases successes="4" failures="15"/>
+ <OverallResultsAsserts successes="35" failures="39"/>
+ <OverallResultsTestCases successes="3" failures="18"/>
</doctest>
Program code.
diff --git a/examples/all_features/test_output/filter_2.txt b/examples/all_features/test_output/filter_2.txt
index fc435a46..2c565bb1 100644
--- a/examples/all_features/test_output/filter_2.txt
+++ b/examples/all_features/test_output/filter_2.txt
@@ -1,6 +1,6 @@
[doctest] run with "--help" for options
===============================================================================
-[doctest] test cases: 0 | 0 passed | 0 failed | 74 skipped
+[doctest] test cases: 0 | 0 passed | 0 failed | 76 skipped
[doctest] assertions: 0 | 0 passed | 0 failed |
[doctest] Status: SUCCESS!
Program code.
diff --git a/examples/all_features/test_output/filter_2_xml.txt b/examples/all_features/test_output/filter_2_xml.txt
index 8873c226..4a6a03a1 100644
--- a/examples/all_features/test_output/filter_2_xml.txt
+++ b/examples/all_features/test_output/filter_2_xml.txt
@@ -5,11 +5,13 @@
<TestCase name=" Scenario: vectors can be sized and resized" filename="subcases.cpp" line="0" skipped="true"/>
<TestCase name="CHECK level of asserts fail the test case but don't abort it" filename="assertion_macros.cpp" line="0" skipped="true"/>
<TestCase name="REQUIRE level of asserts fail and abort the test case - 1" filename="assertion_macros.cpp" line="0" skipped="true"/>
+ <TestCase name="REQUIRE level of asserts fail and abort the test case - 10" filename="assertion_macros.cpp" line="0" skipped="true"/>
+ <TestCase name="REQUIRE level of asserts fail and abort the test case - 11" filename="assertion_macros.cpp" line="0" skipped="true"/>
+ <TestCase name="REQUIRE level of asserts fail and abort the test case - 12" filename="assertion_macros.cpp" line="0" skipped="true"/>
+ <TestCase name="REQUIRE level of asserts fail and abort the test case - 13" filename="assertion_macros.cpp" line="0" skipped="true"/>
<TestCase name="REQUIRE level of asserts fail and abort the test case - 2" filename="assertion_macros.cpp" line="0" skipped="true"/>
<TestCase name="REQUIRE level of asserts fail and abort the test case - 3" filename="assertion_macros.cpp" line="0" skipped="true"/>
<TestCase name="REQUIRE level of asserts fail and abort the test case - 4" filename="assertion_macros.cpp" line="0" skipped="true"/>
- <TestCase name="REQUIRE level of asserts fail and abort the test case - 4" filename="assertion_macros.cpp" line="0" skipped="true"/>
- <TestCase name="REQUIRE level of asserts fail and abort the test case - 5" filename="assertion_macros.cpp" line="0" skipped="true"/>
<TestCase name="REQUIRE level of asserts fail and abort the test case - 5" filename="assertion_macros.cpp" line="0" skipped="true"/>
<TestCase name="REQUIRE level of asserts fail and abort the test case - 6" filename="assertion_macros.cpp" line="0" skipped="true"/>
<TestCase name="REQUIRE level of asserts fail and abort the test case - 7" filename="assertion_macros.cpp" line="0" skipped="true"/>
@@ -112,6 +114,6 @@
<TestCase name="will end from an unknown exception" filename="coverage_maxout.cpp" line="0" skipped="true"/>
</TestSuite>
<OverallResultsAsserts successes="0" failures="0"/>
- <OverallResultsTestCases successes="0" failures="0" skipped="74"/>
+ <OverallResultsTestCases successes="0" failures="0" skipped="76"/>
</doctest>
Program code.