Skip to content

Commit

Permalink
REQUIRE_THROWS etc take an expression not a block
Browse files Browse the repository at this point in the history
The first argument to REQUIRE_THROWS and REQUIRE_THROWS_AS is
documented as being an expression and recent changes mean that is
now being enforced.

catchorg/Catch2#823
  • Loading branch information
tomhughes committed Feb 13, 2017
1 parent 224e560 commit aa87f03
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
5 changes: 1 addition & 4 deletions test/t/basic/test_cases.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ TEST_CASE("check every possible value for single byte in buffer") {

REQUIRE(item.length() == 1);
REQUIRE(!!item); // test operator bool()
REQUIRE_THROWS({
item.next();
item.skip();
});
REQUIRE_THROWS((item.next(), item.skip()));
}
}

Expand Down
4 changes: 1 addition & 3 deletions test/t/data_view/test_cases.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ TEST_CASE("convert data_view to std::string") {

TEST_CASE("converting default constructed data_view to string fails") {
protozero::data_view view;
REQUIRE_THROWS_AS({
view.to_string();
}, assert_error);
REQUIRE_THROWS_AS(view.to_string(), assert_error);
}

TEST_CASE("swapping data_view") {
Expand Down
16 changes: 4 additions & 12 deletions test/t/rollback/test_cases.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@ TEST_CASE("rollback when using packed_field functions") {
protozero::packed_field_sint64 field{pw, 1};
field.add_element(1L);
field.rollback();
REQUIRE_THROWS_AS({
field.add_element(1L);
}, assert_error);
REQUIRE_THROWS_AS(field.add_element(1L), assert_error);
}
}
}
Expand Down Expand Up @@ -174,9 +172,7 @@ TEST_CASE("rollback when using submessages") {
TEST_CASE("rollback on parent message is never allowed") {
std::string buffer;
protozero::pbf_writer pw(buffer);
REQUIRE_THROWS_AS({
pw.rollback();
}, assert_error);
REQUIRE_THROWS_AS(pw.rollback(), assert_error);
}

TEST_CASE("rollback on parent message is not allowed even if there is a submessage") {
Expand All @@ -189,9 +185,7 @@ TEST_CASE("rollback on parent message is not allowed even if there is a submessa
{
protozero::pbf_writer pws(pw, 1);
pws.add_string(1, "foobar");
REQUIRE_THROWS_AS({
pw.rollback();
}, assert_error);
REQUIRE_THROWS_AS(pw.rollback(), assert_error);
}
}

Expand All @@ -206,9 +200,7 @@ TEST_CASE("rollback on message is not allowed if there is a nested submessage")
protozero::pbf_writer pws(pw, 1);
pws.add_string(1, "foobar");
protozero::pbf_writer pws2(pws, 1);
REQUIRE_THROWS_AS({
pws.rollback();
}, assert_error);
REQUIRE_THROWS_AS(pws.rollback(), assert_error);
}
}

0 comments on commit aa87f03

Please sign in to comment.