Added new assertion macros: *_THROWS_WITH

It combines `*_THROWS_AS` and `*_THROWS_WITH` macros, so that the
exception type matches expectetations and its contents match a specific
matcher.
This commit is contained in:
Martin Hořeňovský
2017-06-05 18:40:50 +02:00
parent 7f6773bb4d
commit 950cae9040
3 changed files with 30 additions and 1 deletions

View File

@@ -108,8 +108,13 @@ REQUIRE_THROWS_WITH( openThePodBayDoors(), Contains( "afraid" ) && Contains( "ca
REQUIRE_THROWS_WITH( dismantleHal(), "My mind is going" );
```
* **REQUIRE_THROWS_MATCHES(** _expression_, _exception type_, _matcher for given exception type_ **)** and
* **CHECK_THROWS_MATCHES(** _expression_, _exception type_, _matcher for given exception type_ **)**
Please note that the `THROW` family of assertions expects to be passed a single expression, not a statement or series of statements. If you want to check a more complicated sequence of operations, you can use a C++11 lambda function.
Expects that exception of _exception type_ is thrown and it matches provided matcher (see next section for Matchers).
_Please note that the `THROW` family of assertions expects to be passed a single expression, not a statement or series of statements. If you want to check a more complicated sequence of operations, you can use a C++11 lambda function._
```cpp
REQUIRE_NOTHROW([&](){