Skip to content

Commit

Permalink
Add tests for printing the description of an unwated exception in Ass…
Browse files Browse the repository at this point in the history
…ertThrows
  • Loading branch information
Cogitri committed Feb 26, 2020
1 parent 90c9283 commit 9925f93
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions example/exceptions_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ struct ClassWithExceptions
}
};

struct ExceptionWeExcepted : public std::exception
{
const char* what() const throw()
{
return "Description of the exception we expected";
}
};

void ExceptionTests()
{
ClassWithExceptions objectUnderTest;
Expand Down Expand Up @@ -89,4 +97,9 @@ void ExceptionTests()
AssertThrows(AssertionException, LastException<std::logic_error>());
AssertThat(LastException<AssertionException>().GetMessage(), Contains("No exception was stored"));
}

it("prints description of unwanted exception");
{
AssertTestFails(AssertThrows(ExceptionWeExcepted, objectUnderTest.LogicError()), "Expected ExceptionWeExcepted. Wrong exception was thrown. Description of unwated exception: not logical!");
}
}

0 comments on commit 9925f93

Please sign in to comment.