All tests files have .tests.cpp suffix. Also moved tests out of TestMain.cpp and moved up a level

This commit is contained in:
Phil Nash 2017-11-13 16:03:27 +00:00
parent e34754e433
commit 74d3dfd4cc
32 changed files with 3323 additions and 3322 deletions

View File

@ -47,32 +47,32 @@ endfunction()
# define the sources of the self test
# Please keep these ordered alphabetically
set(TEST_SOURCES
${SELF_TEST_DIR}/UsageTests/ApproxTests.cpp
${SELF_TEST_DIR}/UsageTests/BDDTests.cpp
${SELF_TEST_DIR}/TestMain.cpp
${SELF_TEST_DIR}/IntrospectiveTests/CmdLine.tests.cpp
${SELF_TEST_DIR}/IntrospectiveTests/PartTracker.tests.cpp
${SELF_TEST_DIR}/IntrospectiveTests/TagAlias.tests.cpp
${SELF_TEST_DIR}/IntrospectiveTests/String.tests.cpp
${SELF_TEST_DIR}/IntrospectiveTests/Xml.tests.cpp
${SELF_TEST_DIR}/UsageTests/Approx.tests.cpp
${SELF_TEST_DIR}/UsageTests/BDD.tests.cpp
${SELF_TEST_DIR}/UsageTests/Benchmark.tests.cpp
${SELF_TEST_DIR}/UsageTests/ClassTests.cpp
${SELF_TEST_DIR}/IntrospectiveTests/CmdLineTests.cpp
${SELF_TEST_DIR}/UsageTests/CompilationTests.cpp
${SELF_TEST_DIR}/UsageTests/ConditionTests.cpp
${SELF_TEST_DIR}/UsageTests/DecompositionTests.cpp
${SELF_TEST_DIR}/UsageTests/EnumToString.cpp
${SELF_TEST_DIR}/UsageTests/ExceptionTests.cpp
${SELF_TEST_DIR}/UsageTests/MessageTests.cpp
${SELF_TEST_DIR}/UsageTests/MiscTests.cpp
${SELF_TEST_DIR}/IntrospectiveTests/PartTrackerTests.cpp
${SELF_TEST_DIR}/IntrospectiveTests/TagAliasTests.cpp
${SELF_TEST_DIR}/IntrospectiveTests/TestMain.cpp
${SELF_TEST_DIR}/UsageTests/ToStringChrono.cpp
${SELF_TEST_DIR}/UsageTests/ToStringGeneralTests.cpp
${SELF_TEST_DIR}/UsageTests/ToStringPair.cpp
${SELF_TEST_DIR}/UsageTests/ToStringTuple.cpp
${SELF_TEST_DIR}/UsageTests/ToStringVector.cpp
${SELF_TEST_DIR}/UsageTests/ToStringWhich.cpp
${SELF_TEST_DIR}/UsageTests/TrickyTests.cpp
${SELF_TEST_DIR}/UsageTests/VariadicMacrosTests.cpp
${SELF_TEST_DIR}/UsageTests/MatchersTests.cpp
${SELF_TEST_DIR}/IntrospectiveTests/StringRef.tests.cpp
${SELF_TEST_DIR}/IntrospectiveTests/XmlTests.cpp
${SELF_TEST_DIR}/UsageTests/Class.tests.cpp
${SELF_TEST_DIR}/UsageTests/Compilation.tests.cpp
${SELF_TEST_DIR}/UsageTests/Condition.tests.cpp
${SELF_TEST_DIR}/UsageTests/Decomposition.tests.cpp
${SELF_TEST_DIR}/UsageTests/EnumToString.tests.cpp
${SELF_TEST_DIR}/UsageTests/Exception.tests.cpp
${SELF_TEST_DIR}/UsageTests/Message.tests.cpp
${SELF_TEST_DIR}/UsageTests/Misc.tests.cpp
${SELF_TEST_DIR}/UsageTests/ToStringChrono.tests.cpp
${SELF_TEST_DIR}/UsageTests/ToStringGeneral.tests.cpp
${SELF_TEST_DIR}/UsageTests/ToStringPair.tests.cpp
${SELF_TEST_DIR}/UsageTests/ToStringTuple.tests.cpp
${SELF_TEST_DIR}/UsageTests/ToStringVector.tests.cpp
${SELF_TEST_DIR}/UsageTests/ToStringWhich.tests.cpp
${SELF_TEST_DIR}/UsageTests/Tricky.tests.cpp
${SELF_TEST_DIR}/UsageTests/VariadicMacros.tests.cpp
${SELF_TEST_DIR}/UsageTests/Matchers.tests.cpp
)
CheckFileList(TEST_SOURCES ${SELF_TEST_DIR})

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -6,10 +6,10 @@ Run with -? for options
-------------------------------------------------------------------------------
# A test name that starts with a #
-------------------------------------------------------------------------------
MiscTests.cpp:<line number>
Misc.tests.cpp:<line number>
...............................................................................
MiscTests.cpp:<line number>:
Misc.tests.cpp:<line number>:
PASSED:
with message:
yay
@ -18,16 +18,16 @@ with message:
#1005: Comparing pointer to int and long (NULL can be either on various
systems)
-------------------------------------------------------------------------------
DecompositionTests.cpp:<line number>
Decomposition.tests.cpp:<line number>
...............................................................................
DecompositionTests.cpp:<line number>:
Decomposition.tests.cpp:<line number>:
PASSED:
REQUIRE( fptr == 0 )
with expansion:
0 == 0
DecompositionTests.cpp:<line number>:
Decomposition.tests.cpp:<line number>:
PASSED:
REQUIRE( fptr == 0l )
with expansion:
@ -36,16 +36,16 @@ with expansion:
-------------------------------------------------------------------------------
#1027
-------------------------------------------------------------------------------
CompilationTests.cpp:<line number>
Compilation.tests.cpp:<line number>
...............................................................................
CompilationTests.cpp:<line number>:
Compilation.tests.cpp:<line number>:
PASSED:
REQUIRE( y.v == 0 )
with expansion:
0 == 0
CompilationTests.cpp:<line number>:
Compilation.tests.cpp:<line number>:
PASSED:
REQUIRE( 0 == y.v )
with expansion:
@ -55,10 +55,10 @@ with expansion:
#748 - captures with unexpected exceptions
outside assertions
-------------------------------------------------------------------------------
ExceptionTests.cpp:<line number>
Exception.tests.cpp:<line number>
...............................................................................
ExceptionTests.cpp:<line number>: FAILED:
Exception.tests.cpp:<line number>: FAILED:
due to unexpected exception with messages:
answer := 42
expected exception
@ -67,10 +67,10 @@ due to unexpected exception with messages:
#748 - captures with unexpected exceptions
inside REQUIRE_NOTHROW
-------------------------------------------------------------------------------
ExceptionTests.cpp:<line number>
Exception.tests.cpp:<line number>
...............................................................................
ExceptionTests.cpp:<line number>: FAILED:
Exception.tests.cpp:<line number>: FAILED:
REQUIRE_NOTHROW( thisThrows() )
due to unexpected exception with messages:
answer := 42
@ -80,10 +80,10 @@ due to unexpected exception with messages:
#748 - captures with unexpected exceptions
inside REQUIRE_THROWS
-------------------------------------------------------------------------------
ExceptionTests.cpp:<line number>
Exception.tests.cpp:<line number>
...............................................................................
ExceptionTests.cpp:<line number>:
Exception.tests.cpp:<line number>:
PASSED:
REQUIRE_THROWS( thisThrows() )
with message:
@ -92,10 +92,10 @@ with message:
-------------------------------------------------------------------------------
#809
-------------------------------------------------------------------------------
CompilationTests.cpp:<line number>
Compilation.tests.cpp:<line number>
...............................................................................
CompilationTests.cpp:<line number>:
Compilation.tests.cpp:<line number>:
PASSED:
REQUIRE( 42 == f )
with expansion:
@ -104,40 +104,40 @@ with expansion:
-------------------------------------------------------------------------------
#833
-------------------------------------------------------------------------------
CompilationTests.cpp:<line number>
Compilation.tests.cpp:<line number>
...............................................................................
CompilationTests.cpp:<line number>:
Compilation.tests.cpp:<line number>:
PASSED:
REQUIRE( a == t )
with expansion:
3 == 3
CompilationTests.cpp:<line number>:
Compilation.tests.cpp:<line number>:
PASSED:
CHECK( a == t )
with expansion:
3 == 3
CompilationTests.cpp:<line number>:
Compilation.tests.cpp:<line number>:
PASSED:
REQUIRE_THROWS( throws_int(true) )
CompilationTests.cpp:<line number>:
Compilation.tests.cpp:<line number>:
PASSED:
CHECK_THROWS_AS( throws_int(true), int )
CompilationTests.cpp:<line number>:
Compilation.tests.cpp:<line number>:
PASSED:
REQUIRE_NOTHROW( throws_int(false) )
CompilationTests.cpp:<line number>:
Compilation.tests.cpp:<line number>:
PASSED:
REQUIRE_THAT( "aaa", Catch::EndsWith("aaa") )
with expansion:
"aaa" ends with: "aaa"
CompilationTests.cpp:<line number>:
Compilation.tests.cpp:<line number>:
PASSED:
REQUIRE( templated_tests<int>(3) )
with expansion:
@ -146,15 +146,15 @@ with expansion:
-------------------------------------------------------------------------------
#835 -- errno should not be touched by Catch
-------------------------------------------------------------------------------
MiscTests.cpp:<line number>
Misc.tests.cpp:<line number>
...............................................................................
MiscTests.cpp:<line number>: FAILED:
Misc.tests.cpp:<line number>: FAILED:
CHECK( f() == 0 )
with expansion:
1 == 0
MiscTests.cpp:<line number>:
Misc.tests.cpp:<line number>:
PASSED:
REQUIRE( errno == 1 )
with expansion:
@ -163,10 +163,10 @@ with expansion:
-------------------------------------------------------------------------------
#872
-------------------------------------------------------------------------------
CompilationTests.cpp:<line number>
Compilation.tests.cpp:<line number>
...............................................................................
CompilationTests.cpp:<line number>:
Compilation.tests.cpp:<line number>:
PASSED:
REQUIRE( x == 4 )
with expansion:
@ -178,10 +178,10 @@ with message:
#961 -- Dynamically created sections should all be reported
Looped section 0
-------------------------------------------------------------------------------
MiscTests.cpp:<line number>
Misc.tests.cpp:<line number>
...............................................................................
MiscTests.cpp:<line number>:
Misc.tests.cpp:<line number>:
PASSED:
with message:
Everything is OK
@ -190,10 +190,10 @@ with message:
#961 -- Dynamically created sections should all be reported
Looped section 1
-------------------------------------------------------------------------------
MiscTests.cpp:<line number>
Misc.tests.cpp:<line number>
...............................................................................
MiscTests.cpp:<line number>:
Misc.tests.cpp:<line number>:
PASSED:
with message:
Everything is OK
@ -202,10 +202,10 @@ with message:
#961 -- Dynamically created sections should all be reported
Looped section 2
-------------------------------------------------------------------------------
MiscTests.cpp:<line number>
Misc.tests.cpp:<line number>
...............................................................................
MiscTests.cpp:<line number>:
Misc.tests.cpp:<line number>:
PASSED:
with message:
Everything is OK
@ -214,10 +214,10 @@ with message:
#961 -- Dynamically created sections should all be reported
Looped section 3
-------------------------------------------------------------------------------
MiscTests.cpp:<line number>
Misc.tests.cpp:<line number>
...............................................................................
MiscTests.cpp:<line number>:
Misc.tests.cpp:<line number>:
PASSED:
with message:
Everything is OK
@ -226,10 +226,10 @@ with message:
#961 -- Dynamically created sections should all be reported
Looped section 4
-------------------------------------------------------------------------------
MiscTests.cpp:<line number>
Misc.tests.cpp:<line number>
...............................................................................
MiscTests.cpp:<line number>:
Misc.tests.cpp:<line number>:
PASSED:
with message:
Everything is OK
@ -237,21 +237,21 @@ with message:
-------------------------------------------------------------------------------
'Not' checks that should fail
-------------------------------------------------------------------------------
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
...............................................................................
ConditionTests.cpp:<line number>: FAILED:
Condition.tests.cpp:<line number>: FAILED:
CHECK( false != false )
ConditionTests.cpp:<line number>: FAILED:
Condition.tests.cpp:<line number>: FAILED:
CHECK( true != true )
ConditionTests.cpp:<line number>: FAILED:
Condition.tests.cpp:<line number>: FAILED:
CHECK( !true )
with expansion:
false
ConditionTests.cpp:<line number>: FAILED:
Condition.tests.cpp:<line number>: FAILED:
CHECK_FALSE( true )
with expansion:
!true

