mirror of
https://github.com/catchorg/Catch2.git
synced 2025-09-11 16:05:40 +02:00
Compare commits
24 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e27c4ee042 | ||
![]() |
072114293b | ||
![]() |
f90ee9fb37 | ||
![]() |
c17ba0870a | ||
![]() |
79f01100e3 | ||
![]() |
ccf7f2842a | ||
![]() |
e0302db4a6 | ||
![]() |
88732e85b2 | ||
![]() |
1c9a6cab88 | ||
![]() |
40f6068d52 | ||
![]() |
21cbfc107e | ||
![]() |
31861bbd46 | ||
![]() |
b1eeec7c69 | ||
![]() |
c23b374f3d | ||
![]() |
916317bd81 | ||
![]() |
8c459dd207 | ||
![]() |
fd7d35464b | ||
![]() |
c47c1797d2 | ||
![]() |
f5d2b2dce8 | ||
![]() |
02c7e41c7c | ||
![]() |
5095619955 | ||
![]() |
35f510545d | ||
![]() |
742457cbcf | ||
![]() |
1aa6c91e64 |
12
.travis.yml
12
.travis.yml
@@ -119,23 +119,22 @@ matrix:
|
|||||||
|
|
||||||
# 3/ OSX Clang Builds
|
# 3/ OSX Clang Builds
|
||||||
- os: osx
|
- os: osx
|
||||||
osx_image: xcode6.4
|
osx_image: xcode7
|
||||||
compiler: clang
|
compiler: clang
|
||||||
env: COMPILER='ccache clang++' BUILD_TYPE='Debug'
|
env: COMPILER='ccache clang++' BUILD_TYPE='Debug'
|
||||||
|
|
||||||
- os: osx
|
- os: osx
|
||||||
osx_image: xcode6.4
|
osx_image: xcode7
|
||||||
compiler: clang
|
compiler: clang
|
||||||
env: COMPILER='ccache clang++' BUILD_TYPE='Release'
|
env: COMPILER='ccache clang++' BUILD_TYPE='Release'
|
||||||
|
|
||||||
|
|
||||||
- os: osx
|
- os: osx
|
||||||
osx_image: xcode7
|
osx_image: xcode8
|
||||||
compiler: clang
|
compiler: clang
|
||||||
env: COMPILER='ccache clang++' BUILD_TYPE='Debug'
|
env: COMPILER='ccache clang++' BUILD_TYPE='Debug'
|
||||||
|
|
||||||
- os: osx
|
- os: osx
|
||||||
osx_image: xcode7
|
osx_image: xcode8
|
||||||
compiler: clang
|
compiler: clang
|
||||||
env: COMPILER='ccache clang++' BUILD_TYPE='Release'
|
env: COMPILER='ccache clang++' BUILD_TYPE='Release'
|
||||||
|
|
||||||
@@ -149,7 +148,8 @@ install:
|
|||||||
mkdir cmake && travis_retry wget --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C cmake
|
mkdir cmake && travis_retry wget --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C cmake
|
||||||
export PATH=${DEPS_DIR}/cmake/bin:${PATH}
|
export PATH=${DEPS_DIR}/cmake/bin:${PATH}
|
||||||
elif [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
|
elif [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
|
||||||
brew install cmake ccache
|
which cmake || brew install cmake
|
||||||
|
which ccache || brew install ccache
|
||||||
fi
|
fi
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||

|

|
||||||
|
|
||||||
*v1.5.5*
|
*v1.5.8*
|
||||||
|
|
||||||
Build status (on Travis CI) [](https://travis-ci.org/philsquared/Catch)
|
Build status (on Travis CI) [](https://travis-ci.org/philsquared/Catch)
|
||||||
|
|
||||||
|
4
include/external/clara.h
vendored
4
include/external/clara.h
vendored
@@ -589,7 +589,7 @@ namespace Clara {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Mode handleOpt( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
|
Mode handleOpt( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
|
||||||
if( std::string( ":=\0", 5 ).find( c ) == std::string::npos )
|
if( std::string( ":=\0", 3 ).find( c ) == std::string::npos )
|
||||||
return mode;
|
return mode;
|
||||||
|
|
||||||
std::string optName = arg.substr( from, i-from );
|
std::string optName = arg.substr( from, i-from );
|
||||||
@@ -603,7 +603,7 @@ namespace Clara {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
Mode handlePositional( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
|
Mode handlePositional( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
|
||||||
if( inQuotes || std::string( "\0", 3 ).find( c ) == std::string::npos )
|
if( inQuotes || std::string( "\0", 1 ).find( c ) == std::string::npos )
|
||||||
return mode;
|
return mode;
|
||||||
|
|
||||||
std::string data = arg.substr( from, i-from );
|
std::string data = arg.substr( from, i-from );
|
||||||
|
@@ -85,8 +85,11 @@ namespace Catch {
|
|||||||
std::string line;
|
std::string line;
|
||||||
while( std::getline( f, line ) ) {
|
while( std::getline( f, line ) ) {
|
||||||
line = trim(line);
|
line = trim(line);
|
||||||
if( !line.empty() && !startsWith( line, "#" ) )
|
if( !line.empty() && !startsWith( line, "#" ) ) {
|
||||||
addTestOrTags( config, "\"" + line + "\"," );
|
if( !startsWith( line, "\"" ) )
|
||||||
|
line = "\"" + line + "\"";
|
||||||
|
addTestOrTags( config, line + "," );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,8 +21,11 @@ namespace Catch {
|
|||||||
bool contains( std::string const& s, std::string const& infix ) {
|
bool contains( std::string const& s, std::string const& infix ) {
|
||||||
return s.find( infix ) != std::string::npos;
|
return s.find( infix ) != std::string::npos;
|
||||||
}
|
}
|
||||||
|
char toLowerCh(char c) {
|
||||||
|
return static_cast<char>( ::tolower( c ) );
|
||||||
|
}
|
||||||
void toLowerInPlace( std::string& s ) {
|
void toLowerInPlace( std::string& s ) {
|
||||||
std::transform( s.begin(), s.end(), s.begin(), ::tolower );
|
std::transform( s.begin(), s.end(), s.begin(), toLowerCh );
|
||||||
}
|
}
|
||||||
std::string toLower( std::string const& s ) {
|
std::string toLower( std::string const& s ) {
|
||||||
std::string lc = s;
|
std::string lc = s;
|
||||||
|
@@ -68,7 +68,10 @@ namespace Catch {
|
|||||||
++it ) {
|
++it ) {
|
||||||
matchedTests++;
|
matchedTests++;
|
||||||
TestCaseInfo const& testCaseInfo = it->getTestCaseInfo();
|
TestCaseInfo const& testCaseInfo = it->getTestCaseInfo();
|
||||||
Catch::cout() << testCaseInfo.name << std::endl;
|
if( startsWith( testCaseInfo.name, "#" ) )
|
||||||
|
Catch::cout() << "\"" << testCaseInfo.name << "\"" << std::endl;
|
||||||
|
else
|
||||||
|
Catch::cout() << testCaseInfo.name << std::endl;
|
||||||
}
|
}
|
||||||
return matchedTests;
|
return matchedTests;
|
||||||
}
|
}
|
||||||
|
@@ -24,9 +24,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
struct RandomNumberGenerator {
|
struct RandomNumberGenerator {
|
||||||
typedef int result_type;
|
typedef std::ptrdiff_t result_type;
|
||||||
|
|
||||||
result_type operator()( result_type n ) const { return std::rand() % n; }
|
result_type operator()( result_type n ) const { return std::rand() % n; }
|
||||||
|
|
||||||
@@ -37,10 +37,11 @@ namespace Catch {
|
|||||||
#endif
|
#endif
|
||||||
template<typename V>
|
template<typename V>
|
||||||
static void shuffle( V& vector ) {
|
static void shuffle( V& vector ) {
|
||||||
|
RandomNumberGenerator rng;
|
||||||
#ifdef CATCH_CPP14_OR_GREATER
|
#ifdef CATCH_CPP14_OR_GREATER
|
||||||
std::shuffle( vector.begin(), vector.end(), RandomNumberGenerator() );
|
std::shuffle( vector.begin(), vector.end(), rng );
|
||||||
#else
|
#else
|
||||||
std::random_shuffle( vector.begin(), vector.end(), RandomNumberGenerator() );
|
std::random_shuffle( vector.begin(), vector.end(), rng );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -64,10 +64,11 @@ namespace Catch {
|
|||||||
|
|
||||||
bool matches( TestCaseInfo const& testCase ) const {
|
bool matches( TestCaseInfo const& testCase ) const {
|
||||||
// All patterns in a filter must match for the filter to be a match
|
// All patterns in a filter must match for the filter to be a match
|
||||||
for( std::vector<Ptr<Pattern> >::const_iterator it = m_patterns.begin(), itEnd = m_patterns.end(); it != itEnd; ++it )
|
for( std::vector<Ptr<Pattern> >::const_iterator it = m_patterns.begin(), itEnd = m_patterns.end(); it != itEnd; ++it ) {
|
||||||
if( !(*it)->matches( testCase ) )
|
if( !(*it)->matches( testCase ) )
|
||||||
return false;
|
return false;
|
||||||
return true;
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -37,7 +37,7 @@ namespace Catch {
|
|||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
Version libraryVersion( 1, 5, 5, "", 0 );
|
Version libraryVersion( 1, 5, 8, "", 0 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -55,9 +55,10 @@ namespace Catch {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Escape control chars - based on contribution by @espenalb in PR #465
|
// Escape control chars - based on contribution by @espenalb in PR #465 and
|
||||||
|
// by @mrpi PR #588
|
||||||
if ( ( c < '\x09' ) || ( c > '\x0D' && c < '\x20') || c=='\x7F' )
|
if ( ( c < '\x09' ) || ( c > '\x0D' && c < '\x20') || c=='\x7F' )
|
||||||
os << "&#x" << std::uppercase << std::hex << static_cast<int>( c );
|
os << "&#x" << std::uppercase << std::hex << std::setfill('0') << std::setw(2) << static_cast<int>( c ) << ';';
|
||||||
else
|
else
|
||||||
os << c;
|
os << c;
|
||||||
}
|
}
|
||||||
@@ -112,13 +113,20 @@ namespace Catch {
|
|||||||
: m_tagIsOpen( false ),
|
: m_tagIsOpen( false ),
|
||||||
m_needsNewline( false ),
|
m_needsNewline( false ),
|
||||||
m_os( &Catch::cout() )
|
m_os( &Catch::cout() )
|
||||||
{}
|
{
|
||||||
|
// We encode control characters, which requires
|
||||||
|
// XML 1.1
|
||||||
|
// see http://stackoverflow.com/questions/404107/why-are-control-characters-illegal-in-xml-1-0
|
||||||
|
*m_os << "<?xml version=\"1.1\" encoding=\"UTF-8\"?>\n";
|
||||||
|
}
|
||||||
|
|
||||||
XmlWriter( std::ostream& os )
|
XmlWriter( std::ostream& os )
|
||||||
: m_tagIsOpen( false ),
|
: m_tagIsOpen( false ),
|
||||||
m_needsNewline( false ),
|
m_needsNewline( false ),
|
||||||
m_os( &os )
|
m_os( &os )
|
||||||
{}
|
{
|
||||||
|
*m_os << "<?xml version=\"1.1\" encoding=\"UTF-8\"?>\n";
|
||||||
|
}
|
||||||
|
|
||||||
~XmlWriter() {
|
~XmlWriter() {
|
||||||
while( !m_tags.empty() )
|
while( !m_tags.empty() )
|
||||||
|
@@ -53,7 +53,7 @@ namespace Catch {
|
|||||||
|
|
||||||
virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
|
virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::testCaseStarting(testInfo);
|
StreamingReporterBase::testCaseStarting(testInfo);
|
||||||
m_xml.startElement( "TestCase" ).writeAttribute( "name", trim( testInfo.name ) );
|
m_xml.startElement( "TestCase" ).writeAttribute( "name", testInfo.name );
|
||||||
|
|
||||||
if ( m_config->showDurations() == ShowDurations::Always )
|
if ( m_config->showDurations() == ShowDurations::Always )
|
||||||
m_testCaseTimer.start();
|
m_testCaseTimer.start();
|
||||||
@@ -115,7 +115,7 @@ namespace Catch {
|
|||||||
.writeText( assertionResult.getMessage() );
|
.writeText( assertionResult.getMessage() );
|
||||||
break;
|
break;
|
||||||
case ResultWas::FatalErrorCondition:
|
case ResultWas::FatalErrorCondition:
|
||||||
m_xml.scopedElement( "Fatal Error Condition" )
|
m_xml.scopedElement( "FatalErrorCondition" )
|
||||||
.writeAttribute( "filename", assertionResult.getSourceInfo().file )
|
.writeAttribute( "filename", assertionResult.getSourceInfo().file )
|
||||||
.writeAttribute( "line", assertionResult.getSourceInfo().line )
|
.writeAttribute( "line", assertionResult.getSourceInfo().line )
|
||||||
.writeText( assertionResult.getMessage() );
|
.writeText( assertionResult.getMessage() );
|
||||||
|
@@ -830,6 +830,6 @@ with expansion:
|
|||||||
"first" == "second"
|
"first" == "second"
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
test cases: 168 | 124 passed | 42 failed | 2 failed as expected
|
test cases: 169 | 125 passed | 42 failed | 2 failed as expected
|
||||||
assertions: 920 | 824 passed | 78 failed | 18 failed as expected
|
assertions: 921 | 825 passed | 78 failed | 18 failed as expected
|
||||||
|
|
||||||
|
@@ -3920,9 +3920,9 @@ MiscTests.cpp:<line number>
|
|||||||
|
|
||||||
MiscTests.cpp:<line number>:
|
MiscTests.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
REQUIRE( encode( "[\x01]" ) == "[]" )
|
REQUIRE( encode( "[\x01]" ) == "[]" )
|
||||||
with expansion:
|
with expansion:
|
||||||
"[]" == "[]"
|
"[]" == "[]"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
XmlEncode
|
XmlEncode
|
||||||
@@ -3933,9 +3933,9 @@ MiscTests.cpp:<line number>
|
|||||||
|
|
||||||
MiscTests.cpp:<line number>:
|
MiscTests.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
REQUIRE( encode( "[\x7F]" ) == "[]" )
|
REQUIRE( encode( "[\x7F]" ) == "[]" )
|
||||||
with expansion:
|
with expansion:
|
||||||
"[]" == "[]"
|
"[]" == "[]"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
long long
|
long long
|
||||||
@@ -3962,6 +3962,17 @@ PASSED:
|
|||||||
with message:
|
with message:
|
||||||
oops!
|
oops!
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
# A test name that starts with a #
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
with message:
|
||||||
|
yay
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Process can be configured on command line
|
Process can be configured on command line
|
||||||
default - no arguments
|
default - no arguments
|
||||||
@@ -9104,6 +9115,6 @@ with expansion:
|
|||||||
1 > 0
|
1 > 0
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
test cases: 168 | 123 passed | 43 failed | 2 failed as expected
|
test cases: 169 | 124 passed | 43 failed | 2 failed as expected
|
||||||
assertions: 922 | 824 passed | 80 failed | 18 failed as expected
|
assertions: 923 | 825 passed | 80 failed | 18 failed as expected
|
||||||
|
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8"?>
|
||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="CatchSelfTest" errors="13" failures="68" tests="923" hostname="tbd" time="{duration}" timestamp="tbd">
|
<testsuite name="CatchSelfTest" errors="13" failures="68" tests="924" hostname="tbd" time="{duration}" timestamp="tbd">
|
||||||
<testcase classname="global" name="toString(enum)" time="{duration}"/>
|
<testcase classname="global" name="toString(enum)" time="{duration}"/>
|
||||||
<testcase classname="global" name="toString(enum w/operator<<)" time="{duration}"/>
|
<testcase classname="global" name="toString(enum w/operator<<)" time="{duration}"/>
|
||||||
<testcase classname="global" name="toString(enum class)" time="{duration}"/>
|
<testcase classname="global" name="toString(enum class)" time="{duration}"/>
|
||||||
@@ -500,6 +501,7 @@ MiscTests.cpp:<line number>
|
|||||||
<testcase classname="XmlEncode" name="string with control char (x7F)" time="{duration}"/>
|
<testcase classname="XmlEncode" name="string with control char (x7F)" time="{duration}"/>
|
||||||
<testcase classname="global" name="long long" time="{duration}"/>
|
<testcase classname="global" name="long long" time="{duration}"/>
|
||||||
<testcase classname="global" name="This test 'should' fail but doesn't" time="{duration}"/>
|
<testcase classname="global" name="This test 'should' fail but doesn't" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="# A test name that starts with a #" 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="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/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 exclude:" time="{duration}"/>
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8"?>
|
||||||
<Catch name="CatchSelfTest">
|
<Catch name="CatchSelfTest">
|
||||||
<Group name="CatchSelfTest">
|
<Group name="CatchSelfTest">
|
||||||
<TestCase name="toString(enum)">
|
<TestCase name="toString(enum)">
|
||||||
@@ -4051,10 +4052,10 @@
|
|||||||
<Section name="string with control char (1)">
|
<Section name="string with control char (1)">
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/MiscTests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/MiscTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
encode( "[\x01]" ) == "[&#x1]"
|
encode( "[\x01]" ) == "[&#x01;]"
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
"[&#x1]" == "[&#x1]"
|
"[&#x01;]" == "[&#x01;]"
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</Expression>
|
||||||
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
||||||
@@ -4062,10 +4063,10 @@
|
|||||||
<Section name="string with control char (x7F)">
|
<Section name="string with control char (x7F)">
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/MiscTests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/MiscTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
encode( "[\x7F]" ) == "[&#x7F]"
|
encode( "[\x7F]" ) == "[&#x7F;]"
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
"[&#x7F]" == "[&#x7F]"
|
"[&#x7F;]" == "[&#x7F;]"
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</Expression>
|
||||||
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
||||||
@@ -4088,6 +4089,9 @@
|
|||||||
<TestCase name="This test 'should' fail but doesn't">
|
<TestCase name="This test 'should' fail but doesn't">
|
||||||
<OverallResult success="false"/>
|
<OverallResult success="false"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
|
<TestCase name="# A test name that starts with a #">
|
||||||
|
<OverallResult success="true"/>
|
||||||
|
</TestCase>
|
||||||
<TestCase name="Process can be configured on command line">
|
<TestCase name="Process can be configured on command line">
|
||||||
<Section name="default - no arguments">
|
<Section name="default - no arguments">
|
||||||
<Expression success="true" type="CHECK_NOTHROW" filename="projects/SelfTest/TestMain.cpp" >
|
<Expression success="true" type="CHECK_NOTHROW" filename="projects/SelfTest/TestMain.cpp" >
|
||||||
@@ -9566,7 +9570,7 @@ there"
|
|||||||
</Section>
|
</Section>
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<OverallResults successes="824" failures="81" expectedFailures="18"/>
|
<OverallResults successes="825" failures="81" expectedFailures="18"/>
|
||||||
</Group>
|
</Group>
|
||||||
<OverallResults successes="824" failures="80" expectedFailures="18"/>
|
<OverallResults successes="825" failures="80" expectedFailures="18"/>
|
||||||
</Catch>
|
</Catch>
|
||||||
|
@@ -406,27 +406,27 @@ TEST_CASE( "Tabs and newlines show in output", "[.][whitespace][failing]" ) {
|
|||||||
|
|
||||||
|
|
||||||
TEST_CASE( "toString on const wchar_t const pointer returns the string contents", "[toString]" ) {
|
TEST_CASE( "toString on const wchar_t const pointer returns the string contents", "[toString]" ) {
|
||||||
const wchar_t * const s = L"wide load";
|
const wchar_t * const s = L"wide load";
|
||||||
std::string result = Catch::toString( s );
|
std::string result = Catch::toString( s );
|
||||||
CHECK( result == "\"wide load\"" );
|
CHECK( result == "\"wide load\"" );
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE( "toString on const wchar_t pointer returns the string contents", "[toString]" ) {
|
TEST_CASE( "toString on const wchar_t pointer returns the string contents", "[toString]" ) {
|
||||||
const wchar_t * s = L"wide load";
|
const wchar_t * s = L"wide load";
|
||||||
std::string result = Catch::toString( s );
|
std::string result = Catch::toString( s );
|
||||||
CHECK( result == "\"wide load\"" );
|
CHECK( result == "\"wide load\"" );
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE( "toString on wchar_t const pointer returns the string contents", "[toString]" ) {
|
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" );
|
wchar_t * const s = const_cast<wchar_t* const>( L"wide load" );
|
||||||
std::string result = Catch::toString( s );
|
std::string result = Catch::toString( s );
|
||||||
CHECK( result == "\"wide load\"" );
|
CHECK( result == "\"wide load\"" );
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE( "toString on wchar_t returns the string contents", "[toString]" ) {
|
TEST_CASE( "toString on wchar_t returns the string contents", "[toString]" ) {
|
||||||
wchar_t * s = const_cast<wchar_t*>( L"wide load" );
|
wchar_t * s = const_cast<wchar_t*>( L"wide load" );
|
||||||
std::string result = Catch::toString( s );
|
std::string result = Catch::toString( s );
|
||||||
CHECK( result == "\"wide load\"" );
|
CHECK( result == "\"wide load\"" );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string encode( std::string const& str, Catch::XmlEncode::ForWhat forWhat = Catch::XmlEncode::ForTextNodes ) {
|
inline std::string encode( std::string const& str, Catch::XmlEncode::ForWhat forWhat = Catch::XmlEncode::ForTextNodes ) {
|
||||||
@@ -458,10 +458,10 @@ TEST_CASE( "XmlEncode" ) {
|
|||||||
REQUIRE( encode( stringWithQuotes, Catch::XmlEncode::ForAttributes ) == "don't "quote" me on that" );
|
REQUIRE( encode( stringWithQuotes, Catch::XmlEncode::ForAttributes ) == "don't "quote" me on that" );
|
||||||
}
|
}
|
||||||
SECTION( "string with control char (1)" ) {
|
SECTION( "string with control char (1)" ) {
|
||||||
REQUIRE( encode( "[\x01]" ) == "[]" );
|
REQUIRE( encode( "[\x01]" ) == "[]" );
|
||||||
}
|
}
|
||||||
SECTION( "string with control char (x7F)" ) {
|
SECTION( "string with control char (x7F)" ) {
|
||||||
REQUIRE( encode( "[\x7F]" ) == "[]" );
|
REQUIRE( encode( "[\x7F]" ) == "[]" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -483,3 +483,7 @@ TEST_CASE( "This test 'should' fail but doesn't", "[.][failing][!shouldfail]" )
|
|||||||
{
|
{
|
||||||
SUCCEED( "oops!" );
|
SUCCEED( "oops!" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "# A test name that starts with a #" ) {
|
||||||
|
SUCCEED( "yay" );
|
||||||
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Catch v1.5.5
|
* Catch v1.5.8
|
||||||
* Generated: 2016-06-09 08:17:50.409622
|
* Generated: 2016-10-26 12:07:30.938259
|
||||||
* ----------------------------------------------------------
|
* ----------------------------------------------------------
|
||||||
* This file has been merged from multiple headers. Please don't edit it directly
|
* This file has been merged from multiple headers. Please don't edit it directly
|
||||||
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
|
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
|
||||||
@@ -3223,10 +3223,11 @@ namespace Catch {
|
|||||||
|
|
||||||
bool matches( TestCaseInfo const& testCase ) const {
|
bool matches( TestCaseInfo const& testCase ) const {
|
||||||
// All patterns in a filter must match for the filter to be a match
|
// All patterns in a filter must match for the filter to be a match
|
||||||
for( std::vector<Ptr<Pattern> >::const_iterator it = m_patterns.begin(), itEnd = m_patterns.end(); it != itEnd; ++it )
|
for( std::vector<Ptr<Pattern> >::const_iterator it = m_patterns.begin(), itEnd = m_patterns.end(); it != itEnd; ++it ) {
|
||||||
if( !(*it)->matches( testCase ) )
|
if( !(*it)->matches( testCase ) )
|
||||||
return false;
|
return false;
|
||||||
return true;
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -4185,7 +4186,7 @@ namespace Clara {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Mode handleOpt( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
|
Mode handleOpt( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
|
||||||
if( std::string( ":=\0", 5 ).find( c ) == std::string::npos )
|
if( std::string( ":=\0", 3 ).find( c ) == std::string::npos )
|
||||||
return mode;
|
return mode;
|
||||||
|
|
||||||
std::string optName = arg.substr( from, i-from );
|
std::string optName = arg.substr( from, i-from );
|
||||||
@@ -4199,7 +4200,7 @@ namespace Clara {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
Mode handlePositional( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
|
Mode handlePositional( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
|
||||||
if( inQuotes || std::string( "\0", 3 ).find( c ) == std::string::npos )
|
if( inQuotes || std::string( "\0", 1 ).find( c ) == std::string::npos )
|
||||||
return mode;
|
return mode;
|
||||||
|
|
||||||
std::string data = arg.substr( from, i-from );
|
std::string data = arg.substr( from, i-from );
|
||||||
@@ -4719,8 +4720,11 @@ namespace Catch {
|
|||||||
std::string line;
|
std::string line;
|
||||||
while( std::getline( f, line ) ) {
|
while( std::getline( f, line ) ) {
|
||||||
line = trim(line);
|
line = trim(line);
|
||||||
if( !line.empty() && !startsWith( line, "#" ) )
|
if( !line.empty() && !startsWith( line, "#" ) ) {
|
||||||
addTestOrTags( config, "\"" + line + "\"," );
|
if( !startsWith( line, "\"" ) )
|
||||||
|
line = "\"" + line + "\"";
|
||||||
|
addTestOrTags( config, line + "," );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5368,7 +5372,10 @@ namespace Catch {
|
|||||||
++it ) {
|
++it ) {
|
||||||
matchedTests++;
|
matchedTests++;
|
||||||
TestCaseInfo const& testCaseInfo = it->getTestCaseInfo();
|
TestCaseInfo const& testCaseInfo = it->getTestCaseInfo();
|
||||||
Catch::cout() << testCaseInfo.name << std::endl;
|
if( startsWith( testCaseInfo.name, "#" ) )
|
||||||
|
Catch::cout() << "\"" << testCaseInfo.name << "\"" << std::endl;
|
||||||
|
else
|
||||||
|
Catch::cout() << testCaseInfo.name << std::endl;
|
||||||
}
|
}
|
||||||
return matchedTests;
|
return matchedTests;
|
||||||
}
|
}
|
||||||
@@ -6454,7 +6461,7 @@ namespace Catch {
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
struct RandomNumberGenerator {
|
struct RandomNumberGenerator {
|
||||||
typedef int result_type;
|
typedef std::ptrdiff_t result_type;
|
||||||
|
|
||||||
result_type operator()( result_type n ) const { return std::rand() % n; }
|
result_type operator()( result_type n ) const { return std::rand() % n; }
|
||||||
|
|
||||||
@@ -6465,10 +6472,11 @@ namespace Catch {
|
|||||||
#endif
|
#endif
|
||||||
template<typename V>
|
template<typename V>
|
||||||
static void shuffle( V& vector ) {
|
static void shuffle( V& vector ) {
|
||||||
|
RandomNumberGenerator rng;
|
||||||
#ifdef CATCH_CPP14_OR_GREATER
|
#ifdef CATCH_CPP14_OR_GREATER
|
||||||
std::shuffle( vector.begin(), vector.end(), RandomNumberGenerator() );
|
std::shuffle( vector.begin(), vector.end(), rng );
|
||||||
#else
|
#else
|
||||||
std::random_shuffle( vector.begin(), vector.end(), RandomNumberGenerator() );
|
std::random_shuffle( vector.begin(), vector.end(), rng );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -7570,7 +7578,7 @@ namespace Catch {
|
|||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
Version libraryVersion( 1, 5, 5, "", 0 );
|
Version libraryVersion( 1, 5, 8, "", 0 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7801,8 +7809,11 @@ namespace Catch {
|
|||||||
bool contains( std::string const& s, std::string const& infix ) {
|
bool contains( std::string const& s, std::string const& infix ) {
|
||||||
return s.find( infix ) != std::string::npos;
|
return s.find( infix ) != std::string::npos;
|
||||||
}
|
}
|
||||||
|
char toLowerCh(char c) {
|
||||||
|
return static_cast<char>( ::tolower( c ) );
|
||||||
|
}
|
||||||
void toLowerInPlace( std::string& s ) {
|
void toLowerInPlace( std::string& s ) {
|
||||||
std::transform( s.begin(), s.end(), s.begin(), ::tolower );
|
std::transform( s.begin(), s.end(), s.begin(), toLowerCh );
|
||||||
}
|
}
|
||||||
std::string toLower( std::string const& s ) {
|
std::string toLower( std::string const& s ) {
|
||||||
std::string lc = s;
|
std::string lc = s;
|
||||||
@@ -8950,9 +8961,10 @@ namespace Catch {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Escape control chars - based on contribution by @espenalb in PR #465
|
// Escape control chars - based on contribution by @espenalb in PR #465 and
|
||||||
|
// by @mrpi PR #588
|
||||||
if ( ( c < '\x09' ) || ( c > '\x0D' && c < '\x20') || c=='\x7F' )
|
if ( ( c < '\x09' ) || ( c > '\x0D' && c < '\x20') || c=='\x7F' )
|
||||||
os << "&#x" << std::uppercase << std::hex << static_cast<int>( c );
|
os << "&#x" << std::uppercase << std::hex << std::setfill('0') << std::setw(2) << static_cast<int>( c ) << ';';
|
||||||
else
|
else
|
||||||
os << c;
|
os << c;
|
||||||
}
|
}
|
||||||
@@ -9007,13 +9019,20 @@ namespace Catch {
|
|||||||
: m_tagIsOpen( false ),
|
: m_tagIsOpen( false ),
|
||||||
m_needsNewline( false ),
|
m_needsNewline( false ),
|
||||||
m_os( &Catch::cout() )
|
m_os( &Catch::cout() )
|
||||||
{}
|
{
|
||||||
|
// We encode control characters, which requires
|
||||||
|
// XML 1.1
|
||||||
|
// see http://stackoverflow.com/questions/404107/why-are-control-characters-illegal-in-xml-1-0
|
||||||
|
*m_os << "<?xml version=\"1.1\" encoding=\"UTF-8\"?>\n";
|
||||||
|
}
|
||||||
|
|
||||||
XmlWriter( std::ostream& os )
|
XmlWriter( std::ostream& os )
|
||||||
: m_tagIsOpen( false ),
|
: m_tagIsOpen( false ),
|
||||||
m_needsNewline( false ),
|
m_needsNewline( false ),
|
||||||
m_os( &os )
|
m_os( &os )
|
||||||
{}
|
{
|
||||||
|
*m_os << "<?xml version=\"1.1\" encoding=\"UTF-8\"?>\n";
|
||||||
|
}
|
||||||
|
|
||||||
~XmlWriter() {
|
~XmlWriter() {
|
||||||
while( !m_tags.empty() )
|
while( !m_tags.empty() )
|
||||||
@@ -9180,7 +9199,7 @@ namespace Catch {
|
|||||||
|
|
||||||
virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
|
virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::testCaseStarting(testInfo);
|
StreamingReporterBase::testCaseStarting(testInfo);
|
||||||
m_xml.startElement( "TestCase" ).writeAttribute( "name", trim( testInfo.name ) );
|
m_xml.startElement( "TestCase" ).writeAttribute( "name", testInfo.name );
|
||||||
|
|
||||||
if ( m_config->showDurations() == ShowDurations::Always )
|
if ( m_config->showDurations() == ShowDurations::Always )
|
||||||
m_testCaseTimer.start();
|
m_testCaseTimer.start();
|
||||||
@@ -9242,7 +9261,7 @@ namespace Catch {
|
|||||||
.writeText( assertionResult.getMessage() );
|
.writeText( assertionResult.getMessage() );
|
||||||
break;
|
break;
|
||||||
case ResultWas::FatalErrorCondition:
|
case ResultWas::FatalErrorCondition:
|
||||||
m_xml.scopedElement( "Fatal Error Condition" )
|
m_xml.scopedElement( "FatalErrorCondition" )
|
||||||
.writeAttribute( "filename", assertionResult.getSourceInfo().file )
|
.writeAttribute( "filename", assertionResult.getSourceInfo().file )
|
||||||
.writeAttribute( "line", assertionResult.getSourceInfo().line )
|
.writeAttribute( "line", assertionResult.getSourceInfo().line )
|
||||||
.writeText( assertionResult.getMessage() );
|
.writeText( assertionResult.getMessage() );
|
||||||
|
Reference in New Issue
Block a user