mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-23 03:43:28 +01:00
Removed all (that I could find) redundant second macro args to TEST_CASE and SECTION
- now we can rely on variadic macros
This commit is contained in:
parent
c89bdf842e
commit
f193698fb3
@ -114,18 +114,18 @@
|
||||
#define CATCH_FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
|
||||
#define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( "CATCH_SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
|
||||
|
||||
#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" )
|
||||
#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE()
|
||||
|
||||
#define CATCH_REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType )
|
||||
|
||||
// "BDD-style" convenience wrappers
|
||||
#define CATCH_SCENARIO( ... ) CATCH_TEST_CASE( "Scenario: " __VA_ARGS__ )
|
||||
#define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ )
|
||||
#define CATCH_GIVEN( desc ) CATCH_SECTION( std::string( "Given: ") + desc, "" )
|
||||
#define CATCH_WHEN( desc ) CATCH_SECTION( std::string( " When: ") + desc, "" )
|
||||
#define CATCH_AND_WHEN( desc ) CATCH_SECTION( std::string( " And: ") + desc, "" )
|
||||
#define CATCH_THEN( desc ) CATCH_SECTION( std::string( " Then: ") + desc, "" )
|
||||
#define CATCH_AND_THEN( desc ) CATCH_SECTION( std::string( " And: ") + desc, "" )
|
||||
#define CATCH_GIVEN( desc ) CATCH_SECTION( std::string( "Given: ") + desc )
|
||||
#define CATCH_WHEN( desc ) CATCH_SECTION( std::string( " When: ") + desc )
|
||||
#define CATCH_AND_WHEN( desc ) CATCH_SECTION( std::string( " And: ") + desc )
|
||||
#define CATCH_THEN( desc ) CATCH_SECTION( std::string( " Then: ") + desc )
|
||||
#define CATCH_AND_THEN( desc ) CATCH_SECTION( std::string( " And: ") + desc )
|
||||
|
||||
// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required
|
||||
#else
|
||||
@ -180,7 +180,7 @@
|
||||
#define FAIL( ... ) INTERNAL_CATCH_MSG( "FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ )
|
||||
#define FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
|
||||
#define SUCCEED( ... ) INTERNAL_CATCH_MSG( "SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
|
||||
#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" )
|
||||
#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE()
|
||||
|
||||
#define REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType )
|
||||
|
||||
@ -192,11 +192,11 @@
|
||||
#define SCENARIO( ... ) TEST_CASE( "Scenario: " __VA_ARGS__ )
|
||||
#define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ )
|
||||
|
||||
#define GIVEN( desc ) SECTION( std::string(" Given: ") + desc, "" )
|
||||
#define WHEN( desc ) SECTION( std::string(" When: ") + desc, "" )
|
||||
#define AND_WHEN( desc ) SECTION( std::string("And when: ") + desc, "" )
|
||||
#define THEN( desc ) SECTION( std::string(" Then: ") + desc, "" )
|
||||
#define AND_THEN( desc ) SECTION( std::string(" And: ") + desc, "" )
|
||||
#define GIVEN( desc ) SECTION( std::string(" Given: ") + desc )
|
||||
#define WHEN( desc ) SECTION( std::string(" When: ") + desc )
|
||||
#define AND_WHEN( desc ) SECTION( std::string("And when: ") + desc )
|
||||
#define THEN( desc ) SECTION( std::string(" Then: ") + desc )
|
||||
#define AND_THEN( desc ) SECTION( std::string(" And: ") + desc )
|
||||
|
||||
using Catch::Detail::Approx;
|
||||
|
||||
|
@ -15,52 +15,52 @@
|
||||
|
||||
inline Catch::TestCase fakeTestCase( const char* name, const char* desc = "" ){ return Catch::makeTestCase( nullptr, "", name, desc, CATCH_INTERNAL_LINEINFO ); }
|
||||
|
||||
TEST_CASE( "Parse test names and tags", "" ) {
|
||||
TEST_CASE( "Parse test names and tags" ) {
|
||||
|
||||
using Catch::parseTestSpec;
|
||||
using Catch::TestSpec;
|
||||
|
||||
Catch::TestCase tcA = fakeTestCase( "a", "" );
|
||||
Catch::TestCase tcA = fakeTestCase( "a" );
|
||||
Catch::TestCase tcB = fakeTestCase( "b", "[one][x]" );
|
||||
Catch::TestCase tcC = fakeTestCase( "longer name with spaces", "[two][three][.][x]" );
|
||||
Catch::TestCase tcD = fakeTestCase( "zlonger name with spacesz", "" );
|
||||
Catch::TestCase tcD = fakeTestCase( "zlonger name with spacesz" );
|
||||
|
||||
SECTION( "Empty test spec should have no filters", "" ) {
|
||||
SECTION( "Empty test spec should have no filters" ) {
|
||||
TestSpec spec;
|
||||
CHECK( spec.hasFilters() == false );
|
||||
CHECK( spec.matches( tcA ) == false );
|
||||
CHECK( spec.matches( tcB ) == false );
|
||||
}
|
||||
|
||||
SECTION( "Test spec from empty string should have no filters", "" ) {
|
||||
SECTION( "Test spec from empty string should have no filters" ) {
|
||||
TestSpec spec = parseTestSpec( "" );
|
||||
CHECK( spec.hasFilters() == false );
|
||||
CHECK( spec.matches(tcA ) == false );
|
||||
CHECK( spec.matches( tcB ) == false );
|
||||
}
|
||||
|
||||
SECTION( "Test spec from just a comma should have no filters", "" ) {
|
||||
SECTION( "Test spec from just a comma should have no filters" ) {
|
||||
TestSpec spec = parseTestSpec( "," );
|
||||
CHECK( spec.hasFilters() == false );
|
||||
CHECK( spec.matches( tcA ) == false );
|
||||
CHECK( spec.matches( tcB ) == false );
|
||||
}
|
||||
|
||||
SECTION( "Test spec from name should have one filter", "" ) {
|
||||
SECTION( "Test spec from name should have one filter" ) {
|
||||
TestSpec spec = parseTestSpec( "b" );
|
||||
CHECK( spec.hasFilters() == true );
|
||||
CHECK( spec.matches( tcA ) == false );
|
||||
CHECK( spec.matches( tcB ) == true );
|
||||
}
|
||||
|
||||
SECTION( "Test spec from quoted name should have one filter", "" ) {
|
||||
SECTION( "Test spec from quoted name should have one filter" ) {
|
||||
TestSpec spec = parseTestSpec( "\"b\"" );
|
||||
CHECK( spec.hasFilters() == true );
|
||||
CHECK( spec.matches( tcA ) == false );
|
||||
CHECK( spec.matches( tcB ) == true );
|
||||
}
|
||||
|
||||
SECTION( "Test spec from name should have one filter", "" ) {
|
||||
SECTION( "Test spec from name should have one filter" ) {
|
||||
TestSpec spec = parseTestSpec( "b" );
|
||||
CHECK( spec.hasFilters() == true );
|
||||
CHECK( spec.matches( tcA ) == false );
|
||||
@ -68,7 +68,7 @@ TEST_CASE( "Parse test names and tags", "" ) {
|
||||
CHECK( spec.matches( tcC ) == false );
|
||||
}
|
||||
|
||||
SECTION( "Wildcard at the start", "" ) {
|
||||
SECTION( "Wildcard at the start" ) {
|
||||
TestSpec spec = parseTestSpec( "*spaces" );
|
||||
CHECK( spec.hasFilters() == true );
|
||||
CHECK( spec.matches( tcA ) == false );
|
||||
@ -77,7 +77,7 @@ TEST_CASE( "Parse test names and tags", "" ) {
|
||||
CHECK( spec.matches( tcD ) == false );
|
||||
CHECK( parseTestSpec( "*a" ).matches( tcA ) == true );
|
||||
}
|
||||
SECTION( "Wildcard at the end", "" ) {
|
||||
SECTION( "Wildcard at the end" ) {
|
||||
TestSpec spec = parseTestSpec( "long*" );
|
||||
CHECK( spec.hasFilters() == true );
|
||||
CHECK( spec.matches( tcA ) == false );
|
||||
@ -86,7 +86,7 @@ TEST_CASE( "Parse test names and tags", "" ) {
|
||||
CHECK( spec.matches( tcD ) == false );
|
||||
CHECK( parseTestSpec( "a*" ).matches( tcA ) == true );
|
||||
}
|
||||
SECTION( "Wildcard at both ends", "" ) {
|
||||
SECTION( "Wildcard at both ends" ) {
|
||||
TestSpec spec = parseTestSpec( "*name*" );
|
||||
CHECK( spec.hasFilters() == true );
|
||||
CHECK( spec.matches( tcA ) == false );
|
||||
@ -95,25 +95,25 @@ TEST_CASE( "Parse test names and tags", "" ) {
|
||||
CHECK( spec.matches( tcD ) == true );
|
||||
CHECK( parseTestSpec( "*a*" ).matches( tcA ) == true );
|
||||
}
|
||||
SECTION( "Redundant wildcard at the start", "" ) {
|
||||
SECTION( "Redundant wildcard at the start" ) {
|
||||
TestSpec spec = parseTestSpec( "*a" );
|
||||
CHECK( spec.hasFilters() == true );
|
||||
CHECK( spec.matches( tcA ) == true );
|
||||
CHECK( spec.matches( tcB ) == false );
|
||||
}
|
||||
SECTION( "Redundant wildcard at the end", "" ) {
|
||||
SECTION( "Redundant wildcard at the end" ) {
|
||||
TestSpec spec = parseTestSpec( "a*" );
|
||||
CHECK( spec.hasFilters() == true );
|
||||
CHECK( spec.matches( tcA ) == true );
|
||||
CHECK( spec.matches( tcB ) == false );
|
||||
}
|
||||
SECTION( "Redundant wildcard at both ends", "" ) {
|
||||
SECTION( "Redundant wildcard at both ends" ) {
|
||||
TestSpec spec = parseTestSpec( "*a*" );
|
||||
CHECK( spec.hasFilters() == true );
|
||||
CHECK( spec.matches( tcA ) == true );
|
||||
CHECK( spec.matches( tcB ) == false );
|
||||
}
|
||||
SECTION( "Wildcard at both ends, redundant at start", "" ) {
|
||||
SECTION( "Wildcard at both ends, redundant at start" ) {
|
||||
TestSpec spec = parseTestSpec( "*longer*" );
|
||||
CHECK( spec.hasFilters() == true );
|
||||
CHECK( spec.matches( tcA ) == false );
|
||||
@ -121,7 +121,7 @@ TEST_CASE( "Parse test names and tags", "" ) {
|
||||
CHECK( spec.matches( tcC ) == true );
|
||||
CHECK( spec.matches( tcD ) == true );
|
||||
}
|
||||
SECTION( "Just wildcard", "" ) {
|
||||
SECTION( "Just wildcard" ) {
|
||||
TestSpec spec = parseTestSpec( "*" );
|
||||
CHECK( spec.hasFilters() == true );
|
||||
CHECK( spec.matches( tcA ) == true );
|
||||
@ -130,35 +130,35 @@ TEST_CASE( "Parse test names and tags", "" ) {
|
||||
CHECK( spec.matches( tcD ) == true );
|
||||
}
|
||||
|
||||
SECTION( "Single tag", "" ) {
|
||||
SECTION( "Single tag" ) {
|
||||
TestSpec spec = parseTestSpec( "[one]" );
|
||||
CHECK( spec.hasFilters() == true );
|
||||
CHECK( spec.matches( tcA ) == false );
|
||||
CHECK( spec.matches( tcB ) == true );
|
||||
CHECK( spec.matches( tcC ) == false );
|
||||
}
|
||||
SECTION( "Single tag, two matches", "" ) {
|
||||
SECTION( "Single tag, two matches" ) {
|
||||
TestSpec spec = parseTestSpec( "[x]" );
|
||||
CHECK( spec.hasFilters() == true );
|
||||
CHECK( spec.matches( tcA ) == false );
|
||||
CHECK( spec.matches( tcB ) == true );
|
||||
CHECK( spec.matches( tcC ) == true );
|
||||
}
|
||||
SECTION( "Two tags", "" ) {
|
||||
SECTION( "Two tags" ) {
|
||||
TestSpec spec = parseTestSpec( "[two][x]" );
|
||||
CHECK( spec.hasFilters() == true );
|
||||
CHECK( spec.matches( tcA ) == false );
|
||||
CHECK( spec.matches( tcB ) == false );
|
||||
CHECK( spec.matches( tcC ) == true );
|
||||
}
|
||||
SECTION( "Two tags, spare separated", "" ) {
|
||||
SECTION( "Two tags, spare separated" ) {
|
||||
TestSpec spec = parseTestSpec( "[two] [x]" );
|
||||
CHECK( spec.hasFilters() == true );
|
||||
CHECK( spec.matches( tcA ) == false );
|
||||
CHECK( spec.matches( tcB ) == false );
|
||||
CHECK( spec.matches( tcC ) == true );
|
||||
}
|
||||
SECTION( "Wildcarded name and tag", "" ) {
|
||||
SECTION( "Wildcarded name and tag" ) {
|
||||
TestSpec spec = parseTestSpec( "*name*[x]" );
|
||||
CHECK( spec.hasFilters() == true );
|
||||
CHECK( spec.matches( tcA ) == false );
|
||||
@ -166,21 +166,21 @@ TEST_CASE( "Parse test names and tags", "" ) {
|
||||
CHECK( spec.matches( tcC ) == true );
|
||||
CHECK( spec.matches( tcD ) == false );
|
||||
}
|
||||
SECTION( "Single tag exclusion", "" ) {
|
||||
SECTION( "Single tag exclusion" ) {
|
||||
TestSpec spec = parseTestSpec( "~[one]" );
|
||||
CHECK( spec.hasFilters() == true );
|
||||
CHECK( spec.matches( tcA ) == true );
|
||||
CHECK( spec.matches( tcB ) == false );
|
||||
CHECK( spec.matches( tcC ) == true );
|
||||
}
|
||||
SECTION( "One tag exclusion and one tag inclusion", "" ) {
|
||||
SECTION( "One tag exclusion and one tag inclusion" ) {
|
||||
TestSpec spec = parseTestSpec( "~[two][x]" );
|
||||
CHECK( spec.hasFilters() == true );
|
||||
CHECK( spec.matches( tcA ) == false );
|
||||
CHECK( spec.matches( tcB ) == true );
|
||||
CHECK( spec.matches( tcC ) == false );
|
||||
}
|
||||
SECTION( "One tag exclusion and one wldcarded name inclusion", "" ) {
|
||||
SECTION( "One tag exclusion and one wldcarded name inclusion" ) {
|
||||
TestSpec spec = parseTestSpec( "~[two]*name*" );
|
||||
CHECK( spec.hasFilters() == true );
|
||||
CHECK( spec.matches( tcA ) == false );
|
||||
@ -188,7 +188,7 @@ TEST_CASE( "Parse test names and tags", "" ) {
|
||||
CHECK( spec.matches( tcC ) == false );
|
||||
CHECK( spec.matches( tcD ) == true );
|
||||
}
|
||||
SECTION( "One tag exclusion, using exclude:, and one wldcarded name inclusion", "" ) {
|
||||
SECTION( "One tag exclusion, using exclude:, and one wldcarded name inclusion" ) {
|
||||
TestSpec spec = parseTestSpec( "exclude:[two]*name*" );
|
||||
CHECK( spec.hasFilters() == true );
|
||||
CHECK( spec.matches( tcA ) == false );
|
||||
@ -196,7 +196,7 @@ TEST_CASE( "Parse test names and tags", "" ) {
|
||||
CHECK( spec.matches( tcC ) == false );
|
||||
CHECK( spec.matches( tcD ) == true );
|
||||
}
|
||||
SECTION( "name exclusion", "" ) {
|
||||
SECTION( "name exclusion" ) {
|
||||
TestSpec spec = parseTestSpec( "~b" );
|
||||
CHECK( spec.hasFilters() == true );
|
||||
CHECK( spec.matches( tcA ) == true );
|
||||
@ -204,7 +204,7 @@ TEST_CASE( "Parse test names and tags", "" ) {
|
||||
CHECK( spec.matches( tcC ) == true );
|
||||
CHECK( spec.matches( tcD ) == true );
|
||||
}
|
||||
SECTION( "wildcarded name exclusion", "" ) {
|
||||
SECTION( "wildcarded name exclusion" ) {
|
||||
TestSpec spec = parseTestSpec( "~*name*" );
|
||||
CHECK( spec.hasFilters() == true );
|
||||
CHECK( spec.matches( tcA ) == true );
|
||||
@ -212,7 +212,7 @@ TEST_CASE( "Parse test names and tags", "" ) {
|
||||
CHECK( spec.matches( tcC ) == false );
|
||||
CHECK( spec.matches( tcD ) == false );
|
||||
}
|
||||
SECTION( "wildcarded name exclusion with tag inclusion", "" ) {
|
||||
SECTION( "wildcarded name exclusion with tag inclusion" ) {
|
||||
TestSpec spec = parseTestSpec( "~*name*,[three]" );
|
||||
CHECK( spec.hasFilters() == true );
|
||||
CHECK( spec.matches( tcA ) == true );
|
||||
@ -220,7 +220,7 @@ TEST_CASE( "Parse test names and tags", "" ) {
|
||||
CHECK( spec.matches( tcC ) == true );
|
||||
CHECK( spec.matches( tcD ) == false );
|
||||
}
|
||||
SECTION( "wildcarded name exclusion, using exclude:, with tag inclusion", "" ) {
|
||||
SECTION( "wildcarded name exclusion, using exclude:, with tag inclusion" ) {
|
||||
TestSpec spec = parseTestSpec( "exclude:*name*,[three]" );
|
||||
CHECK( spec.hasFilters() == true );
|
||||
CHECK( spec.matches( tcA ) == true );
|
||||
@ -228,7 +228,7 @@ TEST_CASE( "Parse test names and tags", "" ) {
|
||||
CHECK( spec.matches( tcC ) == true );
|
||||
CHECK( spec.matches( tcD ) == false );
|
||||
}
|
||||
SECTION( "two wildcarded names", "" ) {
|
||||
SECTION( "two wildcarded names" ) {
|
||||
TestSpec spec = parseTestSpec( "\"longer*\"\"*spaces\"" );
|
||||
CHECK( spec.hasFilters() == true );
|
||||
CHECK( spec.matches( tcA ) == false );
|
||||
@ -236,7 +236,7 @@ TEST_CASE( "Parse test names and tags", "" ) {
|
||||
CHECK( spec.matches( tcC ) == true );
|
||||
CHECK( spec.matches( tcD ) == false );
|
||||
}
|
||||
SECTION( "empty tag", "" ) {
|
||||
SECTION( "empty tag" ) {
|
||||
TestSpec spec = parseTestSpec( "[]" );
|
||||
CHECK( spec.hasFilters() == false );
|
||||
CHECK( spec.matches( tcA ) == false );
|
||||
@ -244,7 +244,7 @@ TEST_CASE( "Parse test names and tags", "" ) {
|
||||
CHECK( spec.matches( tcC ) == false );
|
||||
CHECK( spec.matches( tcD ) == false );
|
||||
}
|
||||
SECTION( "empty quoted name", "" ) {
|
||||
SECTION( "empty quoted name" ) {
|
||||
TestSpec spec = parseTestSpec( "\"\"" );
|
||||
CHECK( spec.hasFilters() == false );
|
||||
CHECK( spec.matches( tcA ) == false );
|
||||
@ -252,7 +252,7 @@ TEST_CASE( "Parse test names and tags", "" ) {
|
||||
CHECK( spec.matches( tcC ) == false );
|
||||
CHECK( spec.matches( tcD ) == false );
|
||||
}
|
||||
SECTION( "quoted string followed by tag exclusion", "" ) {
|
||||
SECTION( "quoted string followed by tag exclusion" ) {
|
||||
TestSpec spec = parseTestSpec( "\"*name*\"~[.]" );
|
||||
CHECK( spec.hasFilters() == true );
|
||||
CHECK( spec.matches( tcA ) == false );
|
||||
|
@ -59,7 +59,7 @@ TEST_CASE( "An unchecked exception reports the line of the last assertion", "[.]
|
||||
|
||||
TEST_CASE( "When unchecked exceptions are thrown from sections they are always failures", "[.][failing][!throws]" )
|
||||
{
|
||||
SECTION( "section name", "" )
|
||||
SECTION( "section name" )
|
||||
{
|
||||
if( Catch::alwaysTrue() )
|
||||
throw std::domain_error( "unexpected exception" );
|
||||
|
@ -13,26 +13,23 @@
|
||||
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
|
||||
#endif
|
||||
|
||||
TEST_CASE( "INFO and WARN do not abort tests", "[messages][.]" )
|
||||
{
|
||||
TEST_CASE( "INFO and WARN do not abort tests", "[messages][.]" ) {
|
||||
INFO( "this is a " << "message" ); // This should output the message if a failure occurs
|
||||
WARN( "this is a " << "warning" ); // This should always output the message but then continue
|
||||
}
|
||||
TEST_CASE( "SUCCEED counts as a test pass", "[messages]" )
|
||||
{
|
||||
|
||||
TEST_CASE( "SUCCEED counts as a test pass", "[messages]" ) {
|
||||
SUCCEED( "this is a " << "success" );
|
||||
}
|
||||
|
||||
TEST_CASE( "INFO gets logged on failure", "[failing][messages][.]" )
|
||||
{
|
||||
TEST_CASE( "INFO gets logged on failure", "[failing][messages][.]" ) {
|
||||
INFO( "this message should be logged" );
|
||||
INFO( "so should this" );
|
||||
int a = 2;
|
||||
REQUIRE( a == 1 );
|
||||
}
|
||||
|
||||
TEST_CASE( "INFO gets logged on failure, even if captured before successful assertions", "[failing][messages][.]" )
|
||||
{
|
||||
TEST_CASE( "INFO gets logged on failure, even if captured before successful assertions", "[failing][messages][.]" ) {
|
||||
INFO( "this message may be logged later" );
|
||||
int a = 2;
|
||||
CHECK( a == 2 );
|
||||
@ -50,55 +47,45 @@ TEST_CASE( "INFO gets logged on failure, even if captured before successful asse
|
||||
CHECK( a == 2 );
|
||||
}
|
||||
|
||||
TEST_CASE( "FAIL aborts the test", "[failing][messages][.]" )
|
||||
{
|
||||
TEST_CASE( "FAIL aborts the test", "[failing][messages][.]" ) {
|
||||
FAIL( "This is a " << "failure" ); // This should output the message and abort
|
||||
WARN( "We should never see this");
|
||||
}
|
||||
|
||||
TEST_CASE( "FAIL_CHECK does not abort the test", "[failing][messages][.]" )
|
||||
{
|
||||
TEST_CASE( "FAIL_CHECK does not abort the test", "[failing][messages][.]" ) {
|
||||
FAIL_CHECK( "This is a " << "failure" ); // This should output the message then continue
|
||||
WARN( "This message appears in the output");
|
||||
}
|
||||
|
||||
TEST_CASE( "FAIL does not require an argument", "[failing][messages][.]" )
|
||||
{
|
||||
TEST_CASE( "FAIL does not require an argument", "[failing][messages][.]" ) {
|
||||
FAIL();
|
||||
}
|
||||
TEST_CASE( "SUCCESS does not require an argument", "[messages][.]" )
|
||||
{
|
||||
|
||||
TEST_CASE( "SUCCESS does not require an argument", "[messages][.]" ) {
|
||||
SUCCEED();
|
||||
}
|
||||
|
||||
TEST_CASE( "Output from all sections is reported", "[failing][messages][.]" )
|
||||
{
|
||||
SECTION( "one", "" )
|
||||
{
|
||||
TEST_CASE( "Output from all sections is reported", "[failing][messages][.]" ) {
|
||||
SECTION( "one" ) {
|
||||
FAIL( "Message from section one" );
|
||||
}
|
||||
|
||||
SECTION( "two", "" )
|
||||
{
|
||||
SECTION( "two" ) {
|
||||
FAIL( "Message from section two" );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE( "Standard output from all sections is reported", "[messages][.]" )
|
||||
{
|
||||
SECTION( "one", "" )
|
||||
{
|
||||
TEST_CASE( "Standard output from all sections is reported", "[messages][.]" ) {
|
||||
SECTION( "one" ) {
|
||||
std::cout << "Message from section one" << std::endl;
|
||||
}
|
||||
|
||||
SECTION( "two", "" )
|
||||
{
|
||||
SECTION( "two" ) {
|
||||
std::cout << "Message from section two" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE( "SCOPED_INFO is reset for each loop", "[messages][failing][.]" )
|
||||
{
|
||||
TEST_CASE( "SCOPED_INFO is reset for each loop", "[messages][failing][.]" ) {
|
||||
for( int i=0; i<100; i++ )
|
||||
{
|
||||
SCOPED_INFO( "current counter " << i );
|
||||
@ -107,31 +94,26 @@ TEST_CASE( "SCOPED_INFO is reset for each loop", "[messages][failing][.]" )
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE( "The NO_FAIL macro reports a failure but does not fail the test", "[messages]" )
|
||||
{
|
||||
TEST_CASE( "The NO_FAIL macro reports a failure but does not fail the test", "[messages]" ) {
|
||||
CHECK_NOFAIL( 1 == 2 );
|
||||
}
|
||||
|
||||
TEST_CASE( "just info", "[info][isolated info][messages]" )
|
||||
{
|
||||
TEST_CASE( "just info", "[info][isolated info][messages]" ) {
|
||||
INFO( "this should never be seen" );
|
||||
}
|
||||
TEST_CASE( "just failure", "[fail][isolated info][.][messages]" )
|
||||
{
|
||||
TEST_CASE( "just failure", "[fail][isolated info][.][messages]" ) {
|
||||
FAIL( "Previous info should not be seen" );
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE( "sends information to INFO", "[.][failing]" )
|
||||
{
|
||||
TEST_CASE( "sends information to INFO", "[.][failing]" ) {
|
||||
INFO( "hi" );
|
||||
int i = 7;
|
||||
CAPTURE( i );
|
||||
REQUIRE( false );
|
||||
}
|
||||
|
||||
TEST_CASE( "Pointers can be converted to strings", "[messages][.]" )
|
||||
{
|
||||
TEST_CASE( "Pointers can be converted to strings", "[messages][.]" ) {
|
||||
int p;
|
||||
WARN( "actual address of p: " << &p );
|
||||
WARN( "toString(p): " << ::Catch::Detail::stringify( &p ) );
|
||||
|
@ -18,185 +18,150 @@
|
||||
#include <iostream>
|
||||
#include <cerrno>
|
||||
|
||||
TEST_CASE( "random SECTION tests", "[.][sections][failing]" )
|
||||
{
|
||||
TEST_CASE( "random SECTION tests", "[.][sections][failing]" ) {
|
||||
int a = 1;
|
||||
int b = 2;
|
||||
|
||||
SECTION( "s1", "doesn't equal" )
|
||||
{
|
||||
SECTION( "s1", "doesn't equal" ) {
|
||||
REQUIRE( a != b );
|
||||
REQUIRE( b != a );
|
||||
}
|
||||
|
||||
SECTION( "s2", "not equal" )
|
||||
{
|
||||
SECTION( "s2", "not equal" ) {
|
||||
REQUIRE( a != b);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE( "nested SECTION tests", "[.][sections][failing]" )
|
||||
{
|
||||
TEST_CASE( "nested SECTION tests", "[.][sections][failing]" ) {
|
||||
int a = 1;
|
||||
int b = 2;
|
||||
|
||||
SECTION( "s1", "doesn't equal" )
|
||||
{
|
||||
SECTION( "s1", "doesn't equal" ) {
|
||||
REQUIRE( a != b );
|
||||
REQUIRE( b != a );
|
||||
|
||||
SECTION( "s2", "not equal" )
|
||||
{
|
||||
SECTION( "s2", "not equal" ) {
|
||||
REQUIRE( a != b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE( "more nested SECTION tests", "[sections][failing][.]" )
|
||||
{
|
||||
TEST_CASE( "more nested SECTION tests", "[sections][failing][.]" ) {
|
||||
int a = 1;
|
||||
int b = 2;
|
||||
|
||||
SECTION( "s1", "doesn't equal" )
|
||||
{
|
||||
SECTION( "s2", "equal" )
|
||||
{
|
||||
SECTION( "s1", "doesn't equal" ) {
|
||||
SECTION( "s2", "equal" ) {
|
||||
REQUIRE( a == b );
|
||||
}
|
||||
|
||||
SECTION( "s3", "not equal" )
|
||||
{
|
||||
SECTION( "s3", "not equal" ) {
|
||||
REQUIRE( a != b );
|
||||
}
|
||||
SECTION( "s4", "less than" )
|
||||
{
|
||||
SECTION( "s4", "less than" ) {
|
||||
REQUIRE( a < b );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE( "even more nested SECTION tests", "[sections]" )
|
||||
{
|
||||
SECTION( "c", "" )
|
||||
{
|
||||
SECTION( "d (leaf)", "" )
|
||||
{
|
||||
TEST_CASE( "even more nested SECTION tests", "[sections]" ) {
|
||||
SECTION( "c" ) {
|
||||
SECTION( "d (leaf)" ) {
|
||||
SUCCEED(""); // avoid failing due to no tests
|
||||
}
|
||||
|
||||
SECTION( "e (leaf)", "" )
|
||||
{
|
||||
SECTION( "e (leaf)" ) {
|
||||
SUCCEED(""); // avoid failing due to no tests
|
||||
}
|
||||
}
|
||||
|
||||
SECTION( "f (leaf)", "" )
|
||||
{
|
||||
SECTION( "f (leaf)" ) {
|
||||
SUCCEED(""); // avoid failing due to no tests
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE( "looped SECTION tests", "[.][failing][sections]" )
|
||||
{
|
||||
TEST_CASE( "looped SECTION tests", "[.][failing][sections]" ) {
|
||||
int a = 1;
|
||||
|
||||
for( int b = 0; b < 10; ++b )
|
||||
{
|
||||
for( int b = 0; b < 10; ++b ) {
|
||||
std::ostringstream oss;
|
||||
oss << "b is currently: " << b;
|
||||
SECTION( "s1", oss.str() )
|
||||
{
|
||||
SECTION( "s1", oss.str() ) {
|
||||
CHECK( b > a );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE( "looped tests", "[.][failing]" )
|
||||
{
|
||||
TEST_CASE( "looped tests", "[.][failing]" ) {
|
||||
static const int fib[] = { 1, 1, 2, 3, 5, 8, 13, 21 };
|
||||
|
||||
for( size_t i=0; i < sizeof(fib)/sizeof(int); ++i )
|
||||
{
|
||||
for( size_t i=0; i < sizeof(fib)/sizeof(int); ++i ) {
|
||||
INFO( "Testing if fib[" << i << "] (" << fib[i] << ") is even" );
|
||||
CHECK( ( fib[i] % 2 ) == 0 );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE( "Sends stuff to stdout and stderr", "[.]" )
|
||||
{
|
||||
TEST_CASE( "Sends stuff to stdout and stderr", "[.]" ) {
|
||||
std::cout << "A string sent directly to stdout" << std::endl;
|
||||
|
||||
std::cerr << "A string sent directly to stderr" << std::endl;
|
||||
}
|
||||
|
||||
inline const char* makeString( bool makeNull )
|
||||
{
|
||||
inline const char* makeString( bool makeNull ) {
|
||||
return makeNull ? nullptr : "valid string";
|
||||
}
|
||||
|
||||
TEST_CASE( "null strings", "" )
|
||||
{
|
||||
TEST_CASE( "null strings" ) {
|
||||
REQUIRE( makeString( false ) != static_cast<char*>(nullptr));
|
||||
REQUIRE( makeString( true ) == static_cast<char*>(nullptr));
|
||||
}
|
||||
|
||||
|
||||
inline bool testCheckedIf( bool flag )
|
||||
{
|
||||
inline bool testCheckedIf( bool flag ) {
|
||||
CHECKED_IF( flag )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
TEST_CASE( "checkedIf", "" )
|
||||
{
|
||||
TEST_CASE( "checkedIf" ) {
|
||||
REQUIRE( testCheckedIf( true ) );
|
||||
}
|
||||
|
||||
TEST_CASE( "checkedIf, failing", "[failing][.]" )
|
||||
{
|
||||
TEST_CASE( "checkedIf, failing", "[failing][.]" ) {
|
||||
REQUIRE( testCheckedIf( false ) );
|
||||
}
|
||||
|
||||
inline bool testCheckedElse( bool flag )
|
||||
{
|
||||
inline bool testCheckedElse( bool flag ) {
|
||||
CHECKED_ELSE( flag )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
TEST_CASE( "checkedElse", "" )
|
||||
{
|
||||
TEST_CASE( "checkedElse" ) {
|
||||
REQUIRE( testCheckedElse( true ) );
|
||||
}
|
||||
|
||||
TEST_CASE( "checkedElse, failing", "[failing][.]" )
|
||||
{
|
||||
TEST_CASE( "checkedElse, failing", "[failing][.]" ) {
|
||||
REQUIRE( testCheckedElse( false ) );
|
||||
}
|
||||
|
||||
TEST_CASE( "xmlentitycheck", "" )
|
||||
{
|
||||
SECTION( "embedded xml", "<test>it should be possible to embed xml characters, such as <, \" or &, or even whole <xml>documents</xml> within an attribute</test>" )
|
||||
{
|
||||
TEST_CASE( "xmlentitycheck" ) {
|
||||
SECTION( "embedded xml", "<test>it should be possible to embed xml characters, such as <, \" or &, or even whole <xml>documents</xml> within an attribute</test>" ) {
|
||||
SUCCEED(""); // We need this here to stop it failing due to no tests
|
||||
}
|
||||
SECTION( "encoded chars", "these should all be encoded: &&&\"\"\"<<<&\"<<&\"" )
|
||||
{
|
||||
SECTION( "encoded chars", "these should all be encoded: &&&\"\"\"<<<&\"<<&\"" ) {
|
||||
SUCCEED(""); // We need this here to stop it failing due to no tests
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE( "send a single char to INFO", "[failing][.]" )
|
||||
{
|
||||
TEST_CASE( "send a single char to INFO", "[failing][.]" ) {
|
||||
INFO(3);
|
||||
REQUIRE(false);
|
||||
}
|
||||
|
||||
TEST_CASE( "atomic if", "[failing][0]")
|
||||
{
|
||||
TEST_CASE( "atomic if", "[failing][0]") {
|
||||
size_t x = 0;
|
||||
|
||||
if( x )
|
||||
@ -205,9 +170,7 @@ TEST_CASE( "atomic if", "[failing][0]")
|
||||
REQUIRE(x == 0);
|
||||
}
|
||||
|
||||
inline unsigned int Factorial( unsigned int number )
|
||||
{
|
||||
// return number <= 1 ? number : Factorial(number-1)*number;
|
||||
inline unsigned int Factorial( unsigned int number ) {
|
||||
return number > 1 ? Factorial(number-1)*number : 1;
|
||||
}
|
||||
|
||||
@ -219,20 +182,14 @@ TEST_CASE( "Factorials are computed", "[factorial]" ) {
|
||||
REQUIRE( Factorial(10) == 3628800 );
|
||||
}
|
||||
|
||||
TEST_CASE( "An empty test with no assertions", "[empty]" )
|
||||
{
|
||||
}
|
||||
TEST_CASE( "An empty test with no assertions", "[empty]" ) {}
|
||||
|
||||
TEST_CASE( "Nice descriptive name", "[tag1][tag2][tag3][.]" )
|
||||
{
|
||||
TEST_CASE( "Nice descriptive name", "[tag1][tag2][tag3][.]" ) {
|
||||
WARN( "This one ran" );
|
||||
}
|
||||
TEST_CASE( "first tag", "[tag1]" )
|
||||
{
|
||||
}
|
||||
TEST_CASE( "second tag", "[tag2]" )
|
||||
{
|
||||
}
|
||||
TEST_CASE( "first tag", "[tag1]" ) {}
|
||||
TEST_CASE( "second tag", "[tag2]" ) {}
|
||||
|
||||
//
|
||||
//TEST_CASE( "spawn a new process", "[.]" )
|
||||
//{
|
||||
@ -250,32 +207,32 @@ TEST_CASE( "vectors can be sized and resized", "[vector]" ) {
|
||||
REQUIRE( v.size() == 5 );
|
||||
REQUIRE( v.capacity() >= 5 );
|
||||
|
||||
SECTION( "resizing bigger changes size and capacity", "" ) {
|
||||
SECTION( "resizing bigger changes size and capacity" ) {
|
||||
v.resize( 10 );
|
||||
|
||||
REQUIRE( v.size() == 10 );
|
||||
REQUIRE( v.capacity() >= 10 );
|
||||
}
|
||||
SECTION( "resizing smaller changes size but not capacity", "" ) {
|
||||
SECTION( "resizing smaller changes size but not capacity" ) {
|
||||
v.resize( 0 );
|
||||
|
||||
REQUIRE( v.size() == 0 );
|
||||
REQUIRE( v.capacity() >= 5 );
|
||||
|
||||
SECTION( "We can use the 'swap trick' to reset the capacity", "" ) {
|
||||
SECTION( "We can use the 'swap trick' to reset the capacity" ) {
|
||||
std::vector<int> empty;
|
||||
empty.swap( v );
|
||||
|
||||
REQUIRE( v.capacity() == 0 );
|
||||
}
|
||||
}
|
||||
SECTION( "reserving bigger changes capacity but not size", "" ) {
|
||||
SECTION( "reserving bigger changes capacity but not size" ) {
|
||||
v.reserve( 10 );
|
||||
|
||||
REQUIRE( v.size() == 5 );
|
||||
REQUIRE( v.capacity() >= 10 );
|
||||
}
|
||||
SECTION( "reserving smaller does not change size or capacity", "" ) {
|
||||
SECTION( "reserving smaller does not change size or capacity" ) {
|
||||
v.reserve( 0 );
|
||||
|
||||
REQUIRE( v.size() == 5 );
|
||||
@ -284,8 +241,7 @@ TEST_CASE( "vectors can be sized and resized", "[vector]" ) {
|
||||
}
|
||||
|
||||
// https://github.com/philsquared/Catch/issues/166
|
||||
TEST_CASE("A couple of nested sections followed by a failure", "[failing][.]")
|
||||
{
|
||||
TEST_CASE("A couple of nested sections followed by a failure", "[failing][.]") {
|
||||
SECTION("Outer", "")
|
||||
SECTION("Inner", "")
|
||||
SUCCEED("that's not flying - that's failing in style");
|
||||
@ -293,8 +249,7 @@ TEST_CASE("A couple of nested sections followed by a failure", "[failing][.]")
|
||||
FAIL("to infinity and beyond");
|
||||
}
|
||||
|
||||
TEST_CASE("not allowed", "[!throws]")
|
||||
{
|
||||
TEST_CASE("not allowed", "[!throws]") {
|
||||
// This test case should not be included if you run with -e on the command line
|
||||
SUCCEED( "" );
|
||||
}
|
||||
@ -384,8 +339,7 @@ TEST_CASE( "long long" ) {
|
||||
// CHECK( x == 0 );
|
||||
//}
|
||||
|
||||
TEST_CASE( "This test 'should' fail but doesn't", "[.][failing][!shouldfail]" )
|
||||
{
|
||||
TEST_CASE( "This test 'should' fail but doesn't", "[.][failing][!shouldfail]" ) {
|
||||
SUCCEED( "oops!" );
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ Catch::TestCaseTracking::NameAndLocation makeNAL( std::string const& name ) {
|
||||
return Catch::TestCaseTracking::NameAndLocation( name, Catch::SourceLineInfo() );
|
||||
}
|
||||
|
||||
TEST_CASE( "Tracker", "" ) {
|
||||
TEST_CASE( "Tracker" ) {
|
||||
|
||||
TrackerContext ctx;
|
||||
ctx.startRun();
|
||||
@ -53,7 +53,7 @@ TEST_CASE( "Tracker", "" ) {
|
||||
ITracker& s1 = SectionTracker::acquire( ctx, makeNAL( "S1" ) );
|
||||
REQUIRE( s1.isOpen() );
|
||||
|
||||
SECTION( "successfully close one section", "" ) {
|
||||
SECTION( "successfully close one section" ) {
|
||||
s1.close();
|
||||
REQUIRE( s1.isSuccessfullyCompleted() );
|
||||
REQUIRE( testCase.isComplete() == false );
|
||||
@ -63,7 +63,7 @@ TEST_CASE( "Tracker", "" ) {
|
||||
REQUIRE( testCase.isSuccessfullyCompleted() );
|
||||
}
|
||||
|
||||
SECTION( "fail one section", "" ) {
|
||||
SECTION( "fail one section" ) {
|
||||
s1.fail();
|
||||
REQUIRE( s1.isComplete() );
|
||||
REQUIRE( s1.isSuccessfullyCompleted() == false );
|
||||
@ -73,7 +73,7 @@ TEST_CASE( "Tracker", "" ) {
|
||||
REQUIRE( ctx.completedCycle() );
|
||||
REQUIRE( testCase.isSuccessfullyCompleted() == false );
|
||||
|
||||
SECTION( "re-enter after failed section", "" ) {
|
||||
SECTION( "re-enter after failed section" ) {
|
||||
ctx.startCycle();
|
||||
ITracker& testCase2 = SectionTracker::acquire( ctx, makeNAL( "Testcase" ) );
|
||||
REQUIRE( testCase2.isOpen() );
|
||||
@ -86,7 +86,7 @@ TEST_CASE( "Tracker", "" ) {
|
||||
REQUIRE( testCase.isComplete() );
|
||||
REQUIRE( testCase.isSuccessfullyCompleted() );
|
||||
}
|
||||
SECTION( "re-enter after failed section and find next section", "" ) {
|
||||
SECTION( "re-enter after failed section and find next section" ) {
|
||||
ctx.startCycle();
|
||||
ITracker& testCase2 = SectionTracker::acquire( ctx, makeNAL( "Testcase" ) );
|
||||
REQUIRE( testCase2.isOpen() );
|
||||
@ -106,7 +106,7 @@ TEST_CASE( "Tracker", "" ) {
|
||||
}
|
||||
}
|
||||
|
||||
SECTION( "successfully close one section, then find another", "" ) {
|
||||
SECTION( "successfully close one section, then find another" ) {
|
||||
s1.close();
|
||||
|
||||
ITracker& s2 = SectionTracker::acquire( ctx, makeNAL( "S2" ) );
|
||||
@ -115,7 +115,7 @@ TEST_CASE( "Tracker", "" ) {
|
||||
testCase.close();
|
||||
REQUIRE( testCase.isComplete() == false );
|
||||
|
||||
SECTION( "Re-enter - skips S1 and enters S2", "" ) {
|
||||
SECTION( "Re-enter - skips S1 and enters S2" ) {
|
||||
ctx.startCycle();
|
||||
ITracker& testCase2 = SectionTracker::acquire( ctx, makeNAL( "Testcase" ) );
|
||||
REQUIRE( testCase2.isOpen() );
|
||||
@ -165,7 +165,7 @@ TEST_CASE( "Tracker", "" ) {
|
||||
}
|
||||
}
|
||||
|
||||
SECTION( "open a nested section", "" ) {
|
||||
SECTION( "open a nested section" ) {
|
||||
ITracker& s2 = SectionTracker::acquire( ctx, makeNAL( "S2" ) );
|
||||
REQUIRE( s2.isOpen() );
|
||||
|
||||
@ -181,7 +181,7 @@ TEST_CASE( "Tracker", "" ) {
|
||||
REQUIRE( testCase.isComplete() );
|
||||
}
|
||||
|
||||
SECTION( "start a generator", "" ) {
|
||||
SECTION( "start a generator" ) {
|
||||
IndexTracker& g1 = IndexTracker::acquire( ctx, makeNAL( "G1" ), 2 );
|
||||
REQUIRE( g1.isOpen() );
|
||||
REQUIRE( g1.index() == 0 );
|
||||
@ -196,7 +196,7 @@ TEST_CASE( "Tracker", "" ) {
|
||||
testCase.close();
|
||||
REQUIRE( testCase.isSuccessfullyCompleted() == false );
|
||||
|
||||
SECTION( "Re-enter for second generation", "" ) {
|
||||
SECTION( "Re-enter for second generation" ) {
|
||||
ctx.startCycle();
|
||||
ITracker& testCase2 = SectionTracker::acquire( ctx, makeNAL( "Testcase" ) );
|
||||
REQUIRE( testCase2.isOpen() );
|
||||
@ -218,7 +218,7 @@ TEST_CASE( "Tracker", "" ) {
|
||||
REQUIRE( testCase2.isComplete() );
|
||||
}
|
||||
}
|
||||
SECTION( "Start a new inner section", "" ) {
|
||||
SECTION( "Start a new inner section" ) {
|
||||
ITracker& s2 = SectionTracker::acquire( ctx, makeNAL( "S2" ) );
|
||||
REQUIRE( s2.isOpen() );
|
||||
|
||||
@ -231,7 +231,7 @@ TEST_CASE( "Tracker", "" ) {
|
||||
testCase.close();
|
||||
REQUIRE( testCase.isComplete() == false );
|
||||
|
||||
SECTION( "Re-enter for second generation", "" ) {
|
||||
SECTION( "Re-enter for second generation" ) {
|
||||
ctx.startCycle();
|
||||
ITracker& testCase2 = SectionTracker::acquire( ctx, makeNAL( "Testcase" ) );
|
||||
REQUIRE( testCase2.isOpen() );
|
||||
@ -260,7 +260,7 @@ TEST_CASE( "Tracker", "" ) {
|
||||
}
|
||||
}
|
||||
|
||||
SECTION( "Fail an inner section", "" ) {
|
||||
SECTION( "Fail an inner section" ) {
|
||||
ITracker& s2 = SectionTracker::acquire( ctx, makeNAL( "S2" ) );
|
||||
REQUIRE( s2.isOpen() );
|
||||
|
||||
@ -274,7 +274,7 @@ TEST_CASE( "Tracker", "" ) {
|
||||
testCase.close();
|
||||
REQUIRE( testCase.isComplete() == false );
|
||||
|
||||
SECTION( "Re-enter for second generation", "" ) {
|
||||
SECTION( "Re-enter for second generation" ) {
|
||||
ctx.startCycle();
|
||||
ITracker& testCase2 = SectionTracker::acquire( ctx, makeNAL( "Testcase" ) );
|
||||
REQUIRE( testCase2.isOpen() );
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "catch.hpp"
|
||||
#include "internal/catch_tag_alias_registry.h"
|
||||
|
||||
TEST_CASE( "Tag alias can be registered against tag patterns", "" ) {
|
||||
TEST_CASE( "Tag alias can be registered against tag patterns" ) {
|
||||
|
||||
using namespace Catch::Matchers;
|
||||
|
||||
@ -17,7 +17,7 @@ TEST_CASE( "Tag alias can be registered against tag patterns", "" ) {
|
||||
|
||||
registry.add( "[@zzz]", "[one][two]", Catch::SourceLineInfo( "file", 2 ) );
|
||||
|
||||
SECTION( "The same tag alias can only be registered once", "" ) {
|
||||
SECTION( "The same tag alias can only be registered once" ) {
|
||||
|
||||
try {
|
||||
registry.add( "[@zzz]", "[one][two]", Catch::SourceLineInfo( "file", 10 ) );
|
||||
@ -32,7 +32,7 @@ TEST_CASE( "Tag alias can be registered against tag patterns", "" ) {
|
||||
}
|
||||
}
|
||||
|
||||
SECTION( "Tag aliases must be of the form [@name]", "" ) {
|
||||
SECTION( "Tag aliases must be of the form [@name]" ) {
|
||||
CHECK_THROWS( registry.add( "[no ampersat]", "", Catch::SourceLineInfo( "file", 3 ) ) );
|
||||
CHECK_THROWS( registry.add( "[the @ is not at the start]", "", Catch::SourceLineInfo( "file", 3 ) ) );
|
||||
CHECK_THROWS( registry.add( "@no square bracket at start]", "", Catch::SourceLineInfo( "file", 3 ) ) );
|
||||
|
@ -481,7 +481,7 @@ inline void manuallyRegisteredTestFunction() {
|
||||
}
|
||||
struct AutoTestReg {
|
||||
AutoTestReg() {
|
||||
REGISTER_TEST_CASE( manuallyRegisteredTestFunction, "ManuallyRegistered", "" );
|
||||
REGISTER_TEST_CASE( manuallyRegisteredTestFunction, "ManuallyRegistered" );
|
||||
}
|
||||
};
|
||||
AutoTestReg autoTestReg;
|
||||
|
@ -318,15 +318,15 @@ TEST_CASE( "Assertions then sections", "[Tricky]" )
|
||||
|
||||
REQUIRE( Catch::alwaysTrue() );
|
||||
|
||||
SECTION( "A section", "" )
|
||||
SECTION( "A section" )
|
||||
{
|
||||
REQUIRE( Catch::alwaysTrue() );
|
||||
|
||||
SECTION( "Another section", "" )
|
||||
SECTION( "Another section" )
|
||||
{
|
||||
REQUIRE( Catch::alwaysTrue() );
|
||||
}
|
||||
SECTION( "Another other section", "" )
|
||||
SECTION( "Another other section" )
|
||||
{
|
||||
REQUIRE( Catch::alwaysTrue() );
|
||||
}
|
||||
@ -394,7 +394,7 @@ TEST_CASE( "X/level/0/b", "[Tricky][fizz]" ){ SUCCEED(""); }
|
||||
TEST_CASE( "X/level/1/a", "[Tricky]" ) { SUCCEED(""); }
|
||||
TEST_CASE( "X/level/1/b", "[Tricky]" ) { SUCCEED(""); }
|
||||
|
||||
TEST_CASE( "has printf", "" ) {
|
||||
TEST_CASE( "has printf" ) {
|
||||
|
||||
// This can cause problems as, currently, stdout itself is not redirect - only the cout (and cerr) buffer
|
||||
printf( "spanner" );
|
||||
|
Loading…
Reference in New Issue
Block a user