View File

@ -9,14 +9,14 @@
<error type="TEST_CASE">
expected exception
answer := 42
ExceptionTests.cpp:<line number>
Exception.tests.cpp:<line number>
</error>
</testcase>
<testcase classname="<exe-name>.global" name="#748 - captures with unexpected exceptions/inside REQUIRE_NOTHROW" time="{duration}">
<error message="thisThrows()" type="REQUIRE_NOTHROW">
expected exception
answer := 42
ExceptionTests.cpp:<line number>
Exception.tests.cpp:<line number>
</error>
</testcase>
<testcase classname="<exe-name>.global" name="#748 - captures with unexpected exceptions/inside REQUIRE_THROWS" time="{duration}"/>
@ -24,7 +24,7 @@ ExceptionTests.cpp:<line number>
<testcase classname="<exe-name>.global" name="#833" time="{duration}"/>
<testcase classname="<exe-name>.global" name="#835 -- errno should not be touched by Catch" time="{duration}">
<failure message="1 == 0" type="CHECK">
MiscTests.cpp:<line number>
Misc.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="#872" time="{duration}"/>
@ -35,28 +35,28 @@ MiscTests.cpp:<line number>
<testcase classname="<exe-name>.global" name="#961 -- Dynamically created sections should all be reported/Looped section 4" time="{duration}"/>
<testcase classname="<exe-name>.global" name="'Not' checks that should fail" time="{duration}">
<failure message="false != false" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="true != true" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="false" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="!true" type="CHECK_FALSE">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="false" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="!true" type="CHECK_FALSE">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="false" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="!(1 == 1)" type="CHECK_FALSE">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="'Not' checks that should succeed" time="{duration}"/>
@ -67,29 +67,29 @@ ConditionTests.cpp:<line number>
<testcase classname="<exe-name>.global" name="(unimplemented) static bools can be evaluated/direct" time="{duration}"/>
<testcase classname="<exe-name>.TestClass" name="A METHOD_AS_TEST_CASE based test run that fails" time="{duration}">
<failure message="&quot;hello&quot; == &quot;world&quot;" type="REQUIRE">
ClassTests.cpp:<line number>
Class.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.TestClass" name="A METHOD_AS_TEST_CASE based test run that succeeds" time="{duration}"/>
<testcase classname="<exe-name>.Fixture" name="A TEST_CASE_METHOD based test run that fails" time="{duration}">
<failure message="1 == 2" type="REQUIRE">
ClassTests.cpp:<line number>
Class.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.Fixture" name="A TEST_CASE_METHOD based test run that succeeds" time="{duration}"/>
<testcase classname="<exe-name>.global" name="A couple of nested sections followed by a failure" time="{duration}">
<failure type="FAIL">
to infinity and beyond
MiscTests.cpp:<line number>
Misc.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="A couple of nested sections followed by a failure/Outer/Inner" time="{duration}"/>
<testcase classname="<exe-name>.global" name="A failing expression with a non streamable type is still captured" time="{duration}">
<failure message="0x<hex digits> == 0x<hex digits>" type="CHECK">
TrickyTests.cpp:<line number>
Tricky.tests.cpp:<line number>
</failure>
<failure message="{?} == {?}" type="CHECK">
TrickyTests.cpp:<line number>
Tricky.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Absolute margin" time="{duration}"/>
@ -97,7 +97,7 @@ TrickyTests.cpp:<line number>
<testcase classname="<exe-name>.global" name="An unchecked exception reports the line of the last assertion" time="{duration}">
<error message="{Unknown expression after the reported line}">
unexpected exception
ExceptionTests.cpp:<line number>
Exception.tests.cpp:<line number>
</error>
</testcase>
<testcase classname="<exe-name>.global" name="Anonymous test case 1" time="{duration}"/>
@ -127,115 +127,115 @@ ExceptionTests.cpp:<line number>
<testcase classname="<exe-name>.global" name="Comparisons with int literals don't warn when mixing signed/ unsigned" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Contains string matcher" time="{duration}">
<failure message="&quot;this string contains 'abc' as a substring&quot; contains: &quot;not there&quot; (case insensitive)" type="CHECK_THAT">
MatchersTests.cpp:<line number>
Matchers.tests.cpp:<line number>
</failure>
<failure message="&quot;this string contains 'abc' as a substring&quot; contains: &quot;STRING&quot;" type="CHECK_THAT">
MatchersTests.cpp:<line number>
Matchers.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Custom exceptions can be translated when testing for nothrow" time="{duration}">
<error message="throwCustom()" type="REQUIRE_NOTHROW">
custom exception - not std
ExceptionTests.cpp:<line number>
Exception.tests.cpp:<line number>
</error>
</testcase>
<testcase classname="<exe-name>.global" name="Custom exceptions can be translated when testing for throwing as something else" time="{duration}">
<error message="throwCustom(), std::exception" type="REQUIRE_THROWS_AS">
custom exception - not std
ExceptionTests.cpp:<line number>
Exception.tests.cpp:<line number>
</error>
</testcase>
<testcase classname="<exe-name>.global" name="Custom std-exceptions can be custom translated" time="{duration}">
<error type="TEST_CASE">
custom std exception
ExceptionTests.cpp:<line number>
Exception.tests.cpp:<line number>
</error>
</testcase>
<testcase classname="<exe-name>.global" name="Default scale is invisible to comparison" time="{duration}"/>
<testcase classname="<exe-name>.global" name="EndsWith string matcher" time="{duration}">
<failure message="&quot;this string contains 'abc' as a substring&quot; ends with: &quot;Substring&quot;" type="CHECK_THAT">
MatchersTests.cpp:<line number>
Matchers.tests.cpp:<line number>
</failure>
<failure message="&quot;this string contains 'abc' as a substring&quot; ends with: &quot;this&quot; (case insensitive)" type="CHECK_THAT">
MatchersTests.cpp:<line number>
Matchers.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Epsilon only applies to Approx's value" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Equality checks that should fail" time="{duration}">
<failure message="7 == 6" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="7 == 8" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="7 == 0" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="9.1f == Approx( 9.1099996567 )" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="9.1f == Approx( 9.0 )" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="9.1f == Approx( 1.0 )" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="9.1f == Approx( 0.0 )" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="3.1415926535 == Approx( 3.1415 )" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="&quot;hello&quot; == &quot;goodbye&quot;" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="&quot;hello&quot; == &quot;hell&quot;" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="&quot;hello&quot; == &quot;hello1&quot;" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="5 == 6" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="1.3 == Approx( 1.301 )" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Equality checks that should succeed" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Equals" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Equals string matcher" time="{duration}">
<failure message="&quot;this string contains 'abc' as a substring&quot; equals: &quot;this string contains 'ABC' as a substring&quot;" type="CHECK_THAT">
MatchersTests.cpp:<line number>
Matchers.tests.cpp:<line number>
</failure>
<failure message="&quot;this string contains 'abc' as a substring&quot; equals: &quot;something else&quot; (case insensitive)" type="CHECK_THAT">
MatchersTests.cpp:<line number>
Matchers.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Exception matchers that fail/No exception" time="{duration}">
<failure message="doesNotThrow(), SpecialException, ExceptionMatcher{ 1 }" type="CHECK_THROWS_MATCHES">
MatchersTests.cpp:<line number>
Matchers.tests.cpp:<line number>
</failure>
<failure message="doesNotThrow(), SpecialException, ExceptionMatcher{ 1 }" type="REQUIRE_THROWS_MATCHES">
MatchersTests.cpp:<line number>
Matchers.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Exception matchers that fail/Type mismatch" time="{duration}">
<error message="throwsAsInt(1), SpecialException, ExceptionMatcher{ 1 }" type="CHECK_THROWS_MATCHES">
Unknown exception
MatchersTests.cpp:<line number>
Matchers.tests.cpp:<line number>
</error>
<error message="throwsAsInt(1), SpecialException, ExceptionMatcher{ 1 }" type="REQUIRE_THROWS_MATCHES">
Unknown exception
MatchersTests.cpp:<line number>
Matchers.tests.cpp:<line number>
</error>
</testcase>
<testcase classname="<exe-name>.global" name="Exception matchers that fail/Contents are wrong" time="{duration}">
<failure message="{?} special exception has value of 1" type="CHECK_THROWS_MATCHES">
MatchersTests.cpp:<line number>
Matchers.tests.cpp:<line number>
</failure>
<failure message="{?} special exception has value of 1" type="REQUIRE_THROWS_MATCHES">
MatchersTests.cpp:<line number>
Matchers.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Exception matchers that succeed" time="{duration}"/>
@ -245,31 +245,31 @@ MatchersTests.cpp:<line number>
<testcase classname="<exe-name>.global" name="Expected exceptions that don't throw or unexpected exceptions fail the test" time="{duration}">
<error message="thisThrows(), std::string" type="CHECK_THROWS_AS">
expected exception
ExceptionTests.cpp:<line number>
Exception.tests.cpp:<line number>
</error>
<failure message="thisDoesntThrow(), std::domain_error" type="CHECK_THROWS_AS">
ExceptionTests.cpp:<line number>
Exception.tests.cpp:<line number>
</failure>
<error message="thisThrows()" type="CHECK_NOTHROW">
expected exception
ExceptionTests.cpp:<line number>
Exception.tests.cpp:<line number>
</error>
</testcase>
<testcase classname="<exe-name>.global" name="FAIL aborts the test" time="{duration}">
<failure type="FAIL">
This is a failure
MessageTests.cpp:<line number>
Message.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="FAIL does not require an argument" time="{duration}">
<failure type="FAIL">
MessageTests.cpp:<line number>
Message.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="FAIL_CHECK does not abort the test" time="{duration}">
<failure type="FAIL_CHECK">
This is a failure
MessageTests.cpp:<line number>
Message.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Factorials are computed" time="{duration}"/>
@ -285,44 +285,44 @@ MessageTests.cpp:<line number>
<failure message="2 == 1" type="REQUIRE">
this message should be logged
so should this
MessageTests.cpp:<line number>
Message.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="INFO gets logged on failure, even if captured before successful assertions" time="{duration}">
<failure message="2 == 1" type="CHECK">
this message may be logged later
this message should be logged
MessageTests.cpp:<line number>
Message.tests.cpp:<line number>
</failure>
<failure message="2 == 0" type="CHECK">
this message may be logged later
this message should be logged
and this, but later
MessageTests.cpp:<line number>
Message.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="INFO is reset for each loop" time="{duration}">
<failure message="10 &lt; 10" type="REQUIRE">
current counter 10
i := 10
MessageTests.cpp:<line number>
Message.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Inequality checks that should fail" time="{duration}">
<failure message="7 != 7" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="9.1f != Approx( 9.1000003815 )" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="3.1415926535 != Approx( 3.1415926535 )" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="&quot;hello&quot; != &quot;hello&quot;" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="5 != 5" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Inequality checks that should succeed" time="{duration}"/>
@ -333,98 +333,98 @@ ConditionTests.cpp:<line number>
<testcase classname="<exe-name>.global" name="Matchers can be composed with both &amp;&amp; and ||" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Matchers can be composed with both &amp;&amp; and || - failing" time="{duration}">
<failure message="&quot;this string contains 'abc' as a substring&quot; ( ( contains: &quot;string&quot; or contains: &quot;different&quot; ) and contains: &quot;random&quot; )" type="CHECK_THAT">
MatchersTests.cpp:<line number>
Matchers.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Matchers can be negated (Not) with the ! operator" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Matchers can be negated (Not) with the ! operator - failing" time="{duration}">
<failure message="&quot;this string contains 'abc' as a substring&quot; not contains: &quot;substring&quot;" type="CHECK_THAT">
MatchersTests.cpp:<line number>
Matchers.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Mismatching exception messages failing the test" time="{duration}">
<failure message="&quot;expected exception&quot; equals: &quot;should fail&quot;" type="REQUIRE_THROWS_WITH">
ExceptionTests.cpp:<line number>
Exception.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Nice descriptive name" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Non-std exceptions can be translated" time="{duration}">
<error type="TEST_CASE">
custom exception
ExceptionTests.cpp:<line number>
Exception.tests.cpp:<line number>
</error>
</testcase>
<testcase classname="<exe-name>.global" name="Objects that evaluated in boolean contexts can be checked" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Ordering comparison checks that should fail" time="{duration}">
<failure message="7 > 7" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="7 &lt; 7" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="7 > 8" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="7 &lt; 6" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="7 &lt; 0" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="7 &lt; -1" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="7 >= 8" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="7 &lt;= 6" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="9.1f &lt; 9" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="9.1f > 10" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="9.1f > 9.2" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="&quot;hello&quot; > &quot;hello&quot;" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="&quot;hello&quot; &lt; &quot;hello&quot;" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="&quot;hello&quot; > &quot;hellp&quot;" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="&quot;hello&quot; > &quot;z&quot;" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="&quot;hello&quot; &lt; &quot;hellm&quot;" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="&quot;hello&quot; &lt; &quot;a&quot;" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="&quot;hello&quot; >= &quot;z&quot;" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
<failure message="&quot;hello&quot; &lt;= &quot;a&quot;" type="CHECK">
ConditionTests.cpp:<line number>
Condition.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Ordering comparison checks that should succeed" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Output from all sections is reported/one" time="{duration}">
<failure type="FAIL">
Message from section one
MessageTests.cpp:<line number>
Message.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Output from all sections is reported/two" time="{duration}">
<failure type="FAIL">
Message from section two
MessageTests.cpp:<line number>
Message.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Parse test names and tags/Empty test spec should have no filters" time="{duration}"/>
@ -486,18 +486,18 @@ MessageTests.cpp:<line number>
<testcase classname="<exe-name>.global" name="Process can be configured on command line/use-colour/error" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Reconstruction should be based on stringification: #914" time="{duration}">
<failure message="Hey, its truthy!" type="CHECK">
DecompositionTests.cpp:<line number>
Decomposition.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Regex string matcher" time="{duration}">
<failure message="&quot;this string contains 'abc' as a substring&quot; matches &quot;this STRING contains 'abc' as a substring&quot; case sensitively" type="CHECK_THAT">
MatchersTests.cpp:<line number>
Matchers.tests.cpp:<line number>
</failure>
<failure message="&quot;this string contains 'abc' as a substring&quot; matches &quot;contains 'abc' as a substring&quot; case sensitively" type="CHECK_THAT">
MatchersTests.cpp:<line number>
Matchers.tests.cpp:<line number>
</failure>
<failure message="&quot;this string contains 'abc' as a substring&quot; matches &quot;this string contains 'abc' as a&quot; case sensitively" type="CHECK_THAT">
MatchersTests.cpp:<line number>
Matchers.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="SUCCEED counts as a test pass" time="{duration}"/>
@ -528,10 +528,10 @@ Message from section two
</testcase>
<testcase classname="<exe-name>.global" name="StartsWith string matcher" time="{duration}">
<failure message="&quot;this string contains 'abc' as a substring&quot; starts with: &quot;This String&quot;" type="CHECK_THAT">
MatchersTests.cpp:<line number>
Matchers.tests.cpp:<line number>
</failure>
<failure message="&quot;this string contains 'abc' as a substring&quot; starts with: &quot;string&quot; (case insensitive)" type="CHECK_THAT">
MatchersTests.cpp:<line number>
Matchers.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="String matchers" time="{duration}"/>
@ -540,7 +540,7 @@ MatchersTests.cpp:<line number>
<testcase classname="<exe-name>.global" name="StringRef/From string literal/c_str() does not cause copy" time="{duration}"/>
<testcase classname="<exe-name>.global" name="StringRef/From sub-string" time="{duration}">
<failure message="false" type="REQUIRE">
StringRef.tests.cpp:<line number>
String.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="StringRef/Substrings/zero-based substring" time="{duration}"/>
@ -567,7 +567,7 @@ StringRef.tests.cpp:<line number>
$a = 20;
}
&quot;" type="CHECK">
MiscTests.cpp:<line number>
Misc.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Tag alias can be registered against tag patterns/The same tag alias can only be registered once" time="{duration}"/>
@ -596,7 +596,7 @@ MiscTests.cpp:<line number>
<testcase classname="<exe-name>.global" name="Unexpected exceptions can be translated" time="{duration}">
<error type="TEST_CASE">
3.14
ExceptionTests.cpp:<line number>
Exception.tests.cpp:<line number>
</error>
</testcase>
<testcase classname="<exe-name>.global" name="Use a custom approx" time="{duration}"/>
@ -607,63 +607,63 @@ ExceptionTests.cpp:<line number>
<testcase classname="<exe-name>.global" name="Vector matchers/Equals" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Vector matchers that fail/Contains (element)" time="{duration}">
<failure message="{ 1, 2, 3 } Contains: -1" type="CHECK_THAT">
MatchersTests.cpp:<line number>
Matchers.tests.cpp:<line number>
</failure>
<failure message="{ } Contains: 1" type="CHECK_THAT">
MatchersTests.cpp:<line number>
Matchers.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Vector matchers that fail/Contains (vector)" time="{duration}">
<failure message="{ } Contains: { 1, 2, 3 }" type="CHECK_THAT">
MatchersTests.cpp:<line number>
Matchers.tests.cpp:<line number>
</failure>
<failure message="{ 1, 2, 3 } Contains: { 1, 2, 4 }" type="CHECK_THAT">
MatchersTests.cpp:<line number>
Matchers.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Vector matchers that fail/Equals" time="{duration}">
<failure message="{ 1, 2, 3 } Equals: { 1, 2 }" type="CHECK_THAT">
MatchersTests.cpp:<line number>
Matchers.tests.cpp:<line number>
</failure>
<failure message="{ 1, 2 } Equals: { 1, 2, 3 }" type="CHECK_THAT">
MatchersTests.cpp:<line number>
Matchers.tests.cpp:<line number>
</failure>
<failure message="{ } Equals: { 1, 2, 3 }" type="CHECK_THAT">
MatchersTests.cpp:<line number>
Matchers.tests.cpp:<line number>
</failure>
<failure message="{ 1, 2, 3 } Equals: { }" type="CHECK_THAT">
MatchersTests.cpp:<line number>
Matchers.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="When checked exceptions are thrown they can be expected or unexpected" time="{duration}"/>
<testcase classname="<exe-name>.global" name="When unchecked exceptions are thrown directly they are always failures" time="{duration}">
<error type="TEST_CASE">
unexpected exception
ExceptionTests.cpp:<line number>
Exception.tests.cpp:<line number>
</error>
</testcase>
<testcase classname="<exe-name>.global" name="When unchecked exceptions are thrown during a CHECK the test should continue" time="{duration}">
<error message="thisThrows() == 0" type="CHECK">
expected exception
ExceptionTests.cpp:<line number>
Exception.tests.cpp:<line number>
</error>
</testcase>
<testcase classname="<exe-name>.global" name="When unchecked exceptions are thrown during a REQUIRE the test should abort fail" time="{duration}">
<error message="thisThrows() == 0" type="REQUIRE">
expected exception
ExceptionTests.cpp:<line number>
Exception.tests.cpp:<line number>
</error>
</testcase>
<testcase classname="<exe-name>.global" name="When unchecked exceptions are thrown from functions they are always failures" time="{duration}">
<error message="thisThrows() == 0" type="CHECK">
expected exception
ExceptionTests.cpp:<line number>
Exception.tests.cpp:<line number>
</error>
</testcase>
<testcase classname="<exe-name>.global" name="When unchecked exceptions are thrown from sections they are always failures/section name" time="{duration}">
<error type="TEST_CASE">
unexpected exception
ExceptionTests.cpp:<line number>
Exception.tests.cpp:<line number>
</error>
</testcase>
<testcase classname="<exe-name>.global" name="Where the LHS is not a simple value" time="{duration}"/>
@ -685,19 +685,19 @@ ExceptionTests.cpp:<line number>
<testcase classname="<exe-name>.global" name="checkedElse" time="{duration}"/>
<testcase classname="<exe-name>.global" name="checkedElse, failing" time="{duration}">
<failure message="false" type="CHECKED_ELSE">
MiscTests.cpp:<line number>
Misc.tests.cpp:<line number>
</failure>
<failure message="false" type="REQUIRE">
MiscTests.cpp:<line number>
Misc.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="checkedIf" time="{duration}"/>
<testcase classname="<exe-name>.global" name="checkedIf, failing" time="{duration}">
<failure message="false" type="CHECKED_IF">
MiscTests.cpp:<line number>
Misc.tests.cpp:<line number>
</failure>
<failure message="false" type="REQUIRE">
MiscTests.cpp:<line number>
Misc.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="comparisons between const int variables" time="{duration}"/>
@ -708,44 +708,44 @@ MiscTests.cpp:<line number>
<testcase classname="<exe-name>.global" name="just failure" time="{duration}">
<failure type="FAIL">
Previous info should not be seen
MessageTests.cpp:<line number>
Message.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="long long" time="{duration}"/>
<testcase classname="<exe-name>.global" name="looped SECTION tests/s1" time="{duration}">
<failure message="0 > 1" type="CHECK">
MiscTests.cpp:<line number>
Misc.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="looped tests" time="{duration}">
<failure message="1 == 0" type="CHECK">
Testing if fib[0] (1) is even
MiscTests.cpp:<line number>
Misc.tests.cpp:<line number>
</failure>
<failure message="1 == 0" type="CHECK">
Testing if fib[1] (1) is even
MiscTests.cpp:<line number>
Misc.tests.cpp:<line number>
</failure>
<failure message="1 == 0" type="CHECK">
Testing if fib[3] (3) is even
MiscTests.cpp:<line number>
Misc.tests.cpp:<line number>
</failure>
<failure message="1 == 0" type="CHECK">
Testing if fib[4] (5) is even
MiscTests.cpp:<line number>
Misc.tests.cpp:<line number>
</failure>
<failure message="1 == 0" type="CHECK">
Testing if fib[6] (13) is even
MiscTests.cpp:<line number>
Misc.tests.cpp:<line number>
</failure>
<failure message="1 == 0" type="CHECK">
Testing if fib[7] (21) is even
MiscTests.cpp:<line number>
Misc.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="more nested SECTION tests/s2/s1" time="{duration}">
<failure message="1 == 2" type="REQUIRE">
MiscTests.cpp:<line number>
Misc.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="more nested SECTION tests/s1/s3" time="{duration}"/>
@ -771,14 +771,14 @@ MiscTests.cpp:<line number>
<testcase classname="<exe-name>.global" name="send a single char to INFO" time="{duration}">
<failure message="false" type="REQUIRE">
3
MiscTests.cpp:<line number>
Misc.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="sends information to INFO" time="{duration}">
<failure message="false" type="REQUIRE">
hi
i := 7
MessageTests.cpp:<line number>
Message.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="std::pair&lt;int,const std::string> -> toString" time="{duration}"/>
@ -786,7 +786,7 @@ MessageTests.cpp:<line number>
<testcase classname="<exe-name>.global" name="std::vector&lt;std::pair&lt;std::string,int> > -> toString" time="{duration}"/>
<testcase classname="<exe-name>.global" name="string literals of different sizes can be compared" time="{duration}">
<failure message="&quot;first&quot; == &quot;second&quot;" type="REQUIRE">
TrickyTests.cpp:<line number>
Tricky.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="stringify( has_maker )" time="{duration}"/>
@ -800,10 +800,10 @@ TrickyTests.cpp:<line number>
<testcase classname="<exe-name>.global" name="toString(enum class w/operator&lt;&lt;)" time="{duration}"/>
<testcase classname="<exe-name>.global" name="toString(enum class)" time="{duration}">
<failure message="&quot;{?}&quot; == &quot;0&quot;" type="CHECK">
EnumToString.cpp:<line number>
EnumToString.tests.cpp:<line number>
</failure>
<failure message="&quot;{?}&quot; == &quot;1&quot;" type="CHECK">
EnumToString.cpp:<line number>
EnumToString.tests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="toString(enum w/operator&lt;&lt;)" time="{duration}"/>

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,8 @@
#include "catch.hpp"
#include "internal/catch_test_spec_parser.h"
#include "internal/catch_config.hpp"
#include "internal/catch_commandline.h"
#ifdef __clang__
# pragma clang diagnostic ignored "-Wc++98-compat"
@ -262,3 +264,194 @@ TEST_CASE( "Parse test names and tags" ) {
}
}
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);
SECTION("empty args don't cause a crash") {
auto result = cli.parse({""});
CHECK(result);
CHECK(config.processName == "");
}
SECTION("default - no arguments") {
auto result = cli.parse({"test"});
CHECK(result);
CHECK(config.processName == "test");
CHECK(config.shouldDebugBreak == false);
CHECK(config.abortAfter == -1);
CHECK(config.noThrow == false);
CHECK(config.reporterNames.empty());
}
SECTION("test lists") {
SECTION("1 test", "Specify one test case using") {
auto result = cli.parse({"test", "test1"});
CHECK(result);
Catch::Config cfg(config);
REQUIRE(cfg.testSpec().matches(fakeTestCase("notIncluded")) == false);
REQUIRE(cfg.testSpec().matches(fakeTestCase("test1")));
}
SECTION("Specify one test case exclusion using exclude:") {
auto result = cli.parse({"test", "exclude:test1"});
CHECK(result);
Catch::Config cfg(config);
REQUIRE(cfg.testSpec().matches(fakeTestCase("test1")) == false);
REQUIRE(cfg.testSpec().matches(fakeTestCase("alwaysIncluded")));
}
SECTION("Specify one test case exclusion using ~") {
auto result = cli.parse({"test", "~test1"});
CHECK(result);
Catch::Config cfg(config);
REQUIRE(cfg.testSpec().matches(fakeTestCase("test1")) == false);
REQUIRE(cfg.testSpec().matches(fakeTestCase("alwaysIncluded")));
}
}
SECTION("reporter") {
SECTION("-r/console") {
CHECK(cli.parse({"test", "-r", "console"}));
REQUIRE(config.reporterNames[0] == "console");
}
SECTION("-r/xml") {
CHECK(cli.parse({"test", "-r", "xml"}));
REQUIRE(config.reporterNames[0] == "xml");
}
SECTION("-r xml and junit") {
CHECK(cli.parse({"test", "-r", "xml", "-r", "junit"}));
REQUIRE(config.reporterNames.size() == 2);
REQUIRE(config.reporterNames[0] == "xml");
REQUIRE(config.reporterNames[1] == "junit");
}
SECTION("--reporter/junit") {
CHECK(cli.parse({"test", "--reporter", "junit"}));
REQUIRE(config.reporterNames[0] == "junit");
}
}
SECTION("debugger") {
SECTION("-b") {
CHECK(cli.parse({"test", "-b"}));
REQUIRE(config.shouldDebugBreak == true);
}
SECTION("--break") {
CHECK(cli.parse({"test", "--break"}));
REQUIRE(config.shouldDebugBreak);
}
}
SECTION("abort") {
SECTION("-a aborts after first failure") {
CHECK(cli.parse({"test", "-a"}));
REQUIRE(config.abortAfter == 1);
}
SECTION("-x 2 aborts after two failures") {
CHECK(cli.parse({"test", "-x", "2"}));
REQUIRE(config.abortAfter == 2);
}
SECTION("-x must be numeric") {
auto result = cli.parse({"test", "-x", "oops"});
CHECK(!result);
#ifndef CATCH_CONFIG_DISABLE_MATCHERS
REQUIRE_THAT(result.errorMessage(), Contains("convert") && Contains("oops"));
#endif
}
}
SECTION("nothrow") {
SECTION("-e") {
CHECK(cli.parse({"test", "-e"}));
REQUIRE(config.noThrow);
}
SECTION("--nothrow") {
CHECK(cli.parse({"test", "--nothrow"}));
REQUIRE(config.noThrow);
}
}
SECTION("output filename") {
SECTION("-o filename") {
CHECK(cli.parse({"test", "-o", "filename.ext"}));
REQUIRE(config.outputFilename == "filename.ext");
}
SECTION("--out") {
CHECK(cli.parse({"test", "--out", "filename.ext"}));
REQUIRE(config.outputFilename == "filename.ext");
}
}
SECTION("combinations") {
SECTION("Single character flags can be combined") {
CHECK(cli.parse({"test", "-abe"}));
CHECK(config.abortAfter == 1);
CHECK(config.shouldDebugBreak);
CHECK(config.noThrow == true);
}
}
SECTION( "use-colour") {
using Catch::UseColour;
SECTION( "without option" ) {
CHECK(cli.parse({"test"}));
REQUIRE( config.useColour == UseColour::Auto );
}
SECTION( "auto" ) {
CHECK(cli.parse({"test", "--use-colour", "auto"}));
REQUIRE( config.useColour == UseColour::Auto );
}
SECTION( "yes" ) {
CHECK(cli.parse({"test", "--use-colour", "yes"}));
REQUIRE( config.useColour == UseColour::Yes );
}
SECTION( "no" ) {
CHECK(cli.parse({"test", "--use-colour", "no"}));
REQUIRE( config.useColour == UseColour::No );
}
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
}
}
}

