More macros are now variadic

Also added tests for them
This commit is contained in:
Martin Hořeňovský
2017-05-03 19:10:27 +02:00
parent c5c3d368a2
commit a9128d0fac
6 changed files with 212 additions and 40 deletions

View File

@@ -396,6 +396,31 @@ TEST_CASE( "has printf", "" ) {
}
TEST_CASE( "assertions with commas are allowed" ) {
REQUIRE( std::vector<int>{1, 2} == std::vector<int>{1, 2} );
}
namespace {
struct constructor_throws {
constructor_throws() {
throw 1;
}
};
}
TEST_CASE("Commas in various macros are allowed") {
REQUIRE_THROWS( std::vector<constructor_throws>{constructor_throws{}, constructor_throws{}} );
CHECK_THROWS( std::vector<constructor_throws>{constructor_throws{}, constructor_throws{}} );
REQUIRE_NOTHROW( std::vector<int>{1, 2, 3} == std::vector<int>{1, 2, 3} );
CHECK_NOTHROW( std::vector<int>{1, 2, 3} == std::vector<int>{1, 2, 3} );
REQUIRE(std::vector<int>{1, 2} == std::vector<int>{1, 2});
CHECK( std::vector<int>{1, 2} == std::vector<int>{1, 2} );
REQUIRE_FALSE(std::vector<int>{1, 2} == std::vector<int>{1, 2, 3});
CHECK_FALSE( std::vector<int>{1, 2} == std::vector<int>{1, 2, 3} );
CHECK_NOFAIL( std::vector<int>{1, 2} == std::vector<int>{1, 2} );
CHECKED_IF( std::vector<int>{1, 2} == std::vector<int>{1, 2} ) {
REQUIRE(true);
} CHECKED_ELSE( std::vector<int>{1, 2} == std::vector<int>{1, 2} ) {
CHECK(true);
}
}