Merge branch 'reevaluate' into dev-modernize

This commit is contained in:
Phil Nash
2017-08-10 16:18:05 +01:00
45 changed files with 726 additions and 901 deletions

View File

@@ -499,7 +499,7 @@ ExceptionTests.cpp:<line number>
ExceptionTests.cpp:<line number>: FAILED:
REQUIRE_THROWS_WITH( thisThrows(), "should fail" )
with expansion:
expected exception
"expected exception" equals: "should fail"
-------------------------------------------------------------------------------
Nice descriptive name

View File

@@ -1428,6 +1428,8 @@ ExceptionTests.cpp:<line number>
ExceptionTests.cpp:<line number>:
PASSED:
REQUIRE_THROWS_WITH( thisThrows(), "expected exception" )
with expansion:
"expected exception" equals: "expected exception"
-------------------------------------------------------------------------------
Exception messages can be tested for
@@ -1439,6 +1441,8 @@ ExceptionTests.cpp:<line number>
ExceptionTests.cpp:<line number>:
PASSED:
REQUIRE_THROWS_WITH( thisThrows(), Equals( "expecteD Exception", Catch::CaseSensitive::No ) )
with expansion:
"expected exception" equals: "expected exception" (case insensitive)
-------------------------------------------------------------------------------
Exception messages can be tested for
@@ -1450,18 +1454,26 @@ ExceptionTests.cpp:<line number>
ExceptionTests.cpp:<line number>:
PASSED:
REQUIRE_THROWS_WITH( thisThrows(), StartsWith( "expected" ) )
with expansion:
"expected exception" starts with: "expected"
ExceptionTests.cpp:<line number>:
PASSED:
REQUIRE_THROWS_WITH( thisThrows(), EndsWith( "exception" ) )
with expansion:
"expected exception" ends with: "exception"
ExceptionTests.cpp:<line number>:
PASSED:
REQUIRE_THROWS_WITH( thisThrows(), Contains( "except" ) )
with expansion:
"expected exception" contains: "except"
ExceptionTests.cpp:<line number>:
PASSED:
REQUIRE_THROWS_WITH( thisThrows(), Contains( "exCept", Catch::CaseSensitive::No ) )
with expansion:
"expected exception" contains: "except" (case insensitive)
-------------------------------------------------------------------------------
Expected exceptions that don't throw or unexpected exceptions fail the test
@@ -1986,11 +1998,13 @@ ExceptionTests.cpp:<line number>
ExceptionTests.cpp:<line number>:
PASSED:
REQUIRE_THROWS_WITH( thisThrows(), "expected exception" )
with expansion:
"expected exception" equals: "expected exception"
ExceptionTests.cpp:<line number>: FAILED:
REQUIRE_THROWS_WITH( thisThrows(), "should fail" )
with expansion:
expected exception
"expected exception" equals: "should fail"
-------------------------------------------------------------------------------
Nice descriptive name

View File

@@ -311,7 +311,7 @@ MatchersTests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Mismatching exception messages failing the test" time="{duration}">
<failure message="expected exception" type="REQUIRE_THROWS_WITH">
<failure message="&quot;expected exception&quot; equals: &quot;should fail&quot;" type="REQUIRE_THROWS_WITH">
ExceptionTests.cpp:<line number>
</failure>
</testcase>

View File

@@ -1646,7 +1646,7 @@
thisThrows(), "expected exception"
</Original>
<Expanded>
thisThrows(), "expected exception"
"expected exception" equals: "expected exception"
</Expanded>
</Expression>
<OverallResults successes="1" failures="0" expectedFailures="0"/>
@@ -1657,7 +1657,7 @@
thisThrows(), Equals( "expecteD Exception", Catch::CaseSensitive::No )
</Original>
<Expanded>
thisThrows(), Equals( "expecteD Exception", Catch::CaseSensitive::No )
"expected exception" equals: "expected exception" (case insensitive)
</Expanded>
</Expression>
<OverallResults successes="1" failures="0" expectedFailures="0"/>
@@ -1668,7 +1668,7 @@
thisThrows(), StartsWith( "expected" )
</Original>
<Expanded>
thisThrows(), StartsWith( "expected" )
"expected exception" starts with: "expected"
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/<exe-name>/ExceptionTests.cpp" >
@@ -1676,7 +1676,7 @@
thisThrows(), EndsWith( "exception" )
</Original>
<Expanded>
thisThrows(), EndsWith( "exception" )
"expected exception" ends with: "exception"
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/<exe-name>/ExceptionTests.cpp" >
@@ -1684,7 +1684,7 @@
thisThrows(), Contains( "except" )
</Original>
<Expanded>
thisThrows(), Contains( "except" )
"expected exception" contains: "except"
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/<exe-name>/ExceptionTests.cpp" >
@@ -1692,7 +1692,7 @@
thisThrows(), Contains( "exCept", Catch::CaseSensitive::No )
</Original>
<Expanded>
thisThrows(), Contains( "exCept", Catch::CaseSensitive::No )
"expected exception" contains: "except" (case insensitive)
</Expanded>
</Expression>
<OverallResults successes="4" failures="0" expectedFailures="0"/>
@@ -2172,7 +2172,7 @@
thisThrows(), "expected exception"
</Original>
<Expanded>
thisThrows(), "expected exception"
"expected exception" equals: "expected exception"
</Expanded>
</Expression>
<Expression success="false" type="REQUIRE_THROWS_WITH" filename="projects/<exe-name>/ExceptionTests.cpp" >
@@ -2180,7 +2180,7 @@
thisThrows(), "should fail"
</Original>
<Expanded>
expected exception
"expected exception" equals: "should fail"
</Expanded>
</Expression>
<OverallResult success="false"/>