View File

@ -165,3 +165,36 @@ TEST_CASE( "StringRef", "[Strings]" ) {
}
}
}
TEST_CASE( "replaceInPlace" ) {
std::string letters = "abcdefcg";
SECTION( "replace single char" ) {
CHECK( Catch::replaceInPlace( letters, "b", "z" ) );
CHECK( letters == "azcdefcg" );
}
SECTION( "replace two chars" ) {
CHECK( Catch::replaceInPlace( letters, "c", "z" ) );
CHECK( letters == "abzdefzg" );
}
SECTION( "replace first char" ) {
CHECK( Catch::replaceInPlace( letters, "a", "z" ) );
CHECK( letters == "zbcdefcg" );
}
SECTION( "replace last char" ) {
CHECK( Catch::replaceInPlace( letters, "g", "z" ) );
CHECK( letters == "abcdefcz" );
}
SECTION( "replace all chars" ) {
CHECK( Catch::replaceInPlace( letters, letters, "replaced" ) );
CHECK( letters == "replaced" );
}
SECTION( "replace no chars" ) {
CHECK_FALSE( Catch::replaceInPlace( letters, "x", "z" ) );
CHECK( letters == letters );
}
SECTION( "escape '" ) {
std::string s = "didn't";
CHECK( Catch::replaceInPlace( s, "'", "|'" ) );
CHECK( s == "didn|'t" );
}
}

