Merge branch 'catch2'

This commit is contained in:
Phil Nash
2017-11-03 12:05:38 +00:00
264 changed files with 25287 additions and 23762 deletions

View File

@@ -11,11 +11,11 @@
///////////////////////////////////////////////////////////////////////////////
TEST_CASE("Successful tests -- REQUIRE", "[Success]") {
const size_t sz = 1 * 1024 * 1024;
const std::size_t sz = 1 * 1024 * 1024;
std::vector<size_t> vec; vec.reserve(sz);
for (size_t i = 0; i < sz; ++i){
std::vector<std::size_t> vec; vec.reserve(sz);
for (std::size_t i = 0; i < sz; ++i){
vec.push_back(i);
REQUIRE(vec.back() == i);
}
@@ -23,11 +23,11 @@ TEST_CASE("Successful tests -- REQUIRE", "[Success]") {
///////////////////////////////////////////////////////////////////////////////
TEST_CASE("Successful tests -- CHECK", "[Success]") {
const size_t sz = 1 * 1024 * 1024;
const std::size_t sz = 1 * 1024 * 1024;
std::vector<size_t> vec; vec.reserve(sz);
for (size_t i = 0; i < sz; ++i){
std::vector<std::size_t> vec; vec.reserve(sz);
for (std::size_t i = 0; i < sz; ++i){
vec.push_back(i);
CHECK(vec.back() == i);
}
@@ -35,11 +35,11 @@ TEST_CASE("Successful tests -- CHECK", "[Success]") {
///////////////////////////////////////////////////////////////////////////////
TEST_CASE("Unsuccessful tests -- CHECK", "[Failure]") {
const size_t sz = 1024 * 1024;
const std::size_t sz = 1024 * 1024;
std::vector<size_t> vec; vec.reserve(sz);
for (size_t i = 0; i < sz; ++i){
std::vector<std::size_t> vec; vec.reserve(sz);
for (std::size_t i = 0; i < sz; ++i){
vec.push_back(i);
CHECK(vec.size() == i);
}

View File

@@ -8,6 +8,8 @@
#include "catch.hpp"
#include <cmath>
///////////////////////////////////////////////////////////////////////////////
TEST_CASE
(
@@ -25,7 +27,7 @@ TEST_CASE
REQUIRE( Approx( d ) != 1.22 );
REQUIRE( Approx( d ) != 1.24 );
REQUIRE( 0 == Approx(0) );
REQUIRE(INFINITY == Approx(INFINITY));
}
///////////////////////////////////////////////////////////////////////////////
@@ -106,7 +108,7 @@ TEST_CASE
REQUIRE( 1.0f == Approx( 1 ) );
REQUIRE( 0 == Approx( dZero) );
REQUIRE( 0 == Approx( dSmall ).epsilon( 0.001 ) );
REQUIRE( 0 == Approx( dSmall ).margin( 0.001 ) );
REQUIRE( 1.234f == Approx( dMedium ) );
REQUIRE( dMedium == Approx( 1.234f ) );
}
@@ -120,7 +122,7 @@ TEST_CASE
{
double d = 1.23;
Approx approx = Approx::custom().epsilon( 0.005 );
Approx approx = Approx::custom().epsilon( 0.01 );
REQUIRE( d == approx( 1.23 ) );
REQUIRE( d == approx( 1.22 ) );
@@ -164,9 +166,32 @@ TEST_CASE("Approx with exactly-representable margin", "[Approx]") {
CHECK( 245.5f == Approx(245.25f).margin(0.25f) );
}
////////////////////////////////////////////////////////////////////////////////
TEST_CASE("Approx setters validate their arguments", "[Approx]") {
REQUIRE_NOTHROW(Approx(0).margin(0));
REQUIRE_NOTHROW(Approx(0).margin(1234656));
REQUIRE_THROWS_AS(Approx(0).margin(-2), std::domain_error);
REQUIRE_NOTHROW(Approx(0).epsilon(0));
REQUIRE_NOTHROW(Approx(0).epsilon(1));
REQUIRE_THROWS_AS(Approx(0).epsilon(-0.001), std::domain_error);
REQUIRE_THROWS_AS(Approx(0).epsilon(1.0001), std::domain_error);
}
TEST_CASE("Default scale is invisible to comparison", "[Approx]") {
REQUIRE(101.000001 != Approx(100).epsilon(0.01));
REQUIRE(std::pow(10, -5) != Approx(std::pow(10, -7)));
}
TEST_CASE("Epsilon only applies to Approx's value", "[Approx]") {
REQUIRE(101.01 != Approx(100).epsilon(0.01));
}
TEST_CASE("Assorted miscellaneous tests", "[Approx]") {
REQUIRE(INFINITY == Approx(INFINITY));
}
#if defined(CATCH_CONFIG_CPP11_TYPE_TRAITS)
class StrongDoubleTypedef
{
double d_ = 0.0;
@@ -180,11 +205,7 @@ inline std::ostream& operator<<( std::ostream& os, StrongDoubleTypedef td ) {
return os << "StrongDoubleTypedef(" << static_cast<double>(td) << ")";
}
TEST_CASE
(
"Comparison with explicitly convertible types",
"[Approx][c++11]"
)
TEST_CASE( "Comparison with explicitly convertible types", "[Approx]" )
{
StrongDoubleTypedef td(10.0);
@@ -205,6 +226,3 @@ TEST_CASE
REQUIRE(Approx(11.0) >= td);
}
#endif
////////////////////////////////////////////////////////////////////////////////

View File

@@ -274,6 +274,55 @@ MatchersTests.cpp:<line number>: FAILED:
with expansion:
"this string contains 'abc' as a substring" equals: "something else"
-------------------------------------------------------------------------------
Exception matchers that fail
No exception
-------------------------------------------------------------------------------
MatchersTests.cpp:<line number>
...............................................................................
MatchersTests.cpp:<line number>: FAILED:
CHECK_THROWS_MATCHES( doesNotThrow(), SpecialException, ExceptionMatcher{ 1 } )
because no exception was thrown where one was expected:
MatchersTests.cpp:<line number>: FAILED:
REQUIRE_THROWS_MATCHES( doesNotThrow(), SpecialException, ExceptionMatcher{ 1 } )
because no exception was thrown where one was expected:
-------------------------------------------------------------------------------
Exception matchers that fail
Type mismatch
-------------------------------------------------------------------------------
MatchersTests.cpp:<line number>
...............................................................................
MatchersTests.cpp:<line number>: FAILED:
CHECK_THROWS_MATCHES( throwsAsInt(1), SpecialException, ExceptionMatcher{ 1 } )
due to unexpected exception with message:
Unknown exception
MatchersTests.cpp:<line number>: FAILED:
REQUIRE_THROWS_MATCHES( throwsAsInt(1), SpecialException, ExceptionMatcher{ 1 } )
due to unexpected exception with message:
Unknown exception
-------------------------------------------------------------------------------
Exception matchers that fail
Contents are wrong
-------------------------------------------------------------------------------
MatchersTests.cpp:<line number>
...............................................................................
MatchersTests.cpp:<line number>: FAILED:
CHECK_THROWS_MATCHES( throws(3), SpecialException, ExceptionMatcher{ 1 } )
with expansion:
{?} special exception has value of 1
MatchersTests.cpp:<line number>: FAILED:
REQUIRE_THROWS_MATCHES( throws(4), SpecialException, ExceptionMatcher{ 1 } )
with expansion:
{?} special exception has value of 1
-------------------------------------------------------------------------------
Expected exceptions that don't throw or unexpected exceptions fail the test
-------------------------------------------------------------------------------
@@ -373,6 +422,20 @@ with messages:
this message should be logged
and this, but later
-------------------------------------------------------------------------------
INFO is reset for each loop
-------------------------------------------------------------------------------
MessageTests.cpp:<line number>
...............................................................................
MessageTests.cpp:<line number>: FAILED:
REQUIRE( i < 10 )
with expansion:
10 < 10
with messages:
current counter 10
i := 10
-------------------------------------------------------------------------------
Inequality checks that should fail
-------------------------------------------------------------------------------
@@ -436,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
@@ -581,20 +644,6 @@ MessageTests.cpp:<line number>: FAILED:
explicitly with message:
Message from section two
-------------------------------------------------------------------------------
Pointers can be converted to strings
-------------------------------------------------------------------------------
MessageTests.cpp:<line number>
...............................................................................
MessageTests.cpp:<line number>:
warning:
actual address of p: 0x<hex digits>
MessageTests.cpp:<line number>:
warning:
toString(p): 0x<hex digits>
-------------------------------------------------------------------------------
Reconstruction should be based on stringification: #914
-------------------------------------------------------------------------------
@@ -606,25 +655,8 @@ DecompositionTests.cpp:<line number>: FAILED:
with expansion:
Hey, its truthy!
-------------------------------------------------------------------------------
SCOPED_INFO is reset for each loop
-------------------------------------------------------------------------------
MessageTests.cpp:<line number>
...............................................................................
MessageTests.cpp:<line number>: FAILED:
REQUIRE( i < 10 )
with expansion:
10 < 10
with messages:
current counter 10
i := 10
A string sent directly to stdout
A string sent directly to stderr
Write to std::cerr
Write to std::clog
Interleaved writes to error streams
Message from section one
Message from section two
-------------------------------------------------------------------------------
@@ -638,8 +670,6 @@ MatchersTests.cpp:<line number>: FAILED:
with expansion:
"this string contains 'abc' as a substring" starts with: "string"
hello
hello
-------------------------------------------------------------------------------
Tabs and newlines show in output
-------------------------------------------------------------------------------
@@ -838,7 +868,8 @@ MiscTests.cpp:<line number>: FAILED:
with expansion:
false
spanner-------------------------------------------------------------------------------
loose text artifact
-------------------------------------------------------------------------------
just failure
-------------------------------------------------------------------------------
MessageTests.cpp:<line number>
@@ -955,7 +986,23 @@ TrickyTests.cpp:<line number>: FAILED:
with expansion:
"first" == "second"
===============================================================================
test cases: 171 | 122 passed | 45 failed | 4 failed as expected
assertions: 980 | 871 passed | 88 failed | 21 failed as expected
-------------------------------------------------------------------------------
toString(enum class)
-------------------------------------------------------------------------------
EnumToString.cpp:<line number>
...............................................................................
EnumToString.cpp:<line number>: FAILED:
CHECK( ::Catch::Detail::stringify(e0) == "0" )
with expansion:
"{?}" == "0"
EnumToString.cpp:<line number>: FAILED:
CHECK( ::Catch::Detail::stringify(e1) == "1" )
with expansion:
"{?}" == "1"
===============================================================================
test cases: 185 | 134 passed | 47 failed | 4 failed as expected
assertions: 904 | 787 passed | 96 failed | 21 failed as expected

File diff suppressed because it is too large Load Diff

View File

@@ -14,6 +14,25 @@ PASSED:
with message:
yay
-------------------------------------------------------------------------------
#1005: Comparing pointer to int and long (NULL can be either on various
systems)
-------------------------------------------------------------------------------
DecompositionTests.cpp:<line number>
...............................................................................
DecompositionTests.cpp:<line number>:
PASSED:
REQUIRE( fptr == 0 )
with expansion:
0 == 0
DecompositionTests.cpp:<line number>:
PASSED:
REQUIRE( fptr == 0l )
with expansion:
0 == 0
-------------------------------------------------------------------------------
#748 - captures with unexpected exceptions
outside assertions
@@ -88,7 +107,7 @@ PASSED:
CompilationTests.cpp:<line number>:
PASSED:
CHECK_THROWS_AS( throws_int(true), const int& )
CHECK_THROWS_AS( throws_int(true), int )
CompilationTests.cpp:<line number>:
PASSED:
@@ -123,6 +142,20 @@ PASSED:
with expansion:
1 == 1
-------------------------------------------------------------------------------
#872
-------------------------------------------------------------------------------
CompilationTests.cpp:<line number>
...............................................................................
CompilationTests.cpp:<line number>:
PASSED:
REQUIRE( x == 4 )
with expansion:
{?} == 4
with message:
dummy := 0
-------------------------------------------------------------------------------
#961 -- Dynamically created sections should all be reported
Looped section 0
@@ -206,6 +239,6 @@ with expansion:
!true
===============================================================================
test cases: 7 | 4 passed | 1 failed | 2 failed as expected
assertions: 23 | 16 passed | 4 failed | 3 failed as expected
test cases: 9 | 6 passed | 1 failed | 2 failed as expected
assertions: 26 | 19 passed | 4 failed | 3 failed as expected

View File

@@ -1,35 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuitesspanner>
<testsuite name="<exe-name>" errors="13" failures="81" tests="986" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<testcase classname="global" name="# A test name that starts with a #" time="{duration}"/>
<testcase classname="#748 - captures with unexpected exceptions" name="outside assertions" time="{duration}">
<testsuitesloose text artifact
>
<testsuite name="<exe-name>" errors="15" failures="85" tests="904" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<testcase classname="<exe-name>.global" name="# A test name that starts with a #" time="{duration}"/>
<testcase classname="<exe-name>.global" name="#1005: Comparing pointer to int and long (NULL can be either on various systems)" time="{duration}"/>
<testcase classname="<exe-name>.global" name="#748 - captures with unexpected exceptions/outside assertions" time="{duration}">
<error type="TEST_CASE">
expected exception
answer := 42
ExceptionTests.cpp:<line number>
</error>
</testcase>
<testcase classname="#748 - captures with unexpected exceptions" name="inside REQUIRE_NOTHROW" time="{duration}">
<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>
</error>
</testcase>
<testcase classname="#748 - captures with unexpected exceptions" name="inside REQUIRE_THROWS" time="{duration}"/>
<testcase classname="global" name="#809" time="{duration}"/>
<testcase classname="global" name="#833" time="{duration}"/>
<testcase classname="global" name="#835 -- errno should not be touched by Catch" time="{duration}">
<testcase classname="<exe-name>.global" name="#748 - captures with unexpected exceptions/inside REQUIRE_THROWS" time="{duration}"/>
<testcase classname="<exe-name>.global" name="#809" time="{duration}"/>
<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>
</failure>
</testcase>
<testcase classname="#961 -- Dynamically created sections should all be reported" name="Looped section 0" time="{duration}"/>
<testcase classname="#961 -- Dynamically created sections should all be reported" name="Looped section 1" time="{duration}"/>
<testcase classname="#961 -- Dynamically created sections should all be reported" name="Looped section 2" time="{duration}"/>
<testcase classname="#961 -- Dynamically created sections should all be reported" name="Looped section 3" time="{duration}"/>
<testcase classname="#961 -- Dynamically created sections should all be reported" name="Looped section 4" time="{duration}"/>
<testcase classname="global" name="'Not' checks that should fail" time="{duration}">
<testcase classname="<exe-name>.global" name="#872" time="{duration}"/>
<testcase classname="<exe-name>.global" name="#961 -- Dynamically created sections should all be reported/Looped section 0" time="{duration}"/>
<testcase classname="<exe-name>.global" name="#961 -- Dynamically created sections should all be reported/Looped section 1" time="{duration}"/>
<testcase classname="<exe-name>.global" name="#961 -- Dynamically created sections should all be reported/Looped section 2" time="{duration}"/>
<testcase classname="<exe-name>.global" name="#961 -- Dynamically created sections should all be reported/Looped section 3" time="{duration}"/>
<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>
</failure>
@@ -55,32 +58,32 @@ ConditionTests.cpp:<line number>
ConditionTests.cpp:<line number>
</failure>
</testcase>
<testcase classname="global" name="'Not' checks that should succeed" time="{duration}"/>
<testcase classname="(unimplemented) static bools can be evaluated" name="compare to true" time="{duration}"/>
<testcase classname="(unimplemented) static bools can be evaluated" name="compare to false" time="{duration}"/>
<testcase classname="(unimplemented) static bools can be evaluated" name="negation" time="{duration}"/>
<testcase classname="(unimplemented) static bools can be evaluated" name="double negation" time="{duration}"/>
<testcase classname="(unimplemented) static bools can be evaluated" name="direct" time="{duration}"/>
<testcase classname="TestClass" name="A METHOD_AS_TEST_CASE based test run that fails" time="{duration}">
<testcase classname="<exe-name>.global" name="'Not' checks that should succeed" time="{duration}"/>
<testcase classname="<exe-name>.global" name="(unimplemented) static bools can be evaluated/compare to true" time="{duration}"/>
<testcase classname="<exe-name>.global" name="(unimplemented) static bools can be evaluated/compare to false" time="{duration}"/>
<testcase classname="<exe-name>.global" name="(unimplemented) static bools can be evaluated/negation" time="{duration}"/>
<testcase classname="<exe-name>.global" name="(unimplemented) static bools can be evaluated/double negation" time="{duration}"/>
<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>
</failure>
</testcase>
<testcase classname="TestClass" name="A METHOD_AS_TEST_CASE based test run that succeeds" time="{duration}"/>
<testcase classname="Fixture" name="A TEST_CASE_METHOD based test run that fails" time="{duration}">
<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>
</failure>
</testcase>
<testcase classname="Fixture" name="A TEST_CASE_METHOD based test run that succeeds" time="{duration}"/>
<testcase classname="A couple of nested sections followed by a failure" name="root" time="{duration}">
<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>
</failure>
</testcase>
<testcase classname="A couple of nested sections followed by a failure" name="Outer/Inner" time="{duration}"/>
<testcase classname="global" name="A failing expression with a non streamable type is still captured" time="{duration}">
<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>
</failure>
@@ -88,67 +91,70 @@ TrickyTests.cpp:<line number>
TrickyTests.cpp:<line number>
</failure>
</testcase>
<testcase classname="global" name="Absolute margin" time="{duration}"/>
<testcase classname="global" name="AllOf matcher" time="{duration}"/>
<testcase classname="global" name="An expression with side-effects should only be evaluated once" time="{duration}"/>
<testcase classname="global" name="An unchecked exception reports the line of the last assertion" time="{duration}">
<testcase classname="<exe-name>.global" name="Absolute margin" time="{duration}"/>
<testcase classname="<exe-name>.global" name="An expression with side-effects should only be evaluated once" time="{duration}"/>
<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>
</error>
</testcase>
<testcase classname="global" name="Anonymous test case 1" time="{duration}"/>
<testcase classname="global" name="AnyOf matcher" time="{duration}"/>
<testcase classname="global" name="Approx with exactly-representable margin" time="{duration}"/>
<testcase classname="global" name="Approximate PI" time="{duration}"/>
<testcase classname="global" name="Approximate comparisons with different epsilons" time="{duration}"/>
<testcase classname="global" name="Approximate comparisons with floats" time="{duration}"/>
<testcase classname="global" name="Approximate comparisons with ints" time="{duration}"/>
<testcase classname="global" name="Approximate comparisons with mixed numeric types" time="{duration}"/>
<testcase classname="Assertions then sections" name="root" time="{duration}"/>
<testcase classname="Assertions then sections" name="A section" time="{duration}"/>
<testcase classname="Assertions then sections" name="A section/Another section" time="{duration}"/>
<testcase classname="Assertions then sections" name="A section/Another other section" time="{duration}"/>
<testcase classname="Capture and info messages" name="Capture should stringify like assertions" time="{duration}"/>
<testcase classname="Capture and info messages" name="Info should NOT stringify the way assertions do" time="{duration}"/>
<testcase classname="Character pretty printing" name="Specifically escaped" time="{duration}"/>
<testcase classname="Character pretty printing" name="General chars" time="{duration}"/>
<testcase classname="Character pretty printing" name="Low ASCII" time="{duration}"/>
<testcase classname="global" name="Comparing function pointers" time="{duration}"/>
<testcase classname="global" name="Comparing member function pointers" time="{duration}"/>
<testcase classname="global" name="Comparisons between ints where one side is computed" time="{duration}"/>
<testcase classname="global" name="Comparisons between unsigned ints and negative signed ints match c++ standard behaviour" time="{duration}"/>
<testcase classname="global" name="Comparisons with int literals don't warn when mixing signed/ unsigned" time="{duration}"/>
<testcase classname="global" name="Contains string matcher" time="{duration}">
<testcase classname="<exe-name>.global" name="Anonymous test case 1" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Approx setters validate their arguments" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Approx with exactly-representable margin" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Approximate PI" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Approximate comparisons with different epsilons" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Approximate comparisons with floats" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Approximate comparisons with ints" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Approximate comparisons with mixed numeric types" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Assertions then sections" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Assertions then sections/A section" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Assertions then sections/A section/Another section" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Assertions then sections/A section/Another other section" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Assorted miscellaneous tests" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Bitfields can be captured (#1027)" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Capture and info messages/Capture should stringify like assertions" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Capture and info messages/Info should NOT stringify the way assertions do" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Character pretty printing/Specifically escaped" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Character pretty printing/General chars" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Character pretty printing/Low ASCII" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Commas in various macros are allowed" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Comparing function pointers" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Comparison with explicitly convertible types" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Comparisons between ints where one side is computed" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Comparisons between unsigned ints and negative signed ints match c++ standard behaviour" time="{duration}"/>
<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;" type="CHECK_THAT">
MatchersTests.cpp:<line number>
</failure>
</testcase>
<testcase classname="global" name="Custom exceptions can be translated when testing for nothrow" time="{duration}">
<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>
</error>
</testcase>
<testcase classname="global" name="Custom exceptions can be translated when testing for throwing as something else" time="{duration}">
<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>
</error>
</testcase>
<testcase classname="global" name="Custom std-exceptions can be custom translated" time="{duration}">
<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>
</error>
</testcase>
<testcase classname="global" name="Demonstrate that a non-const == is not used" time="{duration}"/>
<testcase classname="global" name="EndsWith string matcher" time="{duration}">
<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;this&quot;" type="CHECK_THAT">
MatchersTests.cpp:<line number>
</failure>
</testcase>
<testcase classname="global" name="Equality checks that should fail" time="{duration}">
<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>
</failure>
@@ -189,17 +195,44 @@ ConditionTests.cpp:<line number>
ConditionTests.cpp:<line number>
</failure>
</testcase>
<testcase classname="global" name="Equality checks that should succeed" time="{duration}"/>
<testcase classname="global" name="Equals" time="{duration}"/>
<testcase classname="global" name="Equals string matcher" time="{duration}">
<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;something else&quot;" type="CHECK_THAT">
MatchersTests.cpp:<line number>
</failure>
</testcase>
<testcase classname="Exception messages can be tested for" name="exact match" time="{duration}"/>
<testcase classname="Exception messages can be tested for" name="different case" time="{duration}"/>
<testcase classname="Exception messages can be tested for" name="wildcarded" time="{duration}"/>
<testcase classname="global" name="Expected exceptions that don't throw or unexpected exceptions fail the test" time="{duration}">
<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>
</failure>
<failure message="doesNotThrow(), SpecialException, ExceptionMatcher{ 1 }" type="REQUIRE_THROWS_MATCHES">
MatchersTests.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>
</error>
<error message="throwsAsInt(1), SpecialException, ExceptionMatcher{ 1 }" type="REQUIRE_THROWS_MATCHES">
Unknown exception
MatchersTests.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>
</failure>
<failure message="{?} special exception has value of 1" type="REQUIRE_THROWS_MATCHES">
MatchersTests.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="Exception matchers that succeed" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Exception messages can be tested for/exact match" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Exception messages can be tested for/different case" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Exception messages can be tested for/wildcarded" time="{duration}"/>
<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>
@@ -212,36 +245,34 @@ expected exception
ExceptionTests.cpp:<line number>
</error>
</testcase>
<testcase classname="global" name="FAIL aborts the test" time="{duration}">
<testcase classname="<exe-name>.global" name="FAIL aborts the test" time="{duration}">
<failure type="FAIL">
This is a failure
MessageTests.cpp:<line number>
</failure>
</testcase>
<testcase classname="global" name="FAIL does not require an argument" time="{duration}">
<testcase classname="<exe-name>.global" name="FAIL does not require an argument" time="{duration}">
<failure type="FAIL">
MessageTests.cpp:<line number>
</failure>
</testcase>
<testcase classname="global" name="FAIL_CHECK does not abort the test" time="{duration}">
<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>
</failure>
</testcase>
<testcase classname="global" name="Factorials are computed" time="{duration}"/>
<testcase classname="global" name="Generator over a range of pairs" time="{duration}"/>
<testcase classname="global" name="Generators over two ranges" time="{duration}"/>
<testcase classname="global" name="Greater-than inequalities with different epsilons" time="{duration}"/>
<testcase classname="global" name="INFO and WARN do not abort tests" time="{duration}"/>
<testcase classname="global" name="INFO gets logged on failure" time="{duration}">
<testcase classname="<exe-name>.global" name="Factorials are computed" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Greater-than inequalities with different epsilons" time="{duration}"/>
<testcase classname="<exe-name>.global" name="INFO and WARN do not abort tests" time="{duration}"/>
<testcase classname="<exe-name>.global" name="INFO gets logged on failure" time="{duration}">
<failure message="2 == 1" type="REQUIRE">
this message should be logged
so should this
MessageTests.cpp:<line number>
</failure>
</testcase>
<testcase classname="global" name="INFO gets logged on failure, even if captured before successful assertions" time="{duration}">
<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
@@ -254,7 +285,14 @@ and this, but later
MessageTests.cpp:<line number>
</failure>
</testcase>
<testcase classname="global" name="Inequality checks that should fail" time="{duration}">
<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>
</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>
</failure>
@@ -271,54 +309,37 @@ ConditionTests.cpp:<line number>
ConditionTests.cpp:<line number>
</failure>
</testcase>
<testcase classname="global" name="Inequality checks that should succeed" time="{duration}"/>
<testcase classname="global" name="Less-than inequalities with different epsilons" time="{duration}"/>
<testcase classname="Long strings can be wrapped" name="plain string/No wrapping" time="{duration}"/>
<testcase classname="Long strings can be wrapped" name="plain string/Wrapped once" time="{duration}"/>
<testcase classname="Long strings can be wrapped" name="plain string/Wrapped twice" time="{duration}"/>
<testcase classname="Long strings can be wrapped" name="plain string/Wrapped three times" time="{duration}"/>
<testcase classname="Long strings can be wrapped" name="plain string/Short wrap" time="{duration}"/>
<testcase classname="Long strings can be wrapped" name="plain string/As container" time="{duration}"/>
<testcase classname="Long strings can be wrapped" name="plain string/Indent first line differently" time="{duration}"/>
<testcase classname="Long strings can be wrapped" name="With newlines/No wrapping" time="{duration}"/>
<testcase classname="Long strings can be wrapped" name="With newlines/Trailing newline" time="{duration}"/>
<testcase classname="Long strings can be wrapped" name="With newlines/Wrapped once" time="{duration}"/>
<testcase classname="Long strings can be wrapped" name="With newlines/Wrapped twice" time="{duration}"/>
<testcase classname="Long strings can be wrapped" name="With wrap-before/ after characters/No wrapping" time="{duration}"/>
<testcase classname="Long strings can be wrapped" name="With wrap-before/ after characters/Wrap before" time="{duration}"/>
<testcase classname="Long strings can be wrapped" name="With wrap-before/ after characters/Wrap after" time="{duration}"/>
<testcase classname="global" name="Long text is truncated" time="{duration}"/>
<testcase classname="global" name="ManuallyRegistered" time="{duration}"/>
<testcase classname="global" name="Matchers can be (AllOf) composed with the &amp;&amp; operator" time="{duration}"/>
<testcase classname="global" name="Matchers can be (AnyOf) composed with the || operator" time="{duration}"/>
<testcase classname="global" name="Matchers can be composed with both &amp;&amp; and ||" time="{duration}"/>
<testcase classname="global" name="Matchers can be composed with both &amp;&amp; and || - failing" time="{duration}">
<testcase classname="<exe-name>.global" name="Inequality checks that should succeed" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Less-than inequalities with different epsilons" time="{duration}"/>
<testcase classname="<exe-name>.global" name="ManuallyRegistered" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Matchers can be (AllOf) composed with the &amp;&amp; operator" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Matchers can be (AnyOf) composed with the || operator" time="{duration}"/>
<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>
</failure>
</testcase>
<testcase classname="global" name="Matchers can be negated (Not) with the ! operator" time="{duration}"/>
<testcase classname="global" name="Matchers can be negated (Not) with the ! operator - failing" time="{duration}">
<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>
</failure>
</testcase>
<testcase classname="global" name="Mismatching exception messages failing the test" time="{duration}">
<failure message="expected exception" type="REQUIRE_THROWS_WITH">
<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>
</failure>
</testcase>
<testcase classname="global" name="Nice descriptive name" time="{duration}"/>
<testcase classname="global" name="Non-std exceptions can be translated" time="{duration}">
<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>
</error>
</testcase>
<testcase classname="global" name="NotImplemented exception" time="{duration}"/>
<testcase classname="global" name="Objects that evaluated in boolean contexts can be checked" time="{duration}"/>
<testcase classname="global" name="Operators at different namespace levels not hijacked by Koenig lookup" time="{duration}"/>
<testcase classname="global" name="Ordering comparison checks that should fail" time="{duration}">
<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>
</failure>
@@ -377,102 +398,93 @@ ConditionTests.cpp:<line number>
ConditionTests.cpp:<line number>
</failure>
</testcase>
<testcase classname="global" name="Ordering comparison checks that should succeed" time="{duration}"/>
<testcase classname="Output from all sections is reported" name="one" time="{duration}">
<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>
</failure>
</testcase>
<testcase classname="Output from all sections is reported" name="two" time="{duration}">
<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>
</failure>
</testcase>
<testcase classname="Parse test names and tags" name="Empty test spec should have no filters" time="{duration}"/>
<testcase classname="Parse test names and tags" name="Test spec from empty string should have no filters" time="{duration}"/>
<testcase classname="Parse test names and tags" name="Test spec from just a comma should have no filters" time="{duration}"/>
<testcase classname="Parse test names and tags" name="Test spec from name should have one filter" time="{duration}"/>
<testcase classname="Parse test names and tags" name="Test spec from quoted name should have one filter" time="{duration}"/>
<testcase classname="Parse test names and tags" name="Test spec from name should have one filter" time="{duration}"/>
<testcase classname="Parse test names and tags" name="Wildcard at the start" time="{duration}"/>
<testcase classname="Parse test names and tags" name="Wildcard at the end" time="{duration}"/>
<testcase classname="Parse test names and tags" name="Wildcard at both ends" time="{duration}"/>
<testcase classname="Parse test names and tags" name="Redundant wildcard at the start" time="{duration}"/>
<testcase classname="Parse test names and tags" name="Redundant wildcard at the end" time="{duration}"/>
<testcase classname="Parse test names and tags" name="Redundant wildcard at both ends" time="{duration}"/>
<testcase classname="Parse test names and tags" name="Wildcard at both ends, redundant at start" time="{duration}"/>
<testcase classname="Parse test names and tags" name="Just wildcard" time="{duration}"/>
<testcase classname="Parse test names and tags" name="Single tag" time="{duration}"/>
<testcase classname="Parse test names and tags" name="Single tag, two matches" time="{duration}"/>
<testcase classname="Parse test names and tags" name="Two tags" time="{duration}"/>
<testcase classname="Parse test names and tags" name="Two tags, spare separated" time="{duration}"/>
<testcase classname="Parse test names and tags" name="Wildcarded name and tag" time="{duration}"/>
<testcase classname="Parse test names and tags" name="Single tag exclusion" time="{duration}"/>
<testcase classname="Parse test names and tags" name="One tag exclusion and one tag inclusion" time="{duration}"/>
<testcase classname="Parse test names and tags" name="One tag exclusion and one wldcarded name inclusion" time="{duration}"/>
<testcase classname="Parse test names and tags" name="One tag exclusion, using exclude:, and one wldcarded name inclusion" time="{duration}"/>
<testcase classname="Parse test names and tags" name="name exclusion" time="{duration}"/>
<testcase classname="Parse test names and tags" name="wildcarded name exclusion" time="{duration}"/>
<testcase classname="Parse test names and tags" name="wildcarded name exclusion with tag inclusion" time="{duration}"/>
<testcase classname="Parse test names and tags" name="wildcarded name exclusion, using exclude:, with tag inclusion" time="{duration}"/>
<testcase classname="Parse test names and tags" name="two wildcarded names" time="{duration}"/>
<testcase classname="Parse test names and tags" name="empty tag" time="{duration}"/>
<testcase classname="Parse test names and tags" name="empty quoted name" time="{duration}"/>
<testcase classname="Parse test names and tags" name="quoted string followed by tag exclusion" time="{duration}"/>
<testcase classname="global" name="Parsing a std::pair" time="{duration}"/>
<testcase classname="global" name="Pointers can be compared to null" time="{duration}"/>
<testcase classname="global" name="Pointers can be converted to strings" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="empty args don't cause a crash" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="default - no arguments" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="test lists/1 test" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="test lists/Specify one test case exclusion using exclude:" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="test lists/Specify one test case exclusion using ~" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="reporter/-r/console" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="reporter/-r/xml" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="reporter/-r xml and junit" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="reporter/--reporter/junit" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="debugger/-b" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="debugger/--break" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="abort/-a aborts after first failure" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="abort/-x 2 aborts after two failures" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="abort/-x must be greater than zero" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="abort/-x must be numeric" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="nothrow/-e" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="nothrow/--nothrow" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="output filename/-o filename" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="output filename/--out" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="combinations/Single character flags can be combined" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="use-colour/without option" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="use-colour/auto" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="use-colour/yes" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="use-colour/no" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="use-colour/error" time="{duration}"/>
<testcase classname="global" name="Reconstruction should be based on stringification: #914" time="{duration}">
<testcase classname="<exe-name>.global" name="Parse test names and tags/Empty test spec should have no filters" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/Test spec from empty string should have no filters" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/Test spec from just a comma should have no filters" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/Test spec from name should have one filter" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/Test spec from quoted name should have one filter" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/Test spec from name should have one filter" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/Wildcard at the start" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/Wildcard at the end" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/Wildcard at both ends" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/Redundant wildcard at the start" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/Redundant wildcard at the end" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/Redundant wildcard at both ends" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/Wildcard at both ends, redundant at start" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/Just wildcard" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/Single tag" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/Single tag, two matches" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/Two tags" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/Two tags, spare separated" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/Wildcarded name and tag" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/Single tag exclusion" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/One tag exclusion and one tag inclusion" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/One tag exclusion and one wldcarded name inclusion" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/One tag exclusion, using exclude:, and one wldcarded name inclusion" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/name exclusion" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/wildcarded name exclusion" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/wildcarded name exclusion with tag inclusion" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/wildcarded name exclusion, using exclude:, with tag inclusion" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/two wildcarded names" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/empty tag" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/empty quoted name" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/quoted string followed by tag exclusion" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parsing a std::pair" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Pointers can be compared to null" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Process can be configured on command line/empty args don't cause a crash" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Process can be configured on command line/default - no arguments" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Process can be configured on command line/test lists/1 test" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Process can be configured on command line/test lists/Specify one test case exclusion using exclude:" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Process can be configured on command line/test lists/Specify one test case exclusion using ~" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Process can be configured on command line/reporter/-r/console" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Process can be configured on command line/reporter/-r/xml" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Process can be configured on command line/reporter/-r xml and junit" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Process can be configured on command line/reporter/--reporter/junit" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Process can be configured on command line/debugger/-b" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Process can be configured on command line/debugger/--break" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Process can be configured on command line/abort/-a aborts after first failure" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Process can be configured on command line/abort/-x 2 aborts after two failures" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Process can be configured on command line/abort/-x must be numeric" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Process can be configured on command line/nothrow/-e" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Process can be configured on command line/nothrow/--nothrow" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Process can be configured on command line/output filename/-o filename" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Process can be configured on command line/output filename/--out" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Process can be configured on command line/combinations/Single character flags can be combined" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Process can be configured on command line/use-colour/without option" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Process can be configured on command line/use-colour/auto" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Process can be configured on command line/use-colour/yes" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Process can be configured on command line/use-colour/no" time="{duration}"/>
<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>
</failure>
</testcase>
<testcase classname="global" name="SCOPED_INFO is reset for each loop" time="{duration}">
<failure message="10 &lt; 10" type="REQUIRE">
current counter 10
i := 10
MessageTests.cpp:<line number>
</failure>
</testcase>
<testcase classname="global" name="SUCCEED counts as a test pass" time="{duration}"/>
<testcase classname="global" name="SUCCESS does not require an argument" time="{duration}"/>
<testcase classname="Fixture" name="Scenario: BDD tests requiring Fixtures to provide commonly-accessed data or methods/Given: No operations precede me" time="{duration}"/>
<testcase classname="Fixture" name="Scenario: BDD tests requiring Fixtures to provide commonly-accessed data or methods/Given: No operations precede me/When: We get the count/Then: Subsequently values are higher" time="{duration}"/>
<testcase classname="Scenario: Do that thing with the thing" name="Given: This stuff exists/When: I do this/Then: it should do this" time="{duration}"/>
<testcase classname="Scenario: Do that thing with the thing" name="Given: This stuff exists/When: I do this/Then: it should do this/And: do that" time="{duration}"/>
<testcase classname="Scenario: This is a really long scenario name to see how the list command deals with wrapping" name="Given: A section name that is so long that it cannot fit in a single console width/When: The test headers are printed as part of the normal running of the scenario/Then: The, deliberately very long and overly verbose (you see what I did there?) section names must wrap, along with an indent" time="{duration}"/>
<testcase classname="Scenario: Vector resizing affects size and capacity" name="Given: an empty vector" time="{duration}"/>
<testcase classname="Scenario: Vector resizing affects size and capacity" name="Given: an empty vector/When: it is made larger/Then: the size and capacity go up" time="{duration}"/>
<testcase classname="Scenario: Vector resizing affects size and capacity" name="Given: an empty vector/When: it is made larger/Then: the size and capacity go up/And when: it is made smaller again/Then: the size goes down but the capacity stays the same" time="{duration}"/>
<testcase classname="Scenario: Vector resizing affects size and capacity" name="Given: an empty vector/When: we reserve more space/Then: The capacity is increased but the size remains the same" time="{duration}"/>
<testcase classname="global" name="Sends stuff to stdout and stderr" time="{duration}">
<testcase classname="<exe-name>.global" name="SUCCEED counts as a test pass" time="{duration}"/>
<testcase classname="<exe-name>.global" name="SUCCESS does not require an argument" time="{duration}"/>
<testcase classname="<exe-name>.Fixture" name="Scenario: BDD tests requiring Fixtures to provide commonly-accessed data or methods/Given: No operations precede me" time="{duration}"/>
<testcase classname="<exe-name>.Fixture" name="Scenario: BDD tests requiring Fixtures to provide commonly-accessed data or methods/Given: No operations precede me/When: We get the count/Then: Subsequently values are higher" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Scenario: Do that thing with the thing/Given: This stuff exists/When: I do this/Then: it should do this" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Scenario: Do that thing with the thing/Given: This stuff exists/When: I do this/Then: it should do this/And: do that" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Scenario: This is a really long scenario name to see how the list command deals with wrapping/Given: A section name that is so long that it cannot fit in a single console width/When: The test headers are printed as part of the normal running of the scenario/Then: The, deliberately very long and overly verbose (you see what I did there?) section names must wrap, along with an indent" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Scenario: Vector resizing affects size and capacity/Given: an empty vector" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Scenario: Vector resizing affects size and capacity/Given: an empty vector/When: it is made larger/Then: the size and capacity go up" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Scenario: Vector resizing affects size and capacity/Given: an empty vector/When: it is made larger/Then: the size and capacity go up/And when: it is made smaller again/Then: the size goes down but the capacity stays the same" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Scenario: Vector resizing affects size and capacity/Given: an empty vector/When: we reserve more space/Then: The capacity is increased but the size remains the same" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Sends stuff to stdout and stderr" time="{duration}">
<system-out>
A string sent directly to stdout
</system-out>
@@ -480,33 +492,43 @@ A string sent directly to stdout
A string sent directly to stderr
</system-err>
</testcase>
<testcase classname="global" name="Some simple comparisons between doubles" time="{duration}"/>
<testcase classname="Standard error is reported and redirected" name="Interleaved writes to cerr and clog" time="{duration}">
<system-err>
Write to std::cerr
Write to std::clog
Interleaved writes to error streams
</system-err>
</testcase>
<testcase classname="Standard output from all sections is reported" name="two" time="{duration}">
<testcase classname="<exe-name>.global" name="Some simple comparisons between doubles" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Standard output from all sections is reported/two" time="{duration}">
<system-out>
Message from section one
Message from section two
</system-out>
</testcase>
<testcase classname="global" name="StartsWith string matcher" time="{duration}">
<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;string&quot;" type="CHECK_THAT">
MatchersTests.cpp:<line number>
</failure>
</testcase>
<testcase classname="global" name="String matchers" time="{duration}"/>
<testcase classname="global" name="Strings can be rendered with colour" time="{duration}">
<system-out>
hello
hello
</system-out>
<testcase classname="<exe-name>.global" name="String matchers" time="{duration}"/>
<testcase classname="<exe-name>.global" name="StringRef/Empty string" time="{duration}"/>
<testcase classname="<exe-name>.global" name="StringRef/From string literal" time="{duration}"/>
<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>
</failure>
</testcase>
<testcase classname="global" name="Tabs and newlines show in output" time="{duration}">
<testcase classname="<exe-name>.global" name="StringRef/Substrings/zero-based substring" time="{duration}"/>
<testcase classname="<exe-name>.global" name="StringRef/Substrings/c_str() causes copy" time="{duration}"/>
<testcase classname="<exe-name>.global" name="StringRef/Substrings/non-zero-based substring" time="{duration}"/>
<testcase classname="<exe-name>.global" name="StringRef/Substrings/Pointer values of full refs should match" time="{duration}"/>
<testcase classname="<exe-name>.global" name="StringRef/Substrings/Pointer values of substring refs should not match" time="{duration}"/>
<testcase classname="<exe-name>.global" name="StringRef/Comparisons" time="{duration}"/>
<testcase classname="<exe-name>.global" name="StringRef/from std::string/implicitly constructed" time="{duration}"/>
<testcase classname="<exe-name>.global" name="StringRef/from std::string/explicitly constructed" time="{duration}"/>
<testcase classname="<exe-name>.global" name="StringRef/from std::string/assigned" time="{duration}"/>
<testcase classname="<exe-name>.global" name="StringRef/to std::string/implicitly constructed" time="{duration}"/>
<testcase classname="<exe-name>.global" name="StringRef/to std::string/explicitly constructed" time="{duration}"/>
<testcase classname="<exe-name>.global" name="StringRef/to std::string/assigned" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Stringifying std::chrono::duration helpers" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Stringifying std::chrono::duration with weird ratios" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Stringifying std::chrono::time_point&lt;system_clock>" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Tabs and newlines show in output" time="{duration}">
<failure message="&quot;if ($b == 10) {
$a = 20;
}&quot;
@@ -518,42 +540,41 @@ hello
MiscTests.cpp:<line number>
</failure>
</testcase>
<testcase classname="Tag alias can be registered against tag patterns" name="The same tag alias can only be registered once" time="{duration}"/>
<testcase classname="Tag alias can be registered against tag patterns" name="Tag aliases must be of the form [@name]" time="{duration}"/>
<testcase classname="global" name="Test case with one argument" time="{duration}"/>
<testcase classname="global" name="Test enum bit values" time="{duration}"/>
<testcase classname="global" name="Text can be formatted using the Text class" time="{duration}"/>
<testcase classname="global" name="The NO_FAIL macro reports a failure but does not fail the test" time="{duration}"/>
<testcase classname="global" name="This test 'should' fail but doesn't" time="{duration}"/>
<testcase classname="Tracker" name="root" time="{duration}"/>
<testcase classname="Tracker" name="successfully close one section" time="{duration}"/>
<testcase classname="Tracker" name="fail one section" time="{duration}"/>
<testcase classname="Tracker" name="fail one section/re-enter after failed section" time="{duration}"/>
<testcase classname="Tracker" name="fail one section/re-enter after failed section and find next section" time="{duration}"/>
<testcase classname="Tracker" name="successfully close one section, then find another" time="{duration}"/>
<testcase classname="Tracker" name="successfully close one section, then find another/Re-enter - skips S1 and enters S2" time="{duration}"/>
<testcase classname="Tracker" name="successfully close one section, then find another/Re-enter - skips S1 and enters S2/Successfully close S2" time="{duration}"/>
<testcase classname="Tracker" name="successfully close one section, then find another/Re-enter - skips S1 and enters S2/fail S2" time="{duration}"/>
<testcase classname="Tracker" name="open a nested section" time="{duration}"/>
<testcase classname="Tracker" name="start a generator" time="{duration}"/>
<testcase classname="Tracker" name="start a generator/close outer section" time="{duration}"/>
<testcase classname="Tracker" name="start a generator/close outer section/Re-enter for second generation" time="{duration}"/>
<testcase classname="Tracker" name="start a generator/Start a new inner section" time="{duration}"/>
<testcase classname="Tracker" name="start a generator/Start a new inner section/Re-enter for second generation" time="{duration}"/>
<testcase classname="Tracker" name="start a generator/Fail an inner section" time="{duration}"/>
<testcase classname="Tracker" name="start a generator/Fail an inner section/Re-enter for second generation" time="{duration}"/>
<testcase classname="global" name="Unexpected exceptions can be translated" time="{duration}">
<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}"/>
<testcase classname="<exe-name>.global" name="Tag alias can be registered against tag patterns/Tag aliases must be of the form [@name]" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Test case with one argument" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Test enum bit values" time="{duration}"/>
<testcase classname="<exe-name>.global" name="The NO_FAIL macro reports a failure but does not fail the test" time="{duration}"/>
<testcase classname="<exe-name>.global" name="This test 'should' fail but doesn't" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Tracker" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Tracker/successfully close one section" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Tracker/fail one section" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Tracker/fail one section/re-enter after failed section" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Tracker/fail one section/re-enter after failed section and find next section" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Tracker/successfully close one section, then find another" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Tracker/successfully close one section, then find another/Re-enter - skips S1 and enters S2" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Tracker/successfully close one section, then find another/Re-enter - skips S1 and enters S2/Successfully close S2" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Tracker/successfully close one section, then find another/Re-enter - skips S1 and enters S2/fail S2" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Tracker/open a nested section" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Tracker/start a generator" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Tracker/start a generator/close outer section" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Tracker/start a generator/close outer section/Re-enter for second generation" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Tracker/start a generator/Start a new inner section" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Tracker/start a generator/Start a new inner section/Re-enter for second generation" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Tracker/start a generator/Fail an inner section" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Tracker/start a generator/Fail an inner section/Re-enter for second generation" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Unexpected exceptions can be translated" time="{duration}">
<error type="TEST_CASE">
3.14
ExceptionTests.cpp:<line number>
</error>
</testcase>
<testcase classname="global" name="Use a custom approx" time="{duration}"/>
<testcase classname="Variadic macros" name="Section with one argument" time="{duration}"/>
<testcase classname="Vector matchers" name="Contains (element)" time="{duration}"/>
<testcase classname="Vector matchers" name="Contains (vector)" time="{duration}"/>
<testcase classname="Vector matchers" name="Equals" time="{duration}"/>
<testcase classname="Vector matchers that fail" name="Contains (element)" time="{duration}">
<testcase classname="<exe-name>.global" name="Use a custom approx" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Variadic macros/Section with one argument" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Vector matchers/Contains (element)" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Vector matchers/Contains (vector)" time="{duration}"/>
<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>
</failure>
@@ -561,7 +582,7 @@ MatchersTests.cpp:<line number>
MatchersTests.cpp:<line number>
</failure>
</testcase>
<testcase classname="Vector matchers that fail" name="Contains (vector)" time="{duration}">
<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>
</failure>
@@ -569,7 +590,7 @@ MatchersTests.cpp:<line number>
MatchersTests.cpp:<line number>
</failure>
</testcase>
<testcase classname="Vector matchers that fail" name="Equals" time="{duration}">
<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>
</failure>
@@ -583,55 +604,55 @@ MatchersTests.cpp:<line number>
MatchersTests.cpp:<line number>
</failure>
</testcase>
<testcase classname="global" name="When checked exceptions are thrown they can be expected or unexpected" time="{duration}"/>
<testcase classname="global" name="When unchecked exceptions are thrown directly they are always failures" time="{duration}">
<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>
</error>
</testcase>
<testcase classname="global" name="When unchecked exceptions are thrown during a CHECK the test should continue" time="{duration}">
<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>
</error>
</testcase>
<testcase classname="global" name="When unchecked exceptions are thrown during a REQUIRE the test should abort fail" time="{duration}">
<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>
</error>
</testcase>
<testcase classname="global" name="When unchecked exceptions are thrown from functions they are always failures" time="{duration}">
<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>
</error>
</testcase>
<testcase classname="When unchecked exceptions are thrown from sections they are always failures" name="section name" time="{duration}">
<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>
</error>
</testcase>
<testcase classname="global" name="Where the LHS is not a simple value" time="{duration}"/>
<testcase classname="global" name="Where there is more to the expression after the RHS" time="{duration}"/>
<testcase classname="global" name="X/level/0/a" time="{duration}"/>
<testcase classname="global" name="X/level/0/b" time="{duration}"/>
<testcase classname="global" name="X/level/1/a" time="{duration}"/>
<testcase classname="global" name="X/level/1/b" time="{duration}"/>
<testcase classname="XmlEncode" name="normal string" time="{duration}"/>
<testcase classname="XmlEncode" name="empty string" time="{duration}"/>
<testcase classname="XmlEncode" name="string with ampersand" time="{duration}"/>
<testcase classname="XmlEncode" name="string with less-than" time="{duration}"/>
<testcase classname="XmlEncode" name="string with greater-than" time="{duration}"/>
<testcase classname="XmlEncode" name="string with quotes" time="{duration}"/>
<testcase classname="XmlEncode" name="string with control char (1)" time="{duration}"/>
<testcase classname="XmlEncode" name="string with control char (x7F)" time="{duration}"/>
<testcase classname="global" name="atomic if" time="{duration}"/>
<testcase classname="global" name="boolean member" time="{duration}"/>
<testcase classname="global" name="checkedElse" time="{duration}"/>
<testcase classname="global" name="checkedElse, failing" time="{duration}">
<testcase classname="<exe-name>.global" name="Where the LHS is not a simple value" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Where there is more to the expression after the RHS" time="{duration}"/>
<testcase classname="<exe-name>.global" name="X/level/0/a" time="{duration}"/>
<testcase classname="<exe-name>.global" name="X/level/0/b" time="{duration}"/>
<testcase classname="<exe-name>.global" name="X/level/1/a" time="{duration}"/>
<testcase classname="<exe-name>.global" name="X/level/1/b" time="{duration}"/>
<testcase classname="<exe-name>.global" name="XmlEncode/normal string" time="{duration}"/>
<testcase classname="<exe-name>.global" name="XmlEncode/empty string" time="{duration}"/>
<testcase classname="<exe-name>.global" name="XmlEncode/string with ampersand" time="{duration}"/>
<testcase classname="<exe-name>.global" name="XmlEncode/string with less-than" time="{duration}"/>
<testcase classname="<exe-name>.global" name="XmlEncode/string with greater-than" time="{duration}"/>
<testcase classname="<exe-name>.global" name="XmlEncode/string with quotes" time="{duration}"/>
<testcase classname="<exe-name>.global" name="XmlEncode/string with control char (1)" time="{duration}"/>
<testcase classname="<exe-name>.global" name="XmlEncode/string with control char (x7F)" time="{duration}"/>
<testcase classname="<exe-name>.global" name="atomic if" time="{duration}"/>
<testcase classname="<exe-name>.global" name="boolean member" time="{duration}"/>
<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>
</failure>
@@ -639,8 +660,8 @@ MiscTests.cpp:<line number>
MiscTests.cpp:<line number>
</failure>
</testcase>
<testcase classname="global" name="checkedIf" time="{duration}"/>
<testcase classname="global" name="checkedIf, failing" time="{duration}">
<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>
</failure>
@@ -648,23 +669,24 @@ MiscTests.cpp:<line number>
MiscTests.cpp:<line number>
</failure>
</testcase>
<testcase classname="global" name="comparisons between const int variables" time="{duration}"/>
<testcase classname="global" name="comparisons between int variables" time="{duration}"/>
<testcase classname="even more nested SECTION tests" name="c/d (leaf)" time="{duration}"/>
<testcase classname="even more nested SECTION tests" name="c/e (leaf)" time="{duration}"/>
<testcase classname="even more nested SECTION tests" name="f (leaf)" time="{duration}"/>
<testcase classname="global" name="just failure" time="{duration}">
<testcase classname="<exe-name>.global" name="comparisons between const int variables" time="{duration}"/>
<testcase classname="<exe-name>.global" name="comparisons between int variables" time="{duration}"/>
<testcase classname="<exe-name>.global" name="even more nested SECTION tests/c/d (leaf)" time="{duration}"/>
<testcase classname="<exe-name>.global" name="even more nested SECTION tests/c/e (leaf)" time="{duration}"/>
<testcase classname="<exe-name>.global" name="even more nested SECTION tests/f (leaf)" time="{duration}"/>
<testcase classname="<exe-name>.global" name="just failure" time="{duration}">
<failure type="FAIL">
Previous info should not be seen
MessageTests.cpp:<line number>
</failure>
</testcase>
<testcase classname="looped SECTION tests" name="s1" time="{duration}">
<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>
</failure>
</testcase>
<testcase classname="global" name="looped tests" time="{duration}">
<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>
@@ -690,82 +712,96 @@ Testing if fib[7] (21) is even
MiscTests.cpp:<line number>
</failure>
</testcase>
<testcase classname="more nested SECTION tests" name="s2/s1" time="{duration}">
<testcase classname="<exe-name>.global" name="more nested SECTION tests/s2/s1" time="{duration}">
<failure message="1 == 2" type="REQUIRE">
MiscTests.cpp:<line number>
</failure>
</testcase>
<testcase classname="more nested SECTION tests" name="s1/s3" time="{duration}"/>
<testcase classname="more nested SECTION tests" name="s1/s4" time="{duration}"/>
<testcase classname="nested SECTION tests" name="s1" time="{duration}"/>
<testcase classname="nested SECTION tests" name="s1/s2" time="{duration}"/>
<testcase classname="global" name="non streamable - with conv. op" time="{duration}"/>
<testcase classname="global" name="not allowed" time="{duration}"/>
<testcase classname="global" name="null strings" time="{duration}"/>
<testcase classname="global" name="pair&lt;pair&lt;int,const char *,pair&lt;std::string,int> > -> toString" time="{duration}"/>
<testcase classname="global" name="pointer to class" time="{duration}"/>
<testcase classname="random SECTION tests" name="s1" time="{duration}"/>
<testcase classname="random SECTION tests" name="s2" time="{duration}"/>
<testcase classname="replaceInPlace" name="replace single char" time="{duration}"/>
<testcase classname="replaceInPlace" name="replace two chars" time="{duration}"/>
<testcase classname="replaceInPlace" name="replace first char" time="{duration}"/>
<testcase classname="replaceInPlace" name="replace last char" time="{duration}"/>
<testcase classname="replaceInPlace" name="replace all chars" time="{duration}"/>
<testcase classname="replaceInPlace" name="replace no chars" time="{duration}"/>
<testcase classname="replaceInPlace" name="escape '" time="{duration}"/>
<testcase classname="global" name="send a single char to INFO" time="{duration}">
<testcase classname="<exe-name>.global" name="more nested SECTION tests/s1/s3" time="{duration}"/>
<testcase classname="<exe-name>.global" name="more nested SECTION tests/s1/s4" time="{duration}"/>
<testcase classname="<exe-name>.global" name="nested SECTION tests/s1" time="{duration}"/>
<testcase classname="<exe-name>.global" name="nested SECTION tests/s1/s2" time="{duration}"/>
<testcase classname="<exe-name>.global" name="non streamable - with conv. op" time="{duration}"/>
<testcase classname="<exe-name>.global" name="non-copyable objects" time="{duration}"/>
<testcase classname="<exe-name>.global" name="not allowed" time="{duration}"/>
<testcase classname="<exe-name>.global" name="null strings" time="{duration}"/>
<testcase classname="<exe-name>.global" name="null_ptr" time="{duration}"/>
<testcase classname="<exe-name>.global" name="pair&lt;pair&lt;int,const char *,pair&lt;std::string,int> > -> toString" time="{duration}"/>
<testcase classname="<exe-name>.global" name="pointer to class" time="{duration}"/>
<testcase classname="<exe-name>.global" name="random SECTION tests/s1" time="{duration}"/>
<testcase classname="<exe-name>.global" name="random SECTION tests/s2" time="{duration}"/>
<testcase classname="<exe-name>.global" name="replaceInPlace/replace single char" time="{duration}"/>
<testcase classname="<exe-name>.global" name="replaceInPlace/replace two chars" time="{duration}"/>
<testcase classname="<exe-name>.global" name="replaceInPlace/replace first char" time="{duration}"/>
<testcase classname="<exe-name>.global" name="replaceInPlace/replace last char" time="{duration}"/>
<testcase classname="<exe-name>.global" name="replaceInPlace/replace all chars" time="{duration}"/>
<testcase classname="<exe-name>.global" name="replaceInPlace/replace no chars" time="{duration}"/>
<testcase classname="<exe-name>.global" name="replaceInPlace/escape '" time="{duration}"/>
<testcase classname="<exe-name>.global" name="send a single char to INFO" time="{duration}">
<failure message="false" type="REQUIRE">
3
MiscTests.cpp:<line number>
</failure>
</testcase>
<testcase classname="global" name="sends information to INFO" time="{duration}">
<testcase classname="<exe-name>.global" name="sends information to INFO" time="{duration}">
<failure message="false" type="REQUIRE">
hi
i := 7
MessageTests.cpp:<line number>
</failure>
</testcase>
<testcase classname="global" name="std::pair&lt;int,const std::string> -> toString" time="{duration}"/>
<testcase classname="global" name="std::pair&lt;int,std::string> -> toString" time="{duration}"/>
<testcase classname="global" name="std::vector&lt;std::pair&lt;std::string,int> > -> toString" time="{duration}"/>
<testcase classname="global" name="string literals of different sizes can be compared" time="{duration}">
<testcase classname="<exe-name>.global" name="std::pair&lt;int,const std::string> -> toString" time="{duration}"/>
<testcase classname="<exe-name>.global" name="std::pair&lt;int,std::string> -> toString" time="{duration}"/>
<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>
</failure>
</testcase>
<testcase classname="global" name="toString on const wchar_t const pointer returns the string contents" time="{duration}"/>
<testcase classname="global" name="toString on const wchar_t pointer returns the string contents" time="{duration}"/>
<testcase classname="global" name="toString on wchar_t const pointer returns the string contents" time="{duration}"/>
<testcase classname="global" name="toString on wchar_t returns the string contents" time="{duration}"/>
<testcase classname="global" name="toString( has_maker )" time="{duration}"/>
<testcase classname="global" name="toString( has_maker_and_toString )" time="{duration}"/>
<testcase classname="global" name="toString( has_toString )" time="{duration}"/>
<testcase classname="global" name="toString( vectors&lt;has_maker )" time="{duration}"/>
<testcase classname="global" name="toString(enum w/operator&lt;&lt;)" time="{duration}"/>
<testcase classname="global" name="toString(enum)" time="{duration}"/>
<testcase classname="global" name="vector&lt;int> -> toString" time="{duration}"/>
<testcase classname="global" name="vector&lt;string> -> toString" time="{duration}"/>
<testcase classname="vectors can be sized and resized" name="root" time="{duration}"/>
<testcase classname="vectors can be sized and resized" name="resizing bigger changes size and capacity" time="{duration}"/>
<testcase classname="vectors can be sized and resized" name="resizing smaller changes size but not capacity" time="{duration}"/>
<testcase classname="vectors can be sized and resized" name="resizing smaller changes size but not capacity/We can use the 'swap trick' to reset the capacity" time="{duration}"/>
<testcase classname="vectors can be sized and resized" name="reserving bigger changes capacity but not size" time="{duration}"/>
<testcase classname="vectors can be sized and resized" name="reserving smaller does not change size or capacity" time="{duration}"/>
<testcase classname="xmlentitycheck" name="embedded xml" time="{duration}"/>
<testcase classname="xmlentitycheck" name="encoded chars" time="{duration}"/>
<testcase classname="<exe-name>.global" name="stringify( has_maker )" time="{duration}"/>
<testcase classname="<exe-name>.global" name="stringify( has_maker_and_toString )" time="{duration}"/>
<testcase classname="<exe-name>.global" name="stringify( has_operator )" time="{duration}"/>
<testcase classname="<exe-name>.global" name="toString on const wchar_t const pointer returns the string contents" time="{duration}"/>
<testcase classname="<exe-name>.global" name="toString on const wchar_t pointer returns the string contents" time="{duration}"/>
<testcase classname="<exe-name>.global" name="toString on wchar_t const pointer returns the string contents" time="{duration}"/>
<testcase classname="<exe-name>.global" name="toString on wchar_t returns the string contents" time="{duration}"/>
<testcase classname="<exe-name>.global" name="toString( vectors&lt;has_maker )" time="{duration}"/>
<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>
</failure>
<failure message="&quot;{?}&quot; == &quot;1&quot;" type="CHECK">
EnumToString.cpp:<line number>
</failure>
</testcase>
<testcase classname="<exe-name>.global" name="toString(enum w/operator&lt;&lt;)" time="{duration}"/>
<testcase classname="<exe-name>.global" name="toString(enum)" time="{duration}"/>
<testcase classname="<exe-name>.global" name="tuple&lt;>" time="{duration}"/>
<testcase classname="<exe-name>.global" name="tuple&lt;float,int>" time="{duration}"/>
<testcase classname="<exe-name>.global" name="tuple&lt;int>" time="{duration}"/>
<testcase classname="<exe-name>.global" name="tuple&lt;0,int,const char *>" time="{duration}"/>
<testcase classname="<exe-name>.global" name="tuple&lt;string,string>" time="{duration}"/>
<testcase classname="<exe-name>.global" name="tuple&lt;tuple&lt;int>,tuple&lt;>,float>" time="{duration}"/>
<testcase classname="<exe-name>.global" name="vec&lt;vec&lt;string,alloc>> -> toString" time="{duration}"/>
<testcase classname="<exe-name>.global" name="vector&lt;int,allocator> -> toString" time="{duration}"/>
<testcase classname="<exe-name>.global" name="vector&lt;int> -> toString" time="{duration}"/>
<testcase classname="<exe-name>.global" name="vector&lt;string> -> toString" time="{duration}"/>
<testcase classname="<exe-name>.global" name="vectors can be sized and resized" time="{duration}"/>
<testcase classname="<exe-name>.global" name="vectors can be sized and resized/resizing bigger changes size and capacity" time="{duration}"/>
<testcase classname="<exe-name>.global" name="vectors can be sized and resized/resizing smaller changes size but not capacity" time="{duration}"/>
<testcase classname="<exe-name>.global" name="vectors can be sized and resized/resizing smaller changes size but not capacity/We can use the 'swap trick' to reset the capacity" time="{duration}"/>
<testcase classname="<exe-name>.global" name="vectors can be sized and resized/reserving bigger changes capacity but not size" time="{duration}"/>
<testcase classname="<exe-name>.global" name="vectors can be sized and resized/reserving smaller does not change size or capacity" time="{duration}"/>
<testcase classname="<exe-name>.global" name="xmlentitycheck/embedded xml" time="{duration}"/>
<testcase classname="<exe-name>.global" name="xmlentitycheck/encoded chars" time="{duration}"/>
<system-out>
A string sent directly to stdout
Message from section one
Message from section two
hello
hello
</system-out>
<system-err>
A string sent directly to stderr
Write to std::cerr
Write to std::clog
Interleaved writes to error streams
</system-err>
</testsuite>
</testsuites>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,43 @@
#include "catch.hpp"
#include <map>
TEST_CASE( "benchmarked", "[!benchmark]" ) {
static const int size = 100;
std::vector<int> v;
std::map<int, int> m;
BENCHMARK( "Load up a vector" ) {
v = std::vector<int>();
for(int i =0; i < size; ++i )
v.push_back( i );
}
REQUIRE( v.size() == size );
BENCHMARK( "Load up a map" ) {
m = std::map<int, int>();
for(int i =0; i < size; ++i )
m.insert( { i, i+1 } );
}
REQUIRE( m.size() == size );
BENCHMARK( "Reserved vector" ) {
v = std::vector<int>();
v.reserve(size);
for(int i =0; i < size; ++i )
v.push_back( i );
}
REQUIRE( v.size() == size );
int array[size];
BENCHMARK( "A fixed size array that should require no allocations" ) {
for(int i =0; i < size; ++i )
array[i] = i;
}
int sum = 0;
for(int i =0; i < size; ++i )
sum += array[i];
REQUIRE( sum > size );
}

View File

@@ -7,60 +7,60 @@
*/
#include "catch.hpp"
#include "internal/catch_test_spec_parser.hpp"
#include "internal/catch_test_spec_parser.h"
#ifdef __clang__
# pragma clang diagnostic ignored "-Wc++98-compat"
#endif
inline Catch::TestCase fakeTestCase( const char* name, const char* desc = "" ){ return Catch::makeTestCase( CATCH_NULL, "", name, desc, CATCH_INTERNAL_LINEINFO ); }
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 );

View File

@@ -41,9 +41,11 @@ bool templated_tests(T t) {
REQUIRE(a == t);
CHECK(a == t);
REQUIRE_THROWS(throws_int(true));
CHECK_THROWS_AS(throws_int(true), const int&);
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;
}
@@ -51,8 +53,17 @@ TEST_CASE("#833") {
REQUIRE(templated_tests<int>(3));
}
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-function"
#endif
#ifdef __GNUC__
// Note that because -~GCC~-, this warning cannot be silenced temporarily, by pushing diagnostic stack...
// Luckily it is firing in test files and thus can be silenced for the whole file, without losing much.
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
// Test containing example where original stream insertable check breaks compilation
#if defined (CATCH_CONFIG_CPP11_STREAM_INSERTABLE_CHECK)
namespace {
struct A {};
std::ostream& operator<< (std::ostream &o, const A &) { return o << 0; }
@@ -64,9 +75,13 @@ namespace {
B f ();
std::ostream g ();
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
TEST_CASE( "#872" ) {
A dummy;
CAPTURE( dummy );
B x;
REQUIRE (x == 4);
}
#endif

View File

@@ -6,27 +6,22 @@
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifdef __clang__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wpadded"
# pragma clang diagnostic ignored "-Wc++98-compat"
# pragma clang diagnostic ignored "-Wdouble-promotion"
#endif
#include "catch.hpp"
#include <string>
#include <limits>
#include <cstdint>
struct TestData {
TestData()
: int_seven( 7 ),
str_hello( "hello" ),
float_nine_point_one( 9.1f ),
double_pi( 3.1415926535 )
{}
int int_seven;
std::string str_hello;
float float_nine_point_one;
double double_pi;
int int_seven = 7;
std::string str_hello = "hello";
float float_nine_point_one = 9.1f;
double double_pi = 3.1415926535;
};
@@ -37,14 +32,13 @@ struct TestDef {
TestDef& operator[]( const std::string& ) {
return *this;
}
};
// The "failing" tests all use the CHECK macro, which continues if the specific test fails.
// This allows us to see all results, even if an earlier check fails
// Equality tests
TEST_CASE( "Equality checks that should succeed", "" )
TEST_CASE( "Equality checks that should succeed" )
{
TestDef td;
@@ -84,7 +78,7 @@ TEST_CASE( "Equality checks that should fail", "[.][failing][!mayfail]" )
CHECK( x == Approx( 1.301 ) );
}
TEST_CASE( "Inequality checks that should succeed", "" )
TEST_CASE( "Inequality checks that should succeed" )
{
TestData data;
@@ -113,7 +107,7 @@ TEST_CASE( "Inequality checks that should fail", "[.][failing][!shouldfail]" )
}
// Ordering comparison tests
TEST_CASE( "Ordering comparison checks that should succeed", "" )
TEST_CASE( "Ordering comparison checks that should succeed" )
{
TestData data;
@@ -169,8 +163,13 @@ TEST_CASE( "Ordering comparison checks that should fail", "[.][failing]" )
CHECK( data.str_hello <= "a" );
}
#ifdef __clang__
# pragma clang diagnostic pop
#endif
// Comparisons with int literals
TEST_CASE( "Comparisons with int literals don't warn when mixing signed/ unsigned", "" )
TEST_CASE( "Comparisons with int literals don't warn when mixing signed/ unsigned" )
{
int i = 1;
unsigned int ui = 2;
@@ -193,7 +192,7 @@ TEST_CASE( "Comparisons with int literals don't warn when mixing signed/ unsigne
REQUIRE( 5 == c );
REQUIRE( 6 == uc );
REQUIRE( (std::numeric_limits<unsigned long>::max)() > ul );
REQUIRE( (std::numeric_limits<uint32_t>::max)() > ul );
}
// Disable warnings about sign conversions for the next two tests
@@ -208,7 +207,7 @@ TEST_CASE( "Comparisons with int literals don't warn when mixing signed/ unsigne
#pragma warning(disable:4389) // '==' : signed/unsigned mismatch
#endif
TEST_CASE( "comparisons between int variables", "" )
TEST_CASE( "comparisons between int variables" )
{
long long_var = 1L;
unsigned char unsigned_char_var = 1;
@@ -222,7 +221,7 @@ TEST_CASE( "comparisons between int variables", "" )
REQUIRE( long_var == unsigned_long_var );
}
TEST_CASE( "comparisons between const int variables", "" )
TEST_CASE( "comparisons between const int variables" )
{
const unsigned char unsigned_char_var = 1;
const unsigned short unsigned_short_var = 1;
@@ -235,7 +234,7 @@ TEST_CASE( "comparisons between const int variables", "" )
REQUIRE( unsigned_long_var == 1 );
}
TEST_CASE( "Comparisons between unsigned ints and negative signed ints match c++ standard behaviour", "" )
TEST_CASE( "Comparisons between unsigned ints and negative signed ints match c++ standard behaviour" )
{
CHECK( ( -1 > 2u ) );
CHECK( -1 > 2u );
@@ -248,7 +247,7 @@ TEST_CASE( "Comparisons between unsigned ints and negative signed ints match c++
CHECK( minInt > 2u );
}
TEST_CASE( "Comparisons between ints where one side is computed", "" )
TEST_CASE( "Comparisons between ints where one side is computed" )
{
CHECK( 54 == 6*9 );
}
@@ -257,32 +256,32 @@ TEST_CASE( "Comparisons between ints where one side is computed", "" )
#pragma GCC diagnostic pop
#endif
inline const char* returnsConstNull(){ return CATCH_NULL; }
inline char* returnsNull(){ return CATCH_NULL; }
inline const char* returnsConstNull(){ return nullptr; }
inline char* returnsNull(){ return nullptr; }
TEST_CASE( "Pointers can be compared to null", "" )
TEST_CASE( "Pointers can be compared to null" )
{
TestData* p = CATCH_NULL;
TestData* pNULL = CATCH_NULL;
TestData* p = nullptr;
TestData* pNULL = nullptr;
REQUIRE( p == CATCH_NULL );
REQUIRE( p == nullptr );
REQUIRE( p == pNULL );
TestData data;
p = &data;
REQUIRE( p != CATCH_NULL );
REQUIRE( p != nullptr );
const TestData* cp = p;
REQUIRE( cp != CATCH_NULL );
REQUIRE( cp != nullptr );
const TestData* const cpc = p;
REQUIRE( cpc != CATCH_NULL );
REQUIRE( cpc != nullptr );
REQUIRE( returnsNull() == CATCH_NULL );
REQUIRE( returnsConstNull() == CATCH_NULL );
REQUIRE( returnsNull() == nullptr );
REQUIRE( returnsConstNull() == nullptr );
REQUIRE( CATCH_NULL != p );
REQUIRE( nullptr != p );
}
// Not (!) tests
@@ -292,7 +291,7 @@ TEST_CASE( "Pointers can be compared to null", "" )
// is detected and a warning issued.
// An alternative form of the macros (CHECK_FALSE and REQUIRE_FALSE) can be used instead to capture
// the operand value.
TEST_CASE( "'Not' checks that should succeed", "" )
TEST_CASE( "'Not' checks that should succeed" )
{
bool falseValue = false;

View File

@@ -7,6 +7,7 @@
*/
#include <iostream>
#include <cstdio>
struct truthy {
truthy(bool b):m_value(b){}
@@ -26,3 +27,9 @@ std::ostream& operator<<(std::ostream& o, truthy) {
TEST_CASE( "Reconstruction should be based on stringification: #914" , "[Decomposition][failing][.]") {
CHECK(truthy(false));
}
TEST_CASE("#1005: Comparing pointer to int and long (NULL can be either on various systems)", "[Decomposition]") {
FILE* fptr = nullptr;
REQUIRE(fptr == 0);
REQUIRE(fptr == 0l);
}

View File

@@ -1,54 +1,46 @@
#include "catch.hpp"
/*
TODO: maybe ought to check that user-provided specialisations of
Catch::toString also do the right thing
*/
// Enum without user-provided stream operator
enum Enum1 { Enum1Value0, Enum1Value1 };
TEST_CASE( "toString(enum)", "[toString][enum]" ) {
Enum1 e0 = Enum1Value0;
CHECK( Catch::toString(e0) == "0" );
CHECK( ::Catch::Detail::stringify(e0) == "0" );
Enum1 e1 = Enum1Value1;
CHECK( Catch::toString(e1) == "1" );
CHECK( ::Catch::Detail::stringify(e1) == "1" );
}
// Enum with user-provided stream operator
enum Enum2 { Enum2Value0, Enum2Value1 };
inline std::ostream& operator<<( std::ostream& os, Enum2 v ) {
std::ostream& operator<<( std::ostream& os, Enum2 v ) {
return os << "E2{" << static_cast<int>(v) << "}";
}
TEST_CASE( "toString(enum w/operator<<)", "[toString][enum]" ) {
Enum2 e0 = Enum2Value0;
CHECK( Catch::toString(e0) == "E2{0}" );
CHECK( ::Catch::Detail::stringify(e0) == "E2{0}" );
Enum2 e1 = Enum2Value1;
CHECK( Catch::toString(e1) == "E2{1}" );
CHECK( ::Catch::Detail::stringify(e1) == "E2{1}" );
}
#if defined(CATCH_CPP11_OR_GREATER)
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc++98-compat"
#endif
// Enum class without user-provided stream operator
enum class EnumClass1 { EnumClass1Value0, EnumClass1Value1 };
TEST_CASE( "toString(enum class)", "[toString][enum][enumClass][c++11][.]" ) {
// This fails, but has been hidden for a while - not sure if it's a regression or if it never worked
// - need to investigate
TEST_CASE( "toString(enum class)", "[toString][enum][enumClass][.]" ) {
EnumClass1 e0 = EnumClass1::EnumClass1Value0;
CHECK( Catch::toString(e0) == "0" );
CHECK( ::Catch::Detail::stringify(e0) == "0" );
EnumClass1 e1 = EnumClass1::EnumClass1Value1;
CHECK( Catch::toString(e1) == "1" );
CHECK( ::Catch::Detail::stringify(e1) == "1" );
}
// Enum class with user-provided stream operator
enum class EnumClass2 : short { EnumClass2Value0, EnumClass2Value1 };
inline std::ostream& operator<<( std::ostream& os, EnumClass2 e2 ) {
std::ostream& operator<<( std::ostream& os, EnumClass2 e2 ) {
switch( static_cast<int>( e2 ) ) {
case static_cast<int>( EnumClass2::EnumClass2Value0 ):
return os << "E2/V0";
@@ -59,18 +51,13 @@ inline std::ostream& operator<<( std::ostream& os, EnumClass2 e2 ) {
}
}
TEST_CASE( "toString(enum class w/operator<<)", "[toString][enum][enumClass][c++11][.]" ) {
TEST_CASE( "toString(enum class w/operator<<)", "[toString][enum][enumClass]" ) {
EnumClass2 e0 = EnumClass2::EnumClass2Value0;
CHECK( Catch::toString(e0) == "E2/V0" );
CHECK( ::Catch::Detail::stringify(e0) == "E2/V0" );
EnumClass2 e1 = EnumClass2::EnumClass2Value1;
CHECK( Catch::toString(e1) == "E2/V1" );
CHECK( ::Catch::Detail::stringify(e1) == "E2/V1" );
EnumClass2 e3 = static_cast<EnumClass2>(10);
CHECK( Catch::toString(e3) == "Unknown enum value 10" );
CHECK( ::Catch::Detail::stringify(e3) == "Unknown enum value 10" );
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // CATCH_CPP11_OR_GREATER

View File

@@ -14,6 +14,10 @@
#ifdef _MSC_VER
#pragma warning(disable:4702) // Unreachable code -- MSVC 19 (VS 2015) sees right through the indirection
#endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wweak-vtables"
#endif
namespace
{
@@ -59,7 +63,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" );
@@ -120,7 +124,7 @@ public:
CustomStdException( const std::string& msg )
: m_msg( msg )
{}
~CustomStdException() CATCH_NOEXCEPT {}
~CustomStdException() noexcept {}
std::string getMessage() const
{
@@ -144,7 +148,7 @@ CATCH_TRANSLATE_EXCEPTION( CustomStdException& ex )
CATCH_TRANSLATE_EXCEPTION( double& ex )
{
return Catch::toString( ex );
return Catch::Detail::stringify( ex );
}
TEST_CASE("Non-std exceptions can be translated", "[.][failing][!throws]" )
@@ -181,14 +185,7 @@ TEST_CASE( "Unexpected exceptions can be translated", "[.][failing][!throws]" )
throw double( 3.14 );
}
inline int thisFunctionNotImplemented( int ) {
CATCH_NOT_IMPLEMENTED;
}
TEST_CASE( "NotImplemented exception", "[!throws]" )
{
REQUIRE_THROWS( thisFunctionNotImplemented( 7 ) );
}
#ifndef CATCH_CONFIG_DISABLE_MATCHERS
TEST_CASE( "Exception messages can be tested for", "[!throws]" ) {
using namespace Catch::Matchers;
@@ -204,13 +201,15 @@ 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" );
REQUIRE_THROWS_WITH( thisThrows(), "expected exception" );
}
TEST_CASE( "#748 - captures with unexpected exceptions", "[!shouldfail][!throws]" ) {
TEST_CASE( "#748 - captures with unexpected exceptions", "[.][failing][!throws][!shouldfail]" ) {
int answer = 42;
CAPTURE( answer );
// the message should be printed on the first two sections but not on the third
@@ -224,3 +223,7 @@ TEST_CASE( "#748 - captures with unexpected exceptions", "[!shouldfail][!throws]
REQUIRE_THROWS( thisThrows() );
}
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif

View File

@@ -1,42 +0,0 @@
/*
* Created by Phil on 28/01/2011.
* Copyright 2011 Two Blue Cubes Ltd. All rights reserved.
*
* 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)
*/
// This define means we have to prefix all the CATCH macros with CATCH_
// We're using it here to test it out
#define CATCH_CONFIG_PREFIX_ALL
#include "catch.hpp"
inline int multiply( int a, int b )
{
return a*b;
}
CATCH_TEST_CASE( "Generators over two ranges", "[generators]" )
{
using namespace Catch::Generators;
int i = CATCH_GENERATE( between( 1, 5 ).then( values( 15, 20, 21 ).then( 36 ) ) );
int j = CATCH_GENERATE( between( 100, 107 ) );
CATCH_REQUIRE( multiply( i, 2 ) == i*2 );
CATCH_REQUIRE( multiply( j, 2 ) == j*2 );
}
struct IntPair { int first, second; };
CATCH_TEST_CASE( "Generator over a range of pairs", "[generators]" )
{
using namespace Catch::Generators;
IntPair p[] = { { 0, 1 }, { 2, 3 } };
IntPair* i = CATCH_GENERATE( between( p, &p[1] ) );
CATCH_REQUIRE( i->first == i->second-1 );
}

View File

@@ -8,6 +8,14 @@
#include "catch.hpp"
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wweak-vtables"
#pragma clang diagnostic ignored "-Wpadded"
#endif
#ifndef CATCH_CONFIG_DISABLE_MATCHERS
inline const char* testStringForMatching()
{
return "this string contains 'abc' as a substring";
@@ -48,16 +56,6 @@ TEST_CASE("Equals string matcher", "[.][failing][matchers]")
CHECK_THAT( testStringForMatching(), Equals( "something else" ) );
}
TEST_CASE("AllOf matcher", "[matchers]")
{
CHECK_THAT( testStringForMatching(), AllOf( Catch::Contains( "string" ), Catch::Contains( "abc" ) ) );
}
TEST_CASE("AnyOf matcher", "[matchers]")
{
CHECK_THAT( testStringForMatching(), AnyOf( Catch::Contains( "string" ), Catch::Contains( "not there" ) ) );
CHECK_THAT( testStringForMatching(), AnyOf( Catch::Contains( "not there" ), Catch::Contains( "string" ) ) );
}
TEST_CASE("Equals", "[matchers]")
{
CHECK_THAT( testStringForMatching(), Equals( "this string contains 'abc' as a substring" ) );
@@ -166,3 +164,68 @@ TEST_CASE( "Vector matchers that fail", "[matchers][vector][.][failing]" ) {
CHECK_THAT( v, Equals( empty ) );
}
}
#ifdef _MSC_VER
#pragma warning(disable:4702) // Unreachable code -- MSVC 19 (VS 2015) sees right through the indirection
#endif
#include <exception>
struct SpecialException : std::exception {
SpecialException(int i_):i(i_) {}
int i;
};
void doesNotThrow() {}
[[noreturn]]
void throws(int i) {
throw SpecialException{ i };
}
[[noreturn]]
void throwsAsInt(int i) {
throw i;
}
class ExceptionMatcher : public Catch::MatcherBase<SpecialException> {
int m_expected;
public:
ExceptionMatcher(int i):m_expected(i) {}
bool match(SpecialException const& se) const override {
return se.i == m_expected;
}
std::string describe() const override {
std::ostringstream ss;
ss << "special exception has value of " << m_expected;
return ss.str();
}
};
TEST_CASE( "Exception matchers that succeed", "[matchers][exceptions][!throws]" ) {
CHECK_THROWS_MATCHES(throws(1), SpecialException, ExceptionMatcher{ 1 });
REQUIRE_THROWS_MATCHES(throws(2), SpecialException, ExceptionMatcher{ 2 });
}
TEST_CASE("Exception matchers that fail", "[matchers][exceptions][!throws][.failing]") {
SECTION("No exception") {
CHECK_THROWS_MATCHES(doesNotThrow(), SpecialException, ExceptionMatcher{ 1 });
REQUIRE_THROWS_MATCHES(doesNotThrow(), SpecialException, ExceptionMatcher{ 1 });
}
SECTION("Type mismatch") {
CHECK_THROWS_MATCHES(throwsAsInt(1), SpecialException, ExceptionMatcher{ 1 });
REQUIRE_THROWS_MATCHES(throwsAsInt(1), SpecialException, ExceptionMatcher{ 1 });
}
SECTION("Contents are wrong") {
CHECK_THROWS_MATCHES(throws(3), SpecialException, ExceptionMatcher{ 1 });
REQUIRE_THROWS_MATCHES(throws(4), SpecialException, ExceptionMatcher{ 1 });
}
}
#endif // CATCH_CONFIG_DISABLE_MATCHERS
#ifdef __clang__
#pragma clang diagnostic pop
#endif

View File

@@ -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,56 +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");
}
#ifdef CATCH_CONFIG_VARIADIC_MACROS
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();
}
#endif
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( "Standard error is reported and redirected", "[messages][.]" ) {
TEST_CASE( "Standard error is reported and redirected", "[messages][.][approvals]" ) {
SECTION( "std::cerr" ) {
std::cerr << "Write to std::cerr" << std::endl;
}
@@ -112,46 +98,40 @@ TEST_CASE( "Standard error is reported and redirected", "[messages][.]" ) {
std::cerr << ' ';
std::clog << "writes";
std::cerr << " to error";
std::clog << " streams\n";
std::clog << " streams" << std::endl;
}
}
TEST_CASE( "SCOPED_INFO is reset for each loop", "[messages][failing][.]" )
{
TEST_CASE( "INFO is reset for each loop", "[messages][failing][.]" ) {
for( int i=0; i<100; i++ )
{
SCOPED_INFO( "current counter " << i );
SCOPED_CAPTURE( i );
INFO( "current counter " << i );
CAPTURE( i );
REQUIRE( i < 10 );
}
}
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][.][approvals]" ) {
int p;
WARN( "actual address of p: " << &p );
WARN( "toString(p): " << Catch::toString( &p ) );
WARN( "toString(p): " << ::Catch::Detail::stringify( &p ) );
}

View File

@@ -13,191 +13,157 @@
# pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
#endif
#include "../include/internal/catch_xmlwriter.hpp"
#include "internal/catch_xmlwriter.h"
#include <iostream>
#include <cerrno>
#include <limits>
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( std::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 )
{
return makeNull ? CATCH_NULL : "valid string";
inline const char* makeString( bool makeNull ) {
return makeNull ? nullptr : "valid string";
}
TEST_CASE( "null strings", "" )
{
REQUIRE( makeString( false ) != static_cast<char*>(CATCH_NULL));
REQUIRE( makeString( true ) == static_cast<char*>(CATCH_NULL));
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]")
{
size_t x = 0;
TEST_CASE( "atomic if", "[failing][0]") {
std::size_t x = 0;
if( x )
REQUIRE(x > 0);
@@ -205,9 +171,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 +183,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 +208,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 +242,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 +250,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( "" );
}
@@ -314,25 +270,25 @@ TEST_CASE( "Tabs and newlines show in output", "[.][whitespace][failing]" ) {
TEST_CASE( "toString on const wchar_t const pointer returns the string contents", "[toString]" ) {
const wchar_t * const s = L"wide load";
std::string result = Catch::toString( s );
std::string result = ::Catch::Detail::stringify( s );
CHECK( result == "\"wide load\"" );
}
TEST_CASE( "toString on const wchar_t pointer returns the string contents", "[toString]" ) {
const wchar_t * s = L"wide load";
std::string result = Catch::toString( s );
std::string result = ::Catch::Detail::stringify( s );
CHECK( result == "\"wide load\"" );
}
TEST_CASE( "toString on wchar_t const pointer returns the string contents", "[toString]" ) {
wchar_t * const s = const_cast<wchar_t* const>( L"wide load" );
std::string result = Catch::toString( s );
std::string result = ::Catch::Detail::stringify( s );
CHECK( result == "\"wide load\"" );
}
TEST_CASE( "toString on wchar_t returns the string contents", "[toString]" ) {
wchar_t * s = const_cast<wchar_t*>( L"wide load" );
std::string result = Catch::toString( s );
std::string result = ::Catch::Detail::stringify( s );
CHECK( result == "\"wide load\"" );
}
@@ -372,13 +328,11 @@ TEST_CASE( "XmlEncode" ) {
}
}
#ifdef CATCH_CONFIG_CPP11_LONG_LONG
TEST_CASE( "long long", "[c++11][.]" ) {
TEST_CASE( "long long" ) {
long long l = std::numeric_limits<long long>::max();
REQUIRE( l == std::numeric_limits<long long>::max() );
}
#endif
//TEST_CASE( "Divide by Zero signal handler", "[.][sig]" ) {
// int i = 0;
@@ -386,8 +340,7 @@ TEST_CASE( "long long", "[c++11][.]" ) {
// 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!" );
}
@@ -400,7 +353,7 @@ static int f() {
return 1;
}
TEST_CASE( "#835 -- errno should not be touched by Catch", "[!shouldfail]" ) {
TEST_CASE( "#835 -- errno should not be touched by Catch", "[.][failing][!shouldfail]" ) {
errno = 1;
CHECK(f() == 0);
REQUIRE(errno == 1); // Check that f() doesn't touch errno.

View File

@@ -6,7 +6,7 @@
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#include "internal/catch_suppress_warnings.h"
#include "internal/catch_test_case_tracker.hpp"
#include "internal/catch_test_case_tracker.h"
namespace Catch
@@ -37,10 +37,10 @@ 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", "" ) {
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() );

View File

@@ -0,0 +1,167 @@
#include "../include/internal/catch_stringref.h"
#include "catch.hpp"
#include <cstring>
namespace Catch {
// Implementation of test accessors
struct StringRefTestAccess {
static auto isOwned( StringRef const& stringRef ) -> bool {
return stringRef.isOwned();
}
static auto isSubstring( StringRef const& stringRef ) -> bool {
return stringRef.isSubstring();
}
static auto data( StringRef const& stringRef ) -> char const* {
return stringRef.data();
}
};
auto isOwned( StringRef const& stringRef ) -> bool {
return StringRefTestAccess::isOwned( stringRef );
}
auto isSubstring( StringRef const& stringRef ) -> bool {
return StringRefTestAccess::isSubstring( stringRef );
}
auto data( StringRef const& stringRef ) -> char const* {
return StringRefTestAccess::data( stringRef );
}
} // namespace Catch2
namespace Catch {
inline auto toString( Catch::StringRef const& stringRef ) -> std::string {
return std::string( data( stringRef ), stringRef.size() );
}
} // namespace Catch
TEST_CASE( "StringRef", "[Strings]" ) {
using Catch::StringRef;
SECTION( "Empty string" ) {
StringRef empty;
REQUIRE( empty.empty() );
REQUIRE( empty.size() == 0 );
REQUIRE( std::strcmp( empty.c_str(), "" ) == 0 );
}
SECTION( "From string literal" ) {
StringRef s = "hello";
REQUIRE( s.empty() == false );
REQUIRE( s.size() == 5 );
REQUIRE( isSubstring( s ) == false );
auto rawChars = data( s );
REQUIRE( std::strcmp( rawChars, "hello" ) == 0 );
SECTION( "c_str() does not cause copy" ) {
REQUIRE( isOwned( s ) == false );
REQUIRE( s.c_str() == rawChars );
REQUIRE( isOwned( s ) == false );
}
}
SECTION( "From sub-string" ) {
StringRef original = StringRef( "original string" ).substr(0, 8);
REQUIRE( original == "original" );
REQUIRE( isSubstring( original ) );
REQUIRE( isOwned( original ) == false );
original.c_str(); // Forces it to take ownership
REQUIRE( isSubstring( original ) == false );
REQUIRE( isOwned( original ) );
}
SECTION( "Substrings" ) {
StringRef s = "hello world!";
StringRef ss = s.substr(0, 5);
SECTION( "zero-based substring" ) {
REQUIRE( ss.empty() == false );
REQUIRE( ss.size() == 5 );
REQUIRE( std::strcmp( ss.c_str(), "hello" ) == 0 );
REQUIRE( ss == "hello" );
}
SECTION( "c_str() causes copy" ) {
REQUIRE( isSubstring( ss ) );
REQUIRE( isOwned( ss ) == false );
auto rawChars = data( ss );
REQUIRE( rawChars == data( s ) ); // same pointer value
REQUIRE( ss.c_str() != rawChars );
REQUIRE( isSubstring( ss ) == false );
REQUIRE( isOwned( ss ) );
REQUIRE( data( ss ) != data( s ) ); // different pointer value
}
SECTION( "non-zero-based substring") {
ss = s.substr( 6, 6 );
REQUIRE( ss.size() == 6 );
REQUIRE( std::strcmp( ss.c_str(), "world!" ) == 0 );
}
SECTION( "Pointer values of full refs should match" ) {
StringRef s2 = s;
REQUIRE( s.c_str() == s2.c_str() );
}
SECTION( "Pointer values of substring refs should not match" ) {
REQUIRE( s.c_str() != ss.c_str() );
}
}
SECTION( "Comparisons" ) {
REQUIRE( StringRef("hello") == StringRef("hello") );
REQUIRE( StringRef("hello") != StringRef("cello") );
}
SECTION( "from std::string" ) {
std::string stdStr = "a standard string";
SECTION( "implicitly constructed" ) {
StringRef sr = stdStr;
REQUIRE( sr == "a standard string" );
REQUIRE( sr.size() == stdStr.size() );
}
SECTION( "explicitly constructed" ) {
StringRef sr( stdStr );
REQUIRE( sr == "a standard string" );
REQUIRE( sr.size() == stdStr.size() );
}
SECTION( "assigned" ) {
StringRef sr;
sr = stdStr;
REQUIRE( sr == "a standard string" );
REQUIRE( sr.size() == stdStr.size() );
}
}
SECTION( "to std::string" ) {
StringRef sr = "a stringref";
SECTION( "implicitly constructed" ) {
std::string stdStr = sr;
REQUIRE( stdStr == "a stringref" );
REQUIRE( stdStr.size() == sr.size() );
}
SECTION( "explicitly constructed" ) {
std::string stdStr( sr );
REQUIRE( stdStr == "a stringref" );
REQUIRE( stdStr.size() == sr.size() );
}
SECTION( "assigned" ) {
std::string stdStr;
stdStr = sr;
REQUIRE( stdStr == "a stringref" );
REQUIRE( stdStr.size() == sr.size() );
}
}
}

View File

@@ -1,3 +0,0 @@
// This file is only here to verify (to the extent possible) the self sufficiency of the header
#include "internal/catch_suppress_warnings.h"
#include "internal/catch_common.h"

View File

@@ -1,3 +1,3 @@
// This file is only here to verify (to the extent possible) the self sufficiency of the header
#include "internal/catch_suppress_warnings.h"
#include "internal/catch_console_colour.hpp"
#include "internal/catch_console_colour.h"

View File

@@ -1,3 +0,0 @@
// This file is only here to verify (to the extent possible) the self sufficiency of the header
#include "internal/catch_suppress_warnings.h"
#include "internal/catch_interfaces_capture.h"

View File

@@ -1,2 +0,0 @@
#include "internal/catch_suppress_warnings.h"
#include "internal/catch_interfaces_config.h"

View File

@@ -1,2 +0,0 @@
#include "internal/catch_suppress_warnings.h"
#include "internal/catch_interfaces_exception.h"

View File

@@ -1 +0,0 @@
#include "internal/catch_interfaces_generators.h"

View File

@@ -1,3 +0,0 @@
// This file is only here to verify (to the extent possible) the self sufficiency of the header
#include "internal/catch_suppress_warnings.h"
#include "internal/catch_interfaces_registry_hub.h"

View File

@@ -1 +0,0 @@
#include "internal/catch_interfaces_runner.h"

View File

@@ -1,2 +0,0 @@
#include "internal/catch_suppress_warnings.h"
#include "internal/catch_interfaces_testcase.h"

View File

@@ -1,3 +0,0 @@
// This file is only here to verify (to the extent possible) the self sufficiency of the header
#include "internal/catch_suppress_warnings.h"
#include "internal/catch_message.h"

View File

@@ -1,3 +0,0 @@
// This file is only here to verify (to the extent possible) the self sufficiency of the header
#include "internal/catch_suppress_warnings.h"
#include "internal/catch_ptr.hpp"

View File

@@ -1,3 +0,0 @@
// This file is only here to verify (to the extent possible) the self sufficiency of the header
#include "internal/catch_suppress_warnings.h"
#include "internal/catch_streambuf.h"

View File

@@ -1,2 +1,2 @@
// This file is only here to verify (to the extent possible) the self sufficiency of the header
#include "internal/catch_test_case_tracker.hpp"
#include "internal/catch_test_case_tracker.h"

View File

@@ -1,3 +1,3 @@
// This file is only here to verify (to the extent possible) the self sufficiency of the header
#include "internal/catch_suppress_warnings.h"
#include "internal/catch_test_spec.hpp"
#include "internal/catch_test_spec.h"

View File

@@ -1,4 +1,4 @@
// This file is only here to verify (to the extent possible) the self sufficiency of the header
#include "internal/catch_suppress_warnings.h"
#include "internal/catch_xmlwriter.hpp"
#include "internal/catch_xmlwriter.h"
#include "internal/catch_reenable_warnings.h"

View File

@@ -9,30 +9,31 @@
#include "catch.hpp"
#include "internal/catch_tag_alias_registry.h"
TEST_CASE( "Tag alias can be registered against tag patterns", "" ) {
using namespace Catch::Matchers;
TEST_CASE( "Tag alias can be registered against tag patterns" ) {
Catch::TagAliasRegistry registry;
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 ) );
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
}
}
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 ) ) );

View File

@@ -24,479 +24,245 @@ CATCH_REGISTER_TAG_ALIAS( "[@tricky]", "[tricky]~[.]" )
# pragma clang diagnostic ignored "-Wc++98-compat"
#endif
struct TestListener : Catch::TestEventListenerBase {
using TestEventListenerBase::TestEventListenerBase; // inherit constructor
};
CATCH_REGISTER_LISTENER( TestListener );
template<size_t size>
void parseIntoConfig( const char * (&argv)[size], Catch::ConfigData& config ) {
Catch::Clara::CommandLine<Catch::ConfigData> parser = Catch::makeCommandLineParser();
parser.parseInto( Catch::Clara::argsToVector( size, argv ), config );
}
template<size_t size>
std::string parseIntoConfigAndReturnError( const char * (&argv)[size], Catch::ConfigData& config ) {
try {
parseIntoConfig( argv, config );
FAIL( "expected exception" );
}
catch( std::exception& ex ) {
return ex.what();
}
return "";
}
inline Catch::TestCase fakeTestCase( const char* name, const char* desc = "" ){ return Catch::makeTestCase( CATCH_NULL, "", name, desc, CATCH_INTERNAL_LINEINFO ); }
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" ) {
Catch::Clara::CommandLine<Catch::ConfigData> parser = Catch::makeCommandLineParser();
CHECK_NOTHROW( parser.parseInto( std::vector<std::string>(), config ) );
CHECK( config.processName == "" );
SECTION("empty args don't cause a crash") {
auto result = cli.parse({""});
CHECK(result);
CHECK(config.processName == "");
}
SECTION( "default - no arguments", "" ) {
const char* argv[] = { "test" };
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
CHECK( config.processName == "test" );
CHECK( config.shouldDebugBreak == false );
CHECK( config.abortAfter == -1 );
CHECK( config.noThrow == false );
CHECK( config.reporterNames.empty() );
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" ) {
const char* argv[] = { "test", "test1" };
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
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" ) ) );
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:", "" ) {
const char* argv[] = { "test", "exclude:test1" };
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
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" ) ) );
Catch::Config cfg(config);
REQUIRE(cfg.testSpec().matches(fakeTestCase("test1")) == false);
REQUIRE(cfg.testSpec().matches(fakeTestCase("alwaysIncluded")));
}
SECTION( "Specify one test case exclusion using ~", "" ) {
const char* argv[] = { "test", "~test1" };
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
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" ) ) );
Catch::Config cfg(config);
REQUIRE(cfg.testSpec().matches(fakeTestCase("test1")) == false);
REQUIRE(cfg.testSpec().matches(fakeTestCase("alwaysIncluded")));
}
}
SECTION( "reporter", "" ) {
SECTION( "-r/console", "" ) {
const char* argv[] = { "test", "-r", "console" };
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
SECTION("reporter") {
SECTION("-r/console") {
CHECK(cli.parse({"test", "-r", "console"}));
REQUIRE( config.reporterNames[0] == "console" );
REQUIRE(config.reporterNames[0] == "console");
}
SECTION( "-r/xml", "" ) {
const char* argv[] = { "test", "-r", "xml" };
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
SECTION("-r/xml") {
CHECK(cli.parse({"test", "-r", "xml"}));
REQUIRE( config.reporterNames[0] == "xml" );
REQUIRE(config.reporterNames[0] == "xml");
}
SECTION( "-r xml and junit", "" ) {
const char* argv[] = { "test", "-r", "xml", "-r", "junit" };
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
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" );
REQUIRE(config.reporterNames.size() == 2);
REQUIRE(config.reporterNames[0] == "xml");
REQUIRE(config.reporterNames[1] == "junit");
}
SECTION( "--reporter/junit", "" ) {
const char* argv[] = { "test", "--reporter", "junit" };
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
SECTION("--reporter/junit") {
CHECK(cli.parse({"test", "--reporter", "junit"}));
REQUIRE( config.reporterNames[0] == "junit" );
REQUIRE(config.reporterNames[0] == "junit");
}
}
SECTION( "debugger", "" ) {
SECTION( "-b", "" ) {
const char* argv[] = { "test", "-b" };
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
REQUIRE( config.shouldDebugBreak == true );
SECTION("debugger") {
SECTION("-b") {
CHECK(cli.parse({"test", "-b"}));
REQUIRE(config.shouldDebugBreak == true);
}
SECTION( "--break", "" ) {
const char* argv[] = { "test", "--break" };
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
SECTION("--break") {
CHECK(cli.parse({"test", "--break"}));
REQUIRE( config.shouldDebugBreak );
REQUIRE(config.shouldDebugBreak);
}
}
SECTION( "abort", "" ) {
SECTION( "-a aborts after first failure", "" ) {
const char* argv[] = { "test", "-a" };
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
REQUIRE( config.abortAfter == 1 );
}
SECTION( "-x 2 aborts after two failures", "" ) {
const char* argv[] = { "test", "-x", "2" };
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
SECTION("abort") {
SECTION("-a aborts after first failure") {
CHECK(cli.parse({"test", "-a"}));
REQUIRE( config.abortAfter == 2 );
REQUIRE(config.abortAfter == 1);
}
SECTION( "-x must be greater than zero", "" ) {
const char* argv[] = { "test", "-x", "0" };
REQUIRE_THAT( parseIntoConfigAndReturnError( argv, config ), Contains( "greater than zero" ) );
SECTION("-x 2 aborts after two failures") {
CHECK(cli.parse({"test", "-x", "2"}));
REQUIRE(config.abortAfter == 2);
}
SECTION( "-x must be numeric", "" ) {
const char* argv[] = { "test", "-x", "oops" };
REQUIRE_THAT( parseIntoConfigAndReturnError( argv, config ), Contains( "-x" ) );
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", "" ) {
const char* argv[] = { "test", "-e" };
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
SECTION("nothrow") {
SECTION("-e") {
CHECK(cli.parse({"test", "-e"}));
REQUIRE( config.noThrow == true );
REQUIRE(config.noThrow);
}
SECTION( "--nothrow", "" ) {
const char* argv[] = { "test", "--nothrow" };
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
SECTION("--nothrow") {
CHECK(cli.parse({"test", "--nothrow"}));
REQUIRE( config.noThrow == true );
REQUIRE(config.noThrow);
}
}
SECTION( "output filename", "" ) {
SECTION( "-o filename", "" ) {
const char* argv[] = { "test", "-o", "filename.ext" };
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
SECTION("output filename") {
SECTION("-o filename") {
CHECK(cli.parse({"test", "-o", "filename.ext"}));
REQUIRE( config.outputFilename == "filename.ext" );
REQUIRE(config.outputFilename == "filename.ext");
}
SECTION( "--out", "" ) {
const char* argv[] = { "test", "--out", "filename.ext" };
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
SECTION("--out") {
CHECK(cli.parse({"test", "--out", "filename.ext"}));
REQUIRE( config.outputFilename == "filename.ext" );
REQUIRE(config.outputFilename == "filename.ext");
}
}
SECTION( "combinations", "" ) {
SECTION( "Single character flags can be combined", "" ) {
const char* argv[] = { "test", "-abe" };
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
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 );
CHECK(config.abortAfter == 1);
CHECK(config.shouldDebugBreak);
CHECK(config.noThrow == true);
}
}
SECTION( "use-colour", "") {
SECTION( "use-colour") {
using Catch::UseColour;
SECTION( "without option", "" ) {
const char* argv[] = { "test" };
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
SECTION( "without option" ) {
CHECK(cli.parse({"test"}));
REQUIRE( config.useColour == UseColour::Auto );
}
SECTION( "auto", "" ) {
const char* argv[] = { "test", "--use-colour", "auto" };
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
SECTION( "auto" ) {
CHECK(cli.parse({"test", "--use-colour", "auto"}));
REQUIRE( config.useColour == UseColour::Auto );
}
SECTION( "yes", "" ) {
const char* argv[] = { "test", "--use-colour", "yes" };
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
SECTION( "yes" ) {
CHECK(cli.parse({"test", "--use-colour", "yes"}));
REQUIRE( config.useColour == UseColour::Yes );
}
SECTION( "no", "" ) {
const char* argv[] = { "test", "--use-colour", "no" };
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
SECTION( "no" ) {
CHECK(cli.parse({"test", "--use-colour", "no"}));
REQUIRE( config.useColour == UseColour::No );
}
SECTION( "error", "" ) {
const char* argv[] = { "test", "--use-colour", "wrong" };
REQUIRE_THROWS_WITH( parseIntoConfig( argv, config ), Contains( "colour mode must be one of" ) );
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( "Long strings can be wrapped", "[wrap]" ) {
using namespace Catch;
SECTION( "plain string", "" ) {
// guide: 123456789012345678
std::string testString = "one two three four";
SECTION( "No wrapping", "" ) {
CHECK( Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString );
CHECK( Text( testString, TextAttributes().setWidth( 18 ) ).toString() == testString );
}
SECTION( "Wrapped once", "" ) {
CHECK( Text( testString, TextAttributes().setWidth( 17 ) ).toString() == "one two three\nfour" );
CHECK( Text( testString, TextAttributes().setWidth( 16 ) ).toString() == "one two three\nfour" );
CHECK( Text( testString, TextAttributes().setWidth( 14 ) ).toString() == "one two three\nfour" );
CHECK( Text( testString, TextAttributes().setWidth( 13 ) ).toString() == "one two three\nfour" );
CHECK( Text( testString, TextAttributes().setWidth( 12 ) ).toString() == "one two\nthree four" );
}
SECTION( "Wrapped twice", "" ) {
CHECK( Text( testString, TextAttributes().setWidth( 9 ) ).toString() == "one two\nthree\nfour" );
CHECK( Text( testString, TextAttributes().setWidth( 8 ) ).toString() == "one two\nthree\nfour" );
CHECK( Text( testString, TextAttributes().setWidth( 7 ) ).toString() == "one two\nthree\nfour" );
}
SECTION( "Wrapped three times", "" ) {
CHECK( Text( testString, TextAttributes().setWidth( 6 ) ).toString() == "one\ntwo\nthree\nfour" );
CHECK( Text( testString, TextAttributes().setWidth( 5 ) ).toString() == "one\ntwo\nthree\nfour" );
}
SECTION( "Short wrap", "" ) {
CHECK( Text( "abcdef", TextAttributes().setWidth( 4 ) ).toString() == "abc-\ndef" );
CHECK( Text( "abcdefg", TextAttributes().setWidth( 4 ) ).toString() == "abc-\ndefg" );
CHECK( Text( "abcdefgh", TextAttributes().setWidth( 4 ) ).toString() == "abc-\ndef-\ngh" );
CHECK( Text( testString, TextAttributes().setWidth( 4 ) ).toString() == "one\ntwo\nthr-\nee\nfour" );
CHECK( Text( testString, TextAttributes().setWidth( 3 ) ).toString() == "one\ntwo\nth-\nree\nfo-\nur" );
}
SECTION( "As container", "" ) {
Text text( testString, TextAttributes().setWidth( 6 ) );
REQUIRE( text.size() == 4 );
CHECK( text[0] == "one" );
CHECK( text[1] == "two" );
CHECK( text[2] == "three" );
CHECK( text[3] == "four" );
}
SECTION( "Indent first line differently", "" ) {
Text text( testString, TextAttributes()
.setWidth( 10 )
.setIndent( 4 )
.setInitialIndent( 1 ) );
CHECK( text.toString() == " one two\n three\n four" );
}
}
SECTION( "With newlines", "" ) {
// guide: 1234567890123456789
std::string testString = "one two\nthree four";
SECTION( "No wrapping" , "" ) {
CHECK( Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString );
CHECK( Text( testString, TextAttributes().setWidth( 18 ) ).toString() == testString );
CHECK( Text( testString, TextAttributes().setWidth( 10 ) ).toString() == testString );
}
SECTION( "Trailing newline" , "" ) {
CHECK( Text( "abcdef\n", TextAttributes().setWidth( 10 ) ).toString() == "abcdef" );
CHECK( Text( "abcdef", TextAttributes().setWidth( 6 ) ).toString() == "abcdef" );
CHECK( Text( "abcdef\n", TextAttributes().setWidth( 6 ) ).toString() == "abcdef" );
CHECK( Text( "abcdef\n", TextAttributes().setWidth( 5 ) ).toString() == "abcd-\nef" );
}
SECTION( "Wrapped once", "" ) {
CHECK( Text( testString, TextAttributes().setWidth( 9 ) ).toString() == "one two\nthree\nfour" );
CHECK( Text( testString, TextAttributes().setWidth( 8 ) ).toString() == "one two\nthree\nfour" );
CHECK( Text( testString, TextAttributes().setWidth( 7 ) ).toString() == "one two\nthree\nfour" );
}
SECTION( "Wrapped twice", "" ) {
CHECK( Text( testString, TextAttributes().setWidth( 6 ) ).toString() == "one\ntwo\nthree\nfour" );
}
}
SECTION( "With wrap-before/ after characters", "" ) {
std::string testString = "one,two(three) <here>";
SECTION( "No wrapping", "" ) {
CHECK( Text( testString, TextAttributes().setWidth( 80 ) ).toString() == testString );
CHECK( Text( testString, TextAttributes().setWidth( 24 ) ).toString() == testString );
}
SECTION( "Wrap before", "" ) {
CHECK( Text( testString, TextAttributes().setWidth( 11 ) ).toString() == "one,two\n(three)\n<here>" );
}
SECTION( "Wrap after", "" ) {
CHECK( Text( testString, TextAttributes().setWidth( 6 ) ).toString() == "one,\ntwo\n(thre-\ne)\n<here>" );
CHECK( Text( testString, TextAttributes().setWidth( 5 ) ).toString() == "one,\ntwo\n(thr-\nee)\n<her-\ne>" );
CHECK( Text( testString, TextAttributes().setWidth( 4 ) ).toString() == "one,\ntwo\n(th-\nree)\n<he-\nre>" );
}
}
}
using namespace Catch;
class ColourString {
public:
struct ColourIndex {
ColourIndex( Colour::Code _colour, std::size_t _fromIndex, std::size_t _toIndex )
: colour( _colour ),
fromIndex( _fromIndex ),
toIndex( _toIndex )
{}
Colour::Code colour;
std::size_t fromIndex;
std::size_t toIndex;
};
ColourString( std::string const& _string )
: string( _string )
{}
ColourString( std::string const& _string, std::vector<ColourIndex> const& _colours )
: string( _string ), colours( _colours )
{}
ColourString& addColour( Colour::Code colour, int _index ) {
colours.push_back( ColourIndex( colour,
resolveRelativeIndex( _index ),
resolveRelativeIndex( _index )+1 ) );
return *this;
}
ColourString& addColour( Colour::Code colour, int _fromIndex, int _toIndex ) {
colours.push_back( ColourIndex( colour,
resolveRelativeIndex(_fromIndex),
resolveLastRelativeIndex( _toIndex ) ) );
return *this;
}
void writeToStream( std::ostream& _stream ) const {
std::size_t last = 0;
for( std::size_t i = 0; i < colours.size(); ++i ) {
ColourIndex const& index = colours[i];
if( index.fromIndex > last )
_stream << string.substr( last, index.fromIndex-last );
{
Colour colourGuard( index.colour );
_stream << string.substr( index.fromIndex, index.toIndex-index.fromIndex );
}
last = index.toIndex;
}
if( last < string.size() )
_stream << string.substr( last );
}
friend std::ostream& operator << ( std::ostream& _stream, ColourString const& _colourString ) {
_colourString.writeToStream( _stream );
return _stream;
}
private:
std::size_t resolveLastRelativeIndex( int _index ) {
std::size_t index = resolveRelativeIndex( _index );
return index == 0 ? string.size() : index;
}
std::size_t resolveRelativeIndex( int _index ) {
return static_cast<std::size_t>( _index >= 0
? _index
: static_cast<int>( string.size() )+_index );
}
std::string string;
std::vector<ColourIndex> colours;
};
TEST_CASE( "replaceInPlace", "" ) {
TEST_CASE( "replaceInPlace" ) {
std::string letters = "abcdefcg";
SECTION( "replace single char" ) {
CHECK( replaceInPlace( letters, "b", "z" ) );
CHECK( Catch::replaceInPlace( letters, "b", "z" ) );
CHECK( letters == "azcdefcg" );
}
SECTION( "replace two chars" ) {
CHECK( replaceInPlace( letters, "c", "z" ) );
CHECK( Catch::replaceInPlace( letters, "c", "z" ) );
CHECK( letters == "abzdefzg" );
}
SECTION( "replace first char" ) {
CHECK( replaceInPlace( letters, "a", "z" ) );
CHECK( Catch::replaceInPlace( letters, "a", "z" ) );
CHECK( letters == "zbcdefcg" );
}
SECTION( "replace last char" ) {
CHECK( replaceInPlace( letters, "g", "z" ) );
CHECK( Catch::replaceInPlace( letters, "g", "z" ) );
CHECK( letters == "abcdefcz" );
}
SECTION( "replace all chars" ) {
CHECK( replaceInPlace( letters, letters, "replaced" ) );
CHECK( Catch::replaceInPlace( letters, letters, "replaced" ) );
CHECK( letters == "replaced" );
}
SECTION( "replace no chars" ) {
CHECK_FALSE( replaceInPlace( letters, "x", "z" ) );
CHECK_FALSE( Catch::replaceInPlace( letters, "x", "z" ) );
CHECK( letters == letters );
}
SECTION( "escape '" ) {
std::string s = "didn't";
CHECK( replaceInPlace( s, "'", "|'" ) );
CHECK( Catch::replaceInPlace( s, "'", "|'" ) );
CHECK( s == "didn|'t" );
}
}
// !TBD: This will be folded into Text class
TEST_CASE( "Strings can be rendered with colour", "[.colour]" ) {
{
ColourString cs( "hello" );
cs .addColour( Colour::Red, 0 )
.addColour( Colour::Green, -1 );
Catch::cout() << cs << std::endl;
}
{
ColourString cs( "hello" );
cs .addColour( Colour::Blue, 1, -2 );
Catch::cout() << cs << std::endl;
}
}
TEST_CASE( "Text can be formatted using the Text class", "" ) {
CHECK( Text( "hi there" ).toString() == "hi there" );
TextAttributes narrow;
narrow.setWidth( 6 );
CHECK( Text( "hi there", narrow ).toString() == "hi\nthere" );
}
TEST_CASE( "Long text is truncated", "[Text][Truncated]" ) {
std::string longLine( 90, '*' );
std::ostringstream oss;
for(int i = 0; i < 600; ++i )
oss << longLine << longLine << "\n";
Text t( oss.str() );
CHECK_THAT( t.toString(), EndsWith( "... message truncated due to excessive size" ) );
}
inline void manuallyRegisteredTestFunction() {
SUCCEED( "was called" );
}
struct AutoTestReg {
AutoTestReg() {
REGISTER_TEST_CASE( manuallyRegisteredTestFunction, "ManuallyRegistered", "" );
REGISTER_TEST_CASE( manuallyRegisteredTestFunction, "ManuallyRegistered" );
}
};
AutoTestReg autoTestReg;
static AutoTestReg autoTestReg;

View File

@@ -0,0 +1,41 @@
#define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER
#include "catch.hpp"
#include <chrono>
#include <cstdint>
TEST_CASE("Stringifying std::chrono::duration helpers", "[toString][chrono]") {
// No literals because we still support c++11
auto hour = std::chrono::hours(1);
auto minute = std::chrono::minutes(1);
auto seconds = std::chrono::seconds(60);
auto micro = std::chrono::microseconds(1);
auto milli = std::chrono::milliseconds(1);
auto nano = std::chrono::nanoseconds(1);
REQUIRE(minute == seconds);
REQUIRE(hour != seconds);
REQUIRE(micro != milli);
REQUIRE(nano != micro);
}
TEST_CASE("Stringifying std::chrono::duration with weird ratios", "[toString][chrono]") {
std::chrono::duration<int64_t, std::ratio<30>> half_minute(1);
std::chrono::duration<int64_t, std::ratio<1, 1000000000000000>> femto_second(1);
REQUIRE(half_minute != femto_second);
}
TEST_CASE("Stringifying std::chrono::time_point<system_clock>", "[toString][chrono]") {
auto now = std::chrono::system_clock::now();
auto later = now + std::chrono::minutes(2);
REQUIRE(now != later);
}
TEST_CASE("Stringifying std::chrono::time_point<Clock>", "[toString][chrono][!nonportable]") {
auto now = std::chrono::high_resolution_clock::now();
auto later = now + std::chrono::minutes(2);
REQUIRE(now != later);
auto now2 = std::chrono::steady_clock::now();
auto later2 = now2 + std::chrono::minutes(2);
REQUIRE(now2 != later2);
}

View File

@@ -1,37 +1,20 @@
#define CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER
#include "catch.hpp"
// === Pair ===
namespace Catch {
// Note: If we put this in the right place in catch_tostring, then
// we can make it an overload of Catch::toString
template<typename T1, typename T2>
struct StringMaker<std::pair<T1,T2> > {
static std::string convert( const std::pair<T1,T2>& pair ) {
std::ostringstream oss;
oss << "{ "
<< toString( pair.first )
<< ", "
<< toString( pair.second )
<< " }";
return oss.str();
}
};
}
TEST_CASE( "std::pair<int,std::string> -> toString", "[toString][pair]" ) {
std::pair<int,std::string> value( 34, "xyzzy" );
REQUIRE( Catch::toString( value ) == "{ 34, \"xyzzy\" }" );
REQUIRE( ::Catch::Detail::stringify( value ) == "{ 34, \"xyzzy\" }" );
}
TEST_CASE( "std::pair<int,const std::string> -> toString", "[toString][pair]" ) {
std::pair<int,const std::string> value( 34, "xyzzy" );
REQUIRE( Catch::toString(value) == "{ 34, \"xyzzy\" }" );
REQUIRE( ::Catch::Detail::stringify(value) == "{ 34, \"xyzzy\" }" );
}
TEST_CASE( "std::vector<std::pair<std::string,int> > -> toString", "[toString][pair]" ) {
std::vector<std::pair<std::string,int> > pr;
pr.push_back( std::make_pair("green", 55 ) );
REQUIRE( Catch::toString( pr ) == "{ { \"green\", 55 } }" );
REQUIRE( ::Catch::Detail::stringify( pr ) == "{ { \"green\", 55 } }" );
}
// This is pretty contrived - I figure if this works, anything will...
@@ -43,5 +26,5 @@ TEST_CASE( "pair<pair<int,const char *,pair<std::string,int> > -> toString", "[t
right_t right( "Ford", 24 );
std::pair<left_t,right_t> pair( left, right );
REQUIRE( Catch::toString( pair ) == "{ { 42, \"Arthur\" }, { \"Ford\", 24 } }" );
REQUIRE( ::Catch::Detail::stringify( pair ) == "{ { 42, \"Arthur\" }, { \"Ford\", 24 } }" );
}

View File

@@ -1,59 +1,47 @@
#define CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER
#include "catch.hpp"
#ifdef CATCH_CPP11_OR_GREATER
#include <tuple>
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc++98-compat"
#endif
TEST_CASE( "tuple<>", "[toString][tuple][c++11][.]" )
TEST_CASE( "tuple<>", "[toString][tuple]" )
{
typedef std::tuple<> type;
CHECK( "{ }" == Catch::toString(type{}) );
CHECK( "{ }" == ::Catch::Detail::stringify(type{}) );
type value {};
CHECK( "{ }" == Catch::toString(value) );
CHECK( "{ }" == ::Catch::Detail::stringify(value) );
}
TEST_CASE( "tuple<int>", "[toString][tuple][c++11][.]" )
TEST_CASE( "tuple<int>", "[toString][tuple]" )
{
typedef std::tuple<int> type;
CHECK( "{ 0 }" == Catch::toString(type{0}) );
CHECK( "{ 0 }" == ::Catch::Detail::stringify(type{0}) );
}
TEST_CASE( "tuple<float,int>", "[toString][tuple][c++11][.]" )
TEST_CASE( "tuple<float,int>", "[toString][tuple]" )
{
typedef std::tuple<float,int> type;
CHECK( "1.2f" == Catch::toString(float(1.2)) );
CHECK( "{ 1.2f, 0 }" == Catch::toString(type{1.2,0}) );
CHECK( "1.2f" == ::Catch::Detail::stringify(float(1.2)) );
CHECK( "{ 1.2f, 0 }" == ::Catch::Detail::stringify(type{1.2f,0}) );
}
TEST_CASE( "tuple<string,string>", "[toString][tuple][c++11][.]" )
TEST_CASE( "tuple<string,string>", "[toString][tuple]" )
{
typedef std::tuple<std::string,std::string> type;
CHECK( "{ \"hello\", \"world\" }" == Catch::toString(type{"hello","world"}) );
CHECK( "{ \"hello\", \"world\" }" == ::Catch::Detail::stringify(type{"hello","world"}) );
}
TEST_CASE( "tuple<tuple<int>,tuple<>,float>", "[toString][tuple][c++11][.]" )
TEST_CASE( "tuple<tuple<int>,tuple<>,float>", "[toString][tuple]" )
{
typedef std::tuple<std::tuple<int>,std::tuple<>,float> type;
type value { std::tuple<int>{42}, {}, 1.2f };
CHECK( "{ { 42 }, { }, 1.2f }" == Catch::toString(value) );
CHECK( "{ { 42 }, { }, 1.2f }" == ::Catch::Detail::stringify(value) );
}
#ifdef CATCH_CONFIG_CPP11_NULLPTR
TEST_CASE( "tuple<nullptr,int,const char *>", "[toString][tuple][c++11][.]" )
TEST_CASE( "tuple<nullptr,int,const char *>", "[toString][tuple]" )
{
typedef std::tuple<std::nullptr_t,int,const char *> type;
type value { nullptr, 42, "Catch me" };
CHECK( "{ nullptr, 42, \"Catch me\" }" == Catch::toString(value) );
CHECK( "{ nullptr, 42, \"Catch me\" }" == ::Catch::Detail::stringify(value) );
}
#endif
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif /* #ifdef CATCH_CPP11_OR_GREATER */

View File

@@ -6,39 +6,35 @@
TEST_CASE( "vector<int> -> toString", "[toString][vector]" )
{
std::vector<int> vv;
REQUIRE( Catch::toString(vv) == "{ }" );
REQUIRE( ::Catch::Detail::stringify(vv) == "{ }" );
vv.push_back( 42 );
REQUIRE( Catch::toString(vv) == "{ 42 }" );
REQUIRE( ::Catch::Detail::stringify(vv) == "{ 42 }" );
vv.push_back( 250 );
REQUIRE( Catch::toString(vv) == "{ 42, 250 }" );
REQUIRE( ::Catch::Detail::stringify(vv) == "{ 42, 250 }" );
}
TEST_CASE( "vector<string> -> toString", "[toString][vector]" )
{
std::vector<std::string> vv;
REQUIRE( Catch::toString(vv) == "{ }" );
REQUIRE( ::Catch::Detail::stringify(vv) == "{ }" );
vv.push_back( "hello" );
REQUIRE( Catch::toString(vv) == "{ \"hello\" }" );
REQUIRE( ::Catch::Detail::stringify(vv) == "{ \"hello\" }" );
vv.push_back( "world" );
REQUIRE( Catch::toString(vv) == "{ \"hello\", \"world\" }" );
REQUIRE( ::Catch::Detail::stringify(vv) == "{ \"hello\", \"world\" }" );
}
#if defined(CATCH_CPP11_OR_GREATER)
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc++98-compat"
#endif
/*
Note: These tests *can* be made to work with C++ < 11, but the
allocator is a lot more work...
*/
namespace {
/* Minimal Allocator */
template<typename T>
struct minimal_allocator {
typedef T value_type;
typedef std::size_t size_type;
using value_type = T;
using size_type = std::size_t;
minimal_allocator() = default;
template <typename U>
minimal_allocator(const minimal_allocator<U>&) {}
T *allocate( size_type n ) {
return static_cast<T *>( ::operator new( n * sizeof(T) ) );
}
@@ -52,26 +48,21 @@ namespace {
};
}
TEST_CASE( "vector<int,allocator> -> toString", "[toString][vector,allocator][c++11][.]" ) {
TEST_CASE( "vector<int,allocator> -> toString", "[toString][vector,allocator]" ) {
std::vector<int,minimal_allocator<int> > vv;
REQUIRE( Catch::toString(vv) == "{ }" );
REQUIRE( ::Catch::Detail::stringify(vv) == "{ }" );
vv.push_back( 42 );
REQUIRE( Catch::toString(vv) == "{ 42 }" );
REQUIRE( ::Catch::Detail::stringify(vv) == "{ 42 }" );
vv.push_back( 250 );
REQUIRE( Catch::toString(vv) == "{ 42, 250 }" );
REQUIRE( ::Catch::Detail::stringify(vv) == "{ 42, 250 }" );
}
TEST_CASE( "vec<vec<string,alloc>> -> toString", "[toString][vector,allocator][c++11][.]" ) {
typedef std::vector<std::string,minimal_allocator<std::string> > inner;
typedef std::vector<inner> vector;
TEST_CASE( "vec<vec<string,alloc>> -> toString", "[toString][vector,allocator]" ) {
using inner = std::vector<std::string, minimal_allocator<std::string>>;
using vector = std::vector<inner>;
vector v;
REQUIRE( Catch::toString(v) == "{ }" );
REQUIRE( ::Catch::Detail::stringify(v) == "{ }" );
v.push_back( inner { "hello" } );
v.push_back( inner { "world" } );
REQUIRE( Catch::toString(v) == "{ { \"hello\" }, { \"world\" } }" );
REQUIRE( ::Catch::Detail::stringify(v) == "{ { \"hello\" }, { \"world\" } }" );
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // CATCH_CPP11_OR_GREATER

View File

@@ -5,17 +5,21 @@
*/
struct has_toString { };
struct has_operator { };
struct has_maker {};
struct has_maker_and_toString {};
struct has_maker_and_operator {};
std::ostream& operator<<(std::ostream& os, const has_operator&) {
os << "operator<<( has_operator )";
return os;
}
std::ostream& operator<<(std::ostream& os, const has_maker_and_operator&) {
os << "operator<<( has_maker_and_operator )";
return os;
}
namespace Catch {
inline std::string toString( const has_toString& ) {
return "toString( has_toString )";
}
inline std::string toString( const has_maker_and_toString& ) {
return "toString( has_maker_and_toString )";
}
template<>
struct StringMaker<has_maker> {
static std::string convert( const has_maker& ) {
@@ -23,49 +27,47 @@ namespace Catch {
}
};
template<>
struct StringMaker<has_maker_and_toString> {
static std::string convert( const has_maker_and_toString& ) {
return "StringMaker<has_maker_and_toString>";
struct StringMaker<has_maker_and_operator> {
static std::string convert( const has_maker_and_operator& ) {
return "StringMaker<has_maker_and_operator>";
}
};
}
// Call the overload
TEST_CASE( "toString( has_toString )", "[toString]" ) {
has_toString item;
REQUIRE( Catch::toString( item ) == "toString( has_toString )" );
// Call the operator
TEST_CASE( "stringify( has_operator )", "[toString]" ) {
has_operator item;
REQUIRE( ::Catch::Detail::stringify( item ) == "operator<<( has_operator )" );
}
// Call the overload
TEST_CASE( "toString( has_maker )", "toString]" ) {
// Call the stringmaker
TEST_CASE( "stringify( has_maker )", "[toString]" ) {
has_maker item;
REQUIRE( Catch::toString( item ) == "StringMaker<has_maker>" );
REQUIRE( ::Catch::Detail::stringify( item ) == "StringMaker<has_maker>" );
}
// Call the overload
TEST_CASE( "toString( has_maker_and_toString )", "[.][toString]" ) {
has_maker_and_toString item;
REQUIRE( Catch::toString( item ) == "toString( has_maker_and_toString )" );
// Call the stringmaker
TEST_CASE( "stringify( has_maker_and_toString )", "[.][toString]" ) {
has_maker_and_operator item;
REQUIRE( ::Catch::Detail::stringify( item ) == "StringMaker<has_maker_and_operator>" );
}
// Vectors...
// Don't run this in approval tests as it is sensitive to two phase lookup differences
TEST_CASE( "toString( vectors<has_toString )", "[.][toString][!nonportable]" ) {
std::vector<has_toString> v(1);
// This invokes template<T> toString which actually gives us '{ ? }'
REQUIRE( Catch::toString( v ) == "{ {?} }" );
std::vector<has_operator> v(1);
REQUIRE( ::Catch::Detail::stringify( v ) == "{ operator<<( has_operator ) }" );
}
TEST_CASE( "toString( vectors<has_maker )", "[toString]" ) {
std::vector<has_maker> v(1);
REQUIRE( Catch::toString( v ) == "{ StringMaker<has_maker> }" );
REQUIRE( ::Catch::Detail::stringify( v ) == "{ StringMaker<has_maker> }" );
}
// Don't run this in approval tests as it is sensitive to two phase lookup differences
TEST_CASE( "toString( vectors<has_maker_and_toString )", "[.][toString][!nonportable]" ) {
std::vector<has_maker_and_toString> v(1);
// Note: This invokes the template<T> toString -> StringMaker
REQUIRE( Catch::toString( v ) == "{ StringMaker<has_maker_and_toString> }" );
std::vector<has_maker_and_operator> v(1);
REQUIRE( ::Catch::Detail::stringify( v ) == "{ StringMaker<has_maker_and_toString> }" );
}

View File

@@ -10,24 +10,20 @@
#pragma clang diagnostic ignored "-Wpadded"
#endif
#ifdef _MSC_VER
#pragma warning (disable : 4702) // Disable unreachable code warning for the last test
// that is triggered when compiling as Win32|Release
#endif
#include <stdio.h>
#include "catch.hpp"
#ifdef __clang__
#pragma clang diagnostic ignored "-Wc++98-compat"
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
#endif
namespace Catch
{
template<>
std::string toString<std::pair<int, int> >( const std::pair<int, int>& value )
{
namespace Catch {
std::string toString( const std::pair<int, int>& value ) {
std::ostringstream oss;
oss << "std::pair( " << value.first << ", " << value.second << " )";
return oss.str();
}
}
@@ -172,14 +168,14 @@ namespace ObjectWithConversions
{
struct Object
{
operator unsigned int() {return 0xc0000000;}
operator unsigned int() const {return 0xc0000000;}
};
///////////////////////////////////////////////////////////////////////////////
TEST_CASE
(
"Operators at different namespace levels not hijacked by Koenig lookup",
"[Tricky]"
"[Tricky][approvals]"
)
{
Object o;
@@ -187,37 +183,18 @@ namespace ObjectWithConversions
}
}
namespace ObjectWithNonConstEqualityOperator
{
struct Test
{
Test( unsigned int v )
: m_value(v)
{}
bool operator==( const Test&rhs )
{
return (m_value == rhs.m_value);
}
bool operator==( const Test&rhs ) const
{
return (m_value != rhs.m_value);
}
unsigned int m_value;
};
TEST_CASE("Demonstrate that a non-const == is not used", "[Tricky]" )
{
Test t( 1 );
REQUIRE( t == 1u );
}
}
namespace EnumBitFieldTests
{
enum Bits {bit0 = 0x0001, bit1 = 0x0002, bit2 = 0x0004, bit3 = 0x0008, bit1and2 = 0x0006,
bit30 = 0x40000000, bit31 = 0x80000000,
bit30and31 = 0xc0000000};
enum Bits : uint32_t {
bit0 = 0x0001,
bit1 = 0x0002,
bit2 = 0x0004,
bit3 = 0x0008,
bit1and2 = bit1 | bit2,
bit30 = 0x40000000,
bit31 = 0x80000000,
bit30and31 = bit30 | bit31
};
TEST_CASE( "Test enum bit values", "[Tricky]" )
{
@@ -236,7 +213,7 @@ struct Obj
TEST_CASE("boolean member", "[Tricky]")
{
Obj obj;
REQUIRE( obj.prop != CATCH_NULL );
REQUIRE( obj.prop != nullptr );
}
// Tests for a problem submitted by Ralph McArdell
@@ -298,8 +275,8 @@ struct Boolable
{
explicit Boolable( bool value ) : m_value( value ) {}
operator Catch::SafeBool::type() const {
return Catch::SafeBool::makeSafe( m_value );
explicit operator bool() const {
return m_value;
}
bool m_value;
@@ -322,15 +299,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() );
}
@@ -345,7 +322,7 @@ struct Awkward
TEST_CASE( "non streamable - with conv. op", "[Tricky]" )
{
Awkward awkward;
std::string s = Catch::toString( awkward );
std::string s = ::Catch::Detail::stringify( awkward );
REQUIRE( s == "7" );
}
@@ -369,7 +346,7 @@ struct S
};
TEST_CASE( "Comparing member function pointers", "[Tricky][member function pointer]" )
TEST_CASE( "Comparing member function pointers", "[Tricky][member function pointer][approvals]" )
{
typedef void (S::*MF)();
MF m = &S::f;
@@ -385,27 +362,88 @@ TEST_CASE( "pointer to class", "[Tricky]" )
REQUIRE( p == 0 );
}
#ifdef CATCH_CONFIG_CPP11_NULLPTR
#include <memory>
TEST_CASE( "null_ptr", "[Tricky][c++11][.]" )
TEST_CASE( "null_ptr", "[Tricky]" )
{
std::unique_ptr<int> ptr;
REQUIRE(ptr.get() == nullptr);
}
#endif
TEST_CASE( "X/level/0/a", "[Tricky]" ) { SUCCEED(""); }
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" );
// This can cause problems as, currently, stdout itself is not redirected - only the cout (and cerr) buffer
printf( "loose text artifact\n" );
}
namespace {
struct constructor_throws {
[[noreturn]] constructor_throws() {
throw 1;
}
};
}
TEST_CASE("Commas in various macros are allowed") {
REQUIRE_THROWS( std::vector<constructor_throws>{constructor_throws{}, constructor_throws{}} );
CHECK_THROWS( std::vector<constructor_throws>{constructor_throws{}, constructor_throws{}} );
REQUIRE_NOTHROW( std::vector<int>{1, 2, 3} == std::vector<int>{1, 2, 3} );
CHECK_NOTHROW( std::vector<int>{1, 2, 3} == std::vector<int>{1, 2, 3} );
REQUIRE(std::vector<int>{1, 2} == std::vector<int>{1, 2});
CHECK( std::vector<int>{1, 2} == std::vector<int>{1, 2} );
REQUIRE_FALSE(std::vector<int>{1, 2} == std::vector<int>{1, 2, 3});
CHECK_FALSE( std::vector<int>{1, 2} == std::vector<int>{1, 2, 3} );
CHECK_NOFAIL( std::vector<int>{1, 2} == std::vector<int>{1, 2} );
CHECKED_IF( std::vector<int>{1, 2} == std::vector<int>{1, 2} ) {
REQUIRE(true);
} CHECKED_ELSE( std::vector<int>{1, 2} == std::vector<int>{1, 2} ) {
CHECK(true);
}
}
TEST_CASE( "null deref", "[.][failing][!nonportable]" ) {
CHECK( false );
int *x = NULL;
*x = 1;
}
TEST_CASE( "non-copyable objects", "[.][failing]" ) {
// Thanks to Agustin Bergé (@k-ballo on the cpplang Slack) for raising this
std::type_info const& ti = typeid(int);
CHECK( ti == typeid(int) );
}
// #925
using signal_t = void (*) (void*);
struct TestClass {
signal_t testMethod_uponComplete_arg = nullptr;
};
namespace utility {
inline static void synchronizing_callback( void * ) { }
}
TEST_CASE("#925: comparing function pointer to function address failed to compile", "[!nonportable]" ) {
TestClass test;
REQUIRE(utility::synchronizing_callback != test.testMethod_uponComplete_arg);
}
TEST_CASE( "Bitfields can be captured (#1027)" ) {
struct Y {
uint32_t v : 1;
};
Y y{ 0 };
REQUIRE( y.v == 0 );
REQUIRE( 0 == y.v );
}
TEST_CASE( "null deref", "[.][failing][!nonportable]" ) {

View File

@@ -8,7 +8,6 @@
#include "catch.hpp"
#ifdef CATCH_CONFIG_VARIADIC_MACROS
TEST_CASE()
{
@@ -28,4 +27,3 @@ TEST_CASE( "Variadic macros", "[variadic][sections]" )
}
}
#endif

View File

@@ -0,0 +1,267 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
4A5C29AA1F715603007CB94C /* catch_objc_impl.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4A5C29A91F715603007CB94C /* catch_objc_impl.mm */; };
4A63D2AC14E3C1A900F615CB /* OCTest.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4A63D2AB14E3C1A900F615CB /* OCTest.1 */; };
4A63D2B314E3C1E600F615CB /* Main.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4A63D2B214E3C1E600F615CB /* Main.mm */; };
4A63D2C014E4544700F615CB /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4A63D2BF14E4544700F615CB /* Foundation.framework */; };
4A63D2C614E454CC00F615CB /* CatchOCTestCase.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4A63D2C214E454CC00F615CB /* CatchOCTestCase.mm */; };
4A63D2C714E454CC00F615CB /* OCTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4A63D2C314E454CC00F615CB /* OCTest.mm */; };
4A63D2C814E454CC00F615CB /* TestObj.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A63D2C514E454CC00F615CB /* TestObj.m */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
4A63D2A314E3C1A900F615CB /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
4A63D2AC14E3C1A900F615CB /* OCTest.1 in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 1;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
4A5C29A91F715603007CB94C /* catch_objc_impl.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = catch_objc_impl.mm; sourceTree = "<group>"; };
4A63D2A514E3C1A900F615CB /* OCTest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = OCTest; sourceTree = BUILT_PRODUCTS_DIR; };
4A63D2AB14E3C1A900F615CB /* OCTest.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = OCTest.1; sourceTree = "<group>"; };
4A63D2B214E3C1E600F615CB /* Main.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Main.mm; sourceTree = "<group>"; };
4A63D2BF14E4544700F615CB /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
4A63D2C114E454CC00F615CB /* CatchOCTestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CatchOCTestCase.h; sourceTree = "<group>"; };
4A63D2C214E454CC00F615CB /* CatchOCTestCase.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CatchOCTestCase.mm; sourceTree = "<group>"; };
4A63D2C314E454CC00F615CB /* OCTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OCTest.mm; sourceTree = "<group>"; };
4A63D2C414E454CC00F615CB /* TestObj.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestObj.h; sourceTree = "<group>"; };
4A63D2C514E454CC00F615CB /* TestObj.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestObj.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
4A63D2A214E3C1A900F615CB /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
4A63D2C014E4544700F615CB /* Foundation.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
4A63D29A14E3C1A900F615CB = {
isa = PBXGroup;
children = (
4AA0D94F154C0A63004B4193 /* Catch */,
4A63D2BF14E4544700F615CB /* Foundation.framework */,
4A63D2A814E3C1A900F615CB /* OCTest */,
4A63D2A614E3C1A900F615CB /* Products */,
);
sourceTree = "<group>";
};
4A63D2A614E3C1A900F615CB /* Products */ = {
isa = PBXGroup;
children = (
4A63D2A514E3C1A900F615CB /* OCTest */,
);
name = Products;
sourceTree = "<group>";
};
4A63D2A814E3C1A900F615CB /* OCTest */ = {
isa = PBXGroup;
children = (
4A63D2C114E454CC00F615CB /* CatchOCTestCase.h */,
4A63D2C214E454CC00F615CB /* CatchOCTestCase.mm */,
4A63D2C314E454CC00F615CB /* OCTest.mm */,
4A63D2C414E454CC00F615CB /* TestObj.h */,
4A63D2C514E454CC00F615CB /* TestObj.m */,
4A63D2B214E3C1E600F615CB /* Main.mm */,
4A63D2AB14E3C1A900F615CB /* OCTest.1 */,
);
path = OCTest;
sourceTree = "<group>";
};
4AA0D94F154C0A63004B4193 /* Catch */ = {
isa = PBXGroup;
children = (
4A5C29A91F715603007CB94C /* catch_objc_impl.mm */,
);
name = Catch;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
4A63D2A414E3C1A900F615CB /* OCTest */ = {
isa = PBXNativeTarget;
buildConfigurationList = 4A63D2AF14E3C1A900F615CB /* Build configuration list for PBXNativeTarget "OCTest" */;
buildPhases = (
4A63D2A114E3C1A900F615CB /* Sources */,
4A63D2A214E3C1A900F615CB /* Frameworks */,
4A63D2A314E3C1A900F615CB /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = OCTest;
productName = OCTest;
productReference = 4A63D2A514E3C1A900F615CB /* OCTest */;
productType = "com.apple.product-type.tool";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
4A63D29C14E3C1A900F615CB /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0500;
};
buildConfigurationList = 4A63D29F14E3C1A900F615CB /* Build configuration list for PBXProject "OCTest" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 4A63D29A14E3C1A900F615CB;
productRefGroup = 4A63D2A614E3C1A900F615CB /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
4A63D2A414E3C1A900F615CB /* OCTest */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
4A63D2A114E3C1A900F615CB /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4A63D2B314E3C1E600F615CB /* Main.mm in Sources */,
4A5C29AA1F715603007CB94C /* catch_objc_impl.mm in Sources */,
4A63D2C614E454CC00F615CB /* CatchOCTestCase.mm in Sources */,
4A63D2C714E454CC00F615CB /* OCTest.mm in Sources */,
4A63D2C814E454CC00F615CB /* TestObj.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
4A63D2AD14E3C1A900F615CB /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = ../../../include;
MACOSX_DEPLOYMENT_TARGET = 10.7;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
name = Debug;
};
4A63D2AE14E3C1A900F615CB /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = ../../../include;
MACOSX_DEPLOYMENT_TARGET = 10.7;
SDKROOT = macosx;
};
name = Release;
};
4A63D2B014E3C1A900F615CB /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
HEADER_SEARCH_PATHS = ../../../include;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
4A63D2B114E3C1A900F615CB /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
HEADER_SEARCH_PATHS = ../../../include;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
4A63D29F14E3C1A900F615CB /* Build configuration list for PBXProject "OCTest" */ = {
isa = XCConfigurationList;
buildConfigurations = (
4A63D2AD14E3C1A900F615CB /* Debug */,
4A63D2AE14E3C1A900F615CB /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
4A63D2AF14E3C1A900F615CB /* Build configuration list for PBXNativeTarget "OCTest" */ = {
isa = XCConfigurationList;
buildConfigurations = (
4A63D2B014E3C1A900F615CB /* Debug */,
4A63D2B114E3C1A900F615CB /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 4A63D29C14E3C1A900F615CB /* Project object */;
}

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:OCTest.xcodeproj">
</FileRef>
</Workspace>

View File

@@ -0,0 +1,25 @@
//
// CatchOCTestCase.h
// OCTest
//
// Created by Phil on 13/11/2010.
// Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
//
// 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)
#ifndef TWOBLUECUBES_CATCHOCTESTCASE_H_INCLUDED
#define TWOBLUECUBES_CATCHOCTESTCASE_H_INCLUDED
#include "catch.hpp"
#import <Cocoa/Cocoa.h>
#import "TestObj.h"
@interface TestFixture : NSObject <OcFixture>
{
TestObj* obj;
}
@end
#endif // TWOBLUECUBES_CATCHOCTESTCASE_H_INCLUDED

View File

@@ -0,0 +1,87 @@
//
// CatchOCTestCase.mm
// OCTest
//
// Created by Phil Nash on 13/11/2010.
// Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
//
// 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)
#import "CatchOCTestCase.h"
@implementation TestFixture
-(void) setUp
{
obj = [[TestObj alloc] init];
}
-(void) tearDown
{
arcSafeRelease( obj );
}
OC_TEST_CASE( "This is a test case", "" )
{
REQUIRE( obj.int_val == 0 );
obj.int_val = 1;
REQUIRE( obj.int_val == 1 );
}
OC_TEST_CASE( "This is another test case", "" )
{
REQUIRE( obj.int_val == 0 );
obj.int_val = 2;
REQUIRE( obj.int_val == 2 );
}
OC_TEST_CASE( "tests a boolean value", "[!shouldfail]" )
{
CHECK( [obj isTrue] == NO );
CHECK( [obj isFalse] == YES );
}
OC_TEST_CASE( "throws an Objective-C exception", "[!throws][!shouldfail]" )
{
@throw [[NSException alloc] initWithName: NSGenericException
reason: @"Objective-C exception"
userInfo: nil];
}
OC_TEST_CASE( "throws a std c++ exception", "[!throws][!shouldfail]" )
{
throw std::domain_error( "std C++ exception" );
}
///////////////////////////////////////////////////////////////////////////
template<typename T>
void useObject( const T& object ){}
template<typename T>
void useObject( const T* object ){}
OC_TEST_CASE( "Matches work with OC types (NSString so far)", "[!shouldfail]" )
{
using namespace Catch::Matchers;
REQUIRE_THAT( @"This is a string", Equals( @"This isnt a string" ) );
REQUIRE_THAT( @"This is a string", Contains( @"is a" ) );
REQUIRE_THAT( @"This is a string", StartsWith( @"This" ) );
REQUIRE_THAT( @"This is a string", EndsWith( @"string" ) );
}
OC_TEST_CASE( "nil NSString should not crash the test", "[!shouldfail]" )
{
using namespace Catch::Matchers;
CHECK_THAT( (NSString*)nil, Equals( @"This should fail, but not crash" ) );
CHECK_THAT( (NSString*)nil, StartsWith( @"anything" ) );
}
@end

View File

@@ -0,0 +1,2 @@
#define CATCH_CONFIG_MAIN
#import "catch.hpp"

View File

@@ -0,0 +1,79 @@
.\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples.
.\"See Also:
.\"man mdoc.samples for a complete listing of options
.\"man mdoc for the short list of editing options
.\"/usr/share/misc/mdoc.template
.Dd 09/02/2012 \" DATE
.Dt OCTest 1 \" Program name and manual section number
.Os Darwin
.Sh NAME \" Section Header - required - don't modify
.Nm OCTest,
.\" The following lines are read in generating the apropos(man -k) database. Use only key
.\" words here as the database is built based on the words here and in the .ND line.
.Nm Other_name_for_same_program(),
.Nm Yet another name for the same program.
.\" Use .Nm macro to designate other names for the documented program.
.Nd This line parsed for whatis database.
.Sh SYNOPSIS \" Section Header - required - don't modify
.Nm
.Op Fl abcd \" [-abcd]
.Op Fl a Ar path \" [-a path]
.Op Ar file \" [file]
.Op Ar \" [file ...]
.Ar arg0 \" Underlined argument - use .Ar anywhere to underline
arg2 ... \" Arguments
.Sh DESCRIPTION \" Section Header - required - don't modify
Use the .Nm macro to refer to your program throughout the man page like such:
.Nm
Underlining is accomplished with the .Ar macro like this:
.Ar underlined text .
.Pp \" Inserts a space
A list of items with descriptions:
.Bl -tag -width -indent \" Begins a tagged list
.It item a \" Each item preceded by .It macro
Description of item a
.It item b
Description of item b
.El \" Ends the list
.Pp
A list of flags and their descriptions:
.Bl -tag -width -indent \" Differs from above in tag removed
.It Fl a \"-a flag as a list item
Description of -a flag
.It Fl b
Description of -b flag
.El \" Ends the list
.Pp
.\" .Sh ENVIRONMENT \" May not be needed
.\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1
.\" .It Ev ENV_VAR_1
.\" Description of ENV_VAR_1
.\" .It Ev ENV_VAR_2
.\" Description of ENV_VAR_2
.\" .El
.Sh FILES \" File used or created by the topic of the man page
.Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact
.It Pa /usr/share/file_name
FILE_1 description
.It Pa /Users/joeuser/Library/really_long_file_name
FILE_2 description
.El \" Ends the list
.\" .Sh DIAGNOSTICS \" May not be needed
.\" .Bl -diag
.\" .It Diagnostic Tag
.\" Diagnostic informtion here.
.\" .It Diagnostic Tag
.\" Diagnostic informtion here.
.\" .El
.Sh SEE ALSO
.\" List links in ascending order by section, alphabetically within a section.
.\" Please do not reference files that do not exist without filing a bug report
.Xr a 1 ,
.Xr b 1 ,
.Xr c 1 ,
.Xr a 2 ,
.Xr b 2 ,
.Xr a 3 ,
.Xr b 3
.\" .Sh BUGS \" Document known, unremedied bugs
.\" .Sh HISTORY \" Document history if command behaves in a unique manner

View File

@@ -0,0 +1,28 @@
/*
* OCTest.mm
* OCTest
*
* Created by Phil on 13/11/2010.
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
*
* 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)
*
*/
#import "catch.hpp"
#import "TestObj.h"
TEST_CASE( "OCTest/TestObj", "tests TestObj" )
{
TestObj* obj = [[TestObj alloc] init];
REQUIRE( obj.int_val == 0 );
obj.int_val = 1;
REQUIRE( obj.int_val == 1 );
arcSafeRelease( obj );
}

View File

@@ -0,0 +1,28 @@
//
// TestObj.h
// OCTest
//
// Created by Phil on 13/11/2010.
// Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
//
// 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)
#ifndef TWOBLUECUBES_TESTOBJ_H_INCLUDED
#define TWOBLUECUBES_TESTOBJ_H_INCLUDED
#import <Foundation/Foundation.h>
@interface TestObj : NSObject {
int int_val;
}
-(BOOL) isTrue;
-(BOOL) isFalse;
@property (nonatomic, assign ) int int_val;
@end
#endif // TWOBLUECUBES_TESTOBJ_H_INCLUDED

View File

@@ -0,0 +1,25 @@
//
// TestObj.m
// OCTest
//
// Created by Phil on 13/11/2010.
// Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
//
// 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)
#import "TestObj.h"
@implementation TestObj
@synthesize int_val;
-(BOOL) isTrue {
return YES;
}
-(BOOL) isFalse {
return NO;
}
@end

View File

@@ -0,0 +1,68 @@
// This file #includes all the .cpp files into a single .mm
// - so they get compiled as ObjectiveC++
#include "../../../include/internal/catch_approx.cpp"
#include "../../../include/internal/catch_assertionhandler.cpp"
#include "../../../include/internal/catch_assertionresult.cpp"
#include "../../../include/internal/catch_benchmark.cpp"
#include "../../../include/internal/catch_capture_matchers.cpp"
#include "../../../include/internal/catch_commandline.cpp"
#include "../../../include/internal/catch_common.cpp"
#include "../../../include/internal/catch_config.cpp"
#include "../../../include/internal/catch_console_colour.cpp"
#include "../../../include/internal/catch_context.cpp"
#include "../../../include/internal/catch_debug_console.cpp"
#include "../../../include/internal/catch_debugger.cpp"
#include "../../../include/internal/catch_decomposer.cpp"
#include "../../../include/internal/catch_errno_guard.cpp"
#include "../../../include/internal/catch_exception_translator_registry.cpp"
#include "../../../include/internal/catch_fatal_condition.cpp"
#include "../../../include/internal/catch_interfaces_capture.cpp"
#include "../../../include/internal/catch_interfaces_config.cpp"
#include "../../../include/internal/catch_interfaces_exception.cpp"
#include "../../../include/internal/catch_interfaces_registry_hub.cpp"
#include "../../../include/internal/catch_interfaces_reporter.cpp"
#include "../../../include/internal/catch_interfaces_runner.cpp"
#include "../../../include/internal/catch_interfaces_testcase.cpp"
#include "../../../include/internal/catch_leak_detector.cpp"
#include "../../../include/internal/catch_list.cpp"
#include "../../../include/internal/catch_matchers.cpp"
#include "../../../include/internal/catch_matchers_string.cpp"
#include "../../../include/internal/catch_message.cpp"
#include "../../../include/internal/catch_random_number_generator.cpp"
#include "../../../include/internal/catch_registry_hub.cpp"
#include "../../../include/internal/catch_reporter_registry.cpp"
#include "../../../include/internal/catch_result_type.cpp"
#include "../../../include/internal/catch_run_context.cpp"
#include "../../../include/internal/catch_section.cpp"
#include "../../../include/internal/catch_section_info.cpp"
#include "../../../include/internal/catch_session.cpp"
#include "../../../include/internal/catch_startup_exception_registry.cpp"
#include "../../../include/internal/catch_stream.cpp"
#include "../../../include/internal/catch_streambuf.cpp"
#include "../../../include/internal/catch_string_manip.cpp"
#include "../../../include/internal/catch_stringref.cpp"
#include "../../../include/internal/catch_tag_alias.cpp"
#include "../../../include/internal/catch_tag_alias_autoregistrar.cpp"
#include "../../../include/internal/catch_tag_alias_registry.cpp"
#include "../../../include/internal/catch_test_case_info.cpp"
#include "../../../include/internal/catch_test_case_registry_impl.cpp"
#include "../../../include/internal/catch_test_case_tracker.cpp"
#include "../../../include/internal/catch_test_registry.cpp"
#include "../../../include/internal/catch_test_spec.cpp"
#include "../../../include/internal/catch_test_spec_parser.cpp"
#include "../../../include/internal/catch_timer.cpp"
#include "../../../include/internal/catch_tostring.cpp"
#include "../../../include/internal/catch_totals.cpp"
#include "../../../include/internal/catch_version.cpp"
#include "../../../include/internal/catch_wildcard_pattern.cpp"
#include "../../../include/internal/catch_xmlwriter.cpp"
// Reporters
#include "../../../include/reporters/catch_reporter_bases.cpp"
#include "../../../include/reporters/catch_reporter_compact.cpp"
#include "../../../include/reporters/catch_reporter_console.cpp"
#include "../../../include/reporters/catch_reporter_junit.cpp"
#include "../../../include/reporters/catch_reporter_multi.cpp"
#include "../../../include/reporters/catch_reporter_xml.cpp"