View File

@@ -43,7 +43,9 @@ bool templated_tests(T t) {
REQUIRE_THROWS(throws_int(true));
CHECK_THROWS_AS(throws_int(true), int);
REQUIRE_NOTHROW(throws_int(false));
#ifndef CATCH_CONFIG_DISABLE_MATCHERS
REQUIRE_THAT("aaa", Catch::EndsWith("aaa"));
#endif
return true;
}

View File

@@ -181,6 +181,8 @@ TEST_CASE( "Unexpected exceptions can be translated", "[.][failing][!throws]" )
throw double( 3.14 );
}
#ifndef CATCH_CONFIG_DISABLE_MATCHERS
TEST_CASE( "Exception messages can be tested for", "[!throws]" ) {
using namespace Catch::Matchers;
SECTION( "exact match" )
@@ -195,6 +197,8 @@ TEST_CASE( "Exception messages can be tested for", "[!throws]" ) {
}
}
#endif
TEST_CASE( "Mismatching exception messages failing the test", "[.][failing][!throws]" ) {
REQUIRE_THROWS_WITH( thisThrows(), "expected exception" );
REQUIRE_THROWS_WITH( thisThrows(), "should fail" );

View File

@@ -8,6 +8,8 @@
#include "catch.hpp"
#ifndef CATCH_CONFIG_DISABLE_MATCHERS
inline const char* testStringForMatching()
{
return "this string contains 'abc' as a substring";
@@ -223,3 +225,5 @@ TEST_CASE("Exception matchers that fail", "[matchers][exceptions][!throws][.fail
REQUIRE_THROWS_MATCHES(throws(4), SpecialException, ExceptionMatcher{ 1 });
}
}
#endif // CATCH_CONFIG_DISABLE_MATCHERS

View File

@@ -37,7 +37,7 @@ using namespace Catch;
//}
Catch::TestCaseTracking::NameAndLocation makeNAL( std::string const& name ) {
return Catch::TestCaseTracking::NameAndLocation( name, Catch::SourceLineInfo() );
return Catch::TestCaseTracking::NameAndLocation( name, Catch::SourceLineInfo("",0) );
}
TEST_CASE( "Tracker" ) {

View File

@@ -11,8 +11,6 @@
TEST_CASE( "Tag alias can be registered against tag patterns" ) {
using namespace Catch::Matchers;
Catch::TagAliasRegistry registry;
registry.add( "[@zzz]", "[one][two]", Catch::SourceLineInfo( "file", 2 ) );
@@ -24,11 +22,14 @@ TEST_CASE( "Tag alias can be registered against tag patterns" ) {
FAIL( "expected exception" );
}
catch( std::exception& ex ) {
#ifndef CATCH_CONFIG_DISABLE_MATCHERS
std::string what = ex.what();
using namespace Catch::Matchers;
CHECK_THAT( what, Contains( "[@zzz]" ) );
CHECK_THAT( what, Contains( "file" ) );
CHECK_THAT( what, Contains( "2" ) );
CHECK_THAT( what, Contains( "10" ) );
#endif
}
}

View File

@@ -47,7 +47,9 @@ inline Catch::TestCase fakeTestCase( const char* name, const char* desc = "" ){
TEST_CASE( "Process can be configured on command line", "[config][command-line]" ) {
#ifndef CATCH_CONFIG_DISABLE_MATCHERS
using namespace Catch::Matchers;
#endif
Catch::ConfigData config;
auto cli = Catch::makeCommandLineParser(config);
@@ -153,7 +155,9 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]"
auto result = cli.parse({"test", "-x", "oops"});
CHECK(!result);
#ifndef CATCH_CONFIG_DISABLE_MATCHERS
REQUIRE_THAT(result.errorMessage(), Contains("convert") && Contains("oops"));
#endif
}
}
@@ -225,7 +229,9 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]"
SECTION( "error" ) {
auto result = cli.parse({"test", "--use-colour", "wrong"});
CHECK( !result );
#ifndef CATCH_CONFIG_DISABLE_MATCHERS
CHECK_THAT( result.errorMessage(), Contains( "colour mode must be one of" ) );
#endif
}
}
}