View File

@ -1,268 +0,0 @@
/*
* Created by Phil on 22/10/2010.
* Copyright 2010 Two Blue Cubes Ltd
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
#include "reporters/catch_reporter_teamcity.hpp"
#include "reporters/catch_reporter_tap.hpp"
#include "reporters/catch_reporter_automake.hpp"
// Some example tag aliases
CATCH_REGISTER_TAG_ALIAS( "[@nhf]", "[failing]~[.]" )
CATCH_REGISTER_TAG_ALIAS( "[@tricky]", "[tricky]~[.]" )
#ifdef __clang__
# pragma clang diagnostic ignored "-Wpadded"
# pragma clang diagnostic ignored "-Wweak-vtables"
# pragma clang diagnostic ignored "-Wc++98-compat"
#endif
struct TestListener : Catch::TestEventListenerBase {
using TestEventListenerBase::TestEventListenerBase; // inherit constructor
};
CATCH_REGISTER_LISTENER( TestListener );
inline Catch::TestCase fakeTestCase( const char* name, const char* desc = "" ){ return Catch::makeTestCase( nullptr, "", name, desc, CATCH_INTERNAL_LINEINFO ); }
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);
SECTION("empty args don't cause a crash") {
auto result = cli.parse({""});
CHECK(result);
CHECK(config.processName == "");
}
SECTION("default - no arguments") {
auto result = cli.parse({"test"});
CHECK(result);
CHECK(config.processName == "test");
CHECK(config.shouldDebugBreak == false);
CHECK(config.abortAfter == -1);
CHECK(config.noThrow == false);
CHECK(config.reporterNames.empty());
}
SECTION("test lists") {
SECTION("1 test", "Specify one test case using") {
auto result = cli.parse({"test", "test1"});
CHECK(result);
Catch::Config cfg(config);
REQUIRE(cfg.testSpec().matches(fakeTestCase("notIncluded")) == false);
REQUIRE(cfg.testSpec().matches(fakeTestCase("test1")));
}
SECTION("Specify one test case exclusion using exclude:") {
auto result = cli.parse({"test", "exclude:test1"});
CHECK(result);
Catch::Config cfg(config);
REQUIRE(cfg.testSpec().matches(fakeTestCase("test1")) == false);
REQUIRE(cfg.testSpec().matches(fakeTestCase("alwaysIncluded")));
}
SECTION("Specify one test case exclusion using ~") {
auto result = cli.parse({"test", "~test1"});
CHECK(result);
Catch::Config cfg(config);
REQUIRE(cfg.testSpec().matches(fakeTestCase("test1")) == false);
REQUIRE(cfg.testSpec().matches(fakeTestCase("alwaysIncluded")));
}
}
SECTION("reporter") {
SECTION("-r/console") {
CHECK(cli.parse({"test", "-r", "console"}));
REQUIRE(config.reporterNames[0] == "console");
}
SECTION("-r/xml") {
CHECK(cli.parse({"test", "-r", "xml"}));
REQUIRE(config.reporterNames[0] == "xml");
}
SECTION("-r xml and junit") {
CHECK(cli.parse({"test", "-r", "xml", "-r", "junit"}));
REQUIRE(config.reporterNames.size() == 2);
REQUIRE(config.reporterNames[0] == "xml");
REQUIRE(config.reporterNames[1] == "junit");
}
SECTION("--reporter/junit") {
CHECK(cli.parse({"test", "--reporter", "junit"}));
REQUIRE(config.reporterNames[0] == "junit");
}
}
SECTION("debugger") {
SECTION("-b") {
CHECK(cli.parse({"test", "-b"}));
REQUIRE(config.shouldDebugBreak == true);
}
SECTION("--break") {
CHECK(cli.parse({"test", "--break"}));
REQUIRE(config.shouldDebugBreak);
}
}
SECTION("abort") {
SECTION("-a aborts after first failure") {
CHECK(cli.parse({"test", "-a"}));
REQUIRE(config.abortAfter == 1);
}
SECTION("-x 2 aborts after two failures") {
CHECK(cli.parse({"test", "-x", "2"}));
REQUIRE(config.abortAfter == 2);
}
SECTION("-x must be numeric") {
auto result = cli.parse({"test", "-x", "oops"});
CHECK(!result);
#ifndef CATCH_CONFIG_DISABLE_MATCHERS
REQUIRE_THAT(result.errorMessage(), Contains("convert") && Contains("oops"));
#endif
}
}
SECTION("nothrow") {
SECTION("-e") {
CHECK(cli.parse({"test", "-e"}));
REQUIRE(config.noThrow);
}
SECTION("--nothrow") {
CHECK(cli.parse({"test", "--nothrow"}));
REQUIRE(config.noThrow);
}
}
SECTION("output filename") {
SECTION("-o filename") {
CHECK(cli.parse({"test", "-o", "filename.ext"}));
REQUIRE(config.outputFilename == "filename.ext");
}
SECTION("--out") {
CHECK(cli.parse({"test", "--out", "filename.ext"}));
REQUIRE(config.outputFilename == "filename.ext");
}
}
SECTION("combinations") {
SECTION("Single character flags can be combined") {
CHECK(cli.parse({"test", "-abe"}));
CHECK(config.abortAfter == 1);
CHECK(config.shouldDebugBreak);
CHECK(config.noThrow == true);
}
}
SECTION( "use-colour") {
using Catch::UseColour;
SECTION( "without option" ) {
CHECK(cli.parse({"test"}));
REQUIRE( config.useColour == UseColour::Auto );
}
SECTION( "auto" ) {
CHECK(cli.parse({"test", "--use-colour", "auto"}));
REQUIRE( config.useColour == UseColour::Auto );
}
SECTION( "yes" ) {
CHECK(cli.parse({"test", "--use-colour", "yes"}));
REQUIRE( config.useColour == UseColour::Yes );
}
SECTION( "no" ) {
CHECK(cli.parse({"test", "--use-colour", "no"}));
REQUIRE( config.useColour == UseColour::No );
}
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
}
}
}
TEST_CASE( "replaceInPlace" ) {
std::string letters = "abcdefcg";
SECTION( "replace single char" ) {
CHECK( Catch::replaceInPlace( letters, "b", "z" ) );
CHECK( letters == "azcdefcg" );
}
SECTION( "replace two chars" ) {
CHECK( Catch::replaceInPlace( letters, "c", "z" ) );
CHECK( letters == "abzdefzg" );
}
SECTION( "replace first char" ) {
CHECK( Catch::replaceInPlace( letters, "a", "z" ) );
CHECK( letters == "zbcdefcg" );
}
SECTION( "replace last char" ) {
CHECK( Catch::replaceInPlace( letters, "g", "z" ) );
CHECK( letters == "abcdefcz" );
}
SECTION( "replace all chars" ) {
CHECK( Catch::replaceInPlace( letters, letters, "replaced" ) );
CHECK( letters == "replaced" );
}
SECTION( "replace no chars" ) {
CHECK_FALSE( Catch::replaceInPlace( letters, "x", "z" ) );
CHECK( letters == letters );
}
SECTION( "escape '" ) {
std::string s = "didn't";
CHECK( Catch::replaceInPlace( s, "'", "|'" ) );
CHECK( s == "didn|'t" );
}
}
inline void manuallyRegisteredTestFunction() {
SUCCEED( "was called" );
}
struct AutoTestReg {
AutoTestReg() {
REGISTER_TEST_CASE( manuallyRegisteredTestFunction, "ManuallyRegistered" );
}
};
static AutoTestReg autoTestReg;

View File

@ -0,0 +1,33 @@
/*
* Created by Phil on 22/10/2010.
* Copyright 2010 Two Blue Cubes Ltd
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
// These reporters are not included in the single include, so must be included separately in the main file
#include "reporters/catch_reporter_teamcity.hpp"
#include "reporters/catch_reporter_tap.hpp"
#include "reporters/catch_reporter_automake.hpp"
// Some example tag aliases
CATCH_REGISTER_TAG_ALIAS( "[@nhf]", "[failing]~[.]" )
CATCH_REGISTER_TAG_ALIAS( "[@tricky]", "[tricky]~[.]" )
#ifdef __clang__
# pragma clang diagnostic ignored "-Wpadded"
# pragma clang diagnostic ignored "-Wweak-vtables"
# pragma clang diagnostic ignored "-Wc++98-compat"
#endif
struct TestListener : Catch::TestEventListenerBase {
using TestEventListenerBase::TestEventListenerBase; // inherit constructor
};
CATCH_REGISTER_LISTENER( TestListener );

View File

@ -330,3 +330,13 @@ TEST_CASE( "#961 -- Dynamically created sections should all be reported", "[.]"
}
}
}
inline void manuallyRegisteredTestFunction() {
SUCCEED( "was called" );
}
struct AutoTestReg {
AutoTestReg() {
REGISTER_TEST_CASE( manuallyRegisteredTestFunction, "ManuallyRegistered" );
}
};
static AutoTestReg autoTestReg;