Skip to content

Commit ee67ac6

Browse files
committed
v1.9.6
1 parent 8a14af7 commit ee67ac6

File tree

4 files changed

+81
-42
lines changed

4 files changed

+81
-42
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![Build Status](https://travis-ci.org/philsquared/Catch.svg?branch=master)](https://travis-ci.org/philsquared/Catch)
55
[![Build status](https://ci.appveyor.com/api/projects/status/hrtk60hv6tw6fght/branch/master?svg=true)](https://ci.appveyor.com/project/philsquared/catch/branch/master)
66

7-
<a href="https://github.com/philsquared/Catch/releases/download/v1.9.5/catch.hpp">The latest, single header, version can be downloaded directly using this link</a>
7+
<a href="https://github.com/philsquared/Catch/releases/download/v1.9.6/catch.hpp">The latest, single header, version can be downloaded directly using this link</a>
88

99
## What's the Catch?
1010

docs/release-notes.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# 1.9.6
2+
3+
### Improvements
4+
* Catch's runtime overhead has been significantly decreased (#937, #939)
5+
* Added `--list-extra-info` cli option (#934).
6+
* It lists all tests together with extra information, ie filename, line number and description.
7+
8+
9+
110
# 1.9.5
211

312
### Fixes

include/internal/catch_version.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace Catch {
3838
}
3939

4040
inline Version libraryVersion() {
41-
static Version version( 1, 9, 5, "", 0 );
41+
static Version version( 1, 9, 6, "", 0 );
4242
return version;
4343
}
4444

single_include/catch.hpp

Lines changed: 70 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Catch v1.9.5
3-
* Generated: 2017-06-15 12:03:23.301505
2+
* Catch v1.9.6
3+
* Generated: 2017-06-27 12:19:54.557875
44
* ----------------------------------------------------------
55
* This file has been merged from multiple headers. Please don't edit it directly
66
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
@@ -934,15 +934,17 @@ namespace Catch {
934934
struct AssertionInfo
935935
{
936936
AssertionInfo() {}
937-
AssertionInfo( std::string const& _macroName,
937+
AssertionInfo( char const * _macroName,
938938
SourceLineInfo const& _lineInfo,
939-
std::string const& _capturedExpression,
940-
ResultDisposition::Flags _resultDisposition );
939+
char const * _capturedExpression,
940+
ResultDisposition::Flags _resultDisposition,
941+
char const * _secondArg = "");
941942

942-
std::string macroName;
943+
char const * macroName;
943944
SourceLineInfo lineInfo;
944-
std::string capturedExpression;
945+
char const * capturedExpression;
945946
ResultDisposition::Flags resultDisposition;
947+
char const * secondArg;
946948
};
947949

948950
struct AssertionResultData
@@ -1217,7 +1219,7 @@ namespace Catch {
12171219

12181220
template<typename T>
12191221
ResultBuilder& operator << ( T const& value ) {
1220-
m_stream.oss << value;
1222+
m_stream().oss << value;
12211223
return *this;
12221224
}
12231225

@@ -1250,7 +1252,12 @@ namespace Catch {
12501252
private:
12511253
AssertionInfo m_assertionInfo;
12521254
AssertionResultData m_data;
1253-
CopyableStream m_stream;
1255+
1256+
static CopyableStream &m_stream()
1257+
{
1258+
static CopyableStream s;
1259+
return s;
1260+
}
12541261

12551262
bool m_shouldDebugBreak;
12561263
bool m_shouldThrow;
@@ -3938,6 +3945,7 @@ namespace Catch {
39383945
listTags( false ),
39393946
listReporters( false ),
39403947
listTestNamesOnly( false ),
3948+
listExtraInfo( false ),
39413949
showSuccessfulTests( false ),
39423950
shouldDebugBreak( false ),
39433951
noThrow( false ),
@@ -3957,6 +3965,7 @@ namespace Catch {
39573965
bool listTags;
39583966
bool listReporters;
39593967
bool listTestNamesOnly;
3968+
bool listExtraInfo;
39603969

39613970
bool showSuccessfulTests;
39623971
bool shouldDebugBreak;
@@ -4015,6 +4024,7 @@ namespace Catch {
40154024
bool listTestNamesOnly() const { return m_data.listTestNamesOnly; }
40164025
bool listTags() const { return m_data.listTags; }
40174026
bool listReporters() const { return m_data.listReporters; }
4027+
bool listExtraInfo() const { return m_data.listExtraInfo; }
40184028

40194029
std::string getProcessName() const { return m_data.processName; }
40204030

@@ -5276,6 +5286,10 @@ namespace Catch {
52765286
.describe( "list all/matching test cases names only" )
52775287
.bind( &ConfigData::listTestNamesOnly );
52785288

5289+
cli["--list-extra-info"]
5290+
.describe( "list all/matching test cases with more info" )
5291+
.bind( &ConfigData::listExtraInfo );
5292+
52795293
cli["--list-reporters"]
52805294
.describe( "list all reporters" )
52815295
.bind( &ConfigData::listReporters );
@@ -5804,8 +5818,9 @@ namespace Catch {
58045818
}
58055819

58065820
std::size_t matchedTests = 0;
5807-
TextAttributes nameAttr, tagsAttr;
5821+
TextAttributes nameAttr, descAttr, tagsAttr;
58085822
nameAttr.setInitialIndent( 2 ).setIndent( 4 );
5823+
descAttr.setIndent( 4 );
58095824
tagsAttr.setIndent( 6 );
58105825

58115826
std::vector<TestCase> matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config );
@@ -5820,6 +5835,13 @@ namespace Catch {
58205835
Colour colourGuard( colour );
58215836

58225837
Catch::cout() << Text( testCaseInfo.name, nameAttr ) << std::endl;
5838+
if( config.listExtraInfo() ) {
5839+
Catch::cout() << " " << testCaseInfo.lineInfo << std::endl;
5840+
std::string description = testCaseInfo.description;
5841+
if( description.empty() )
5842+
description = "(NO DESCRIPTION)";
5843+
Catch::cout() << Text( description, descAttr ) << std::endl;
5844+
}
58235845
if( !testCaseInfo.tags.empty() )
58245846
Catch::cout() << Text( testCaseInfo.tagsAsString, tagsAttr ) << std::endl;
58255847
}
@@ -5843,9 +5865,12 @@ namespace Catch {
58435865
matchedTests++;
58445866
TestCaseInfo const& testCaseInfo = it->getTestCaseInfo();
58455867
if( startsWith( testCaseInfo.name, '#' ) )
5846-
Catch::cout() << '"' << testCaseInfo.name << '"' << std::endl;
5868+
Catch::cout() << '"' << testCaseInfo.name << '"';
58475869
else
5848-
Catch::cout() << testCaseInfo.name << std::endl;
5870+
Catch::cout() << testCaseInfo.name;
5871+
if ( config.listExtraInfo() )
5872+
Catch::cout() << "\t@" << testCaseInfo.lineInfo;
5873+
Catch::cout() << std::endl;
58495874
}
58505875
return matchedTests;
58515876
}
@@ -5937,7 +5962,7 @@ namespace Catch {
59375962

59385963
inline Option<std::size_t> list( Config const& config ) {
59395964
Option<std::size_t> listedCount;
5940-
if( config.listTests() )
5965+
if( config.listTests() || ( config.listExtraInfo() && !config.listTestNamesOnly() ) )
59415966
listedCount = listedCount.valueOr(0) + listTests( config );
59425967
if( config.listTestNamesOnly() )
59435968
listedCount = listedCount.valueOr(0) + listTestsNamesOnly( config );
@@ -6647,7 +6672,7 @@ namespace Catch {
66476672
static_cast<void>(m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals)));
66486673

66496674
// Reset working state
6650-
m_lastAssertionInfo = AssertionInfo( std::string(), m_lastAssertionInfo.lineInfo, "{Unknown expression after the reported line}" , m_lastAssertionInfo.resultDisposition );
6675+
m_lastAssertionInfo = AssertionInfo( "", m_lastAssertionInfo.lineInfo, "{Unknown expression after the reported line}" , m_lastAssertionInfo.resultDisposition );
66516676
m_lastResult = result;
66526677
}
66536678

@@ -6777,7 +6802,7 @@ namespace Catch {
67776802
double duration = 0;
67786803
m_shouldReportUnexpected = true;
67796804
try {
6780-
m_lastAssertionInfo = AssertionInfo( "TEST_CASE", testCaseInfo.lineInfo, std::string(), ResultDisposition::Normal );
6805+
m_lastAssertionInfo = AssertionInfo( "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal );
67816806

67826807
seedRng( *m_config );
67836808

@@ -6829,9 +6854,9 @@ namespace Catch {
68296854
private:
68306855

68316856
ResultBuilder makeUnexpectedResultBuilder() const {
6832-
return ResultBuilder( m_lastAssertionInfo.macroName.c_str(),
6857+
return ResultBuilder( m_lastAssertionInfo.macroName,
68336858
m_lastAssertionInfo.lineInfo,
6834-
m_lastAssertionInfo.capturedExpression.c_str(),
6859+
m_lastAssertionInfo.capturedExpression,
68356860
m_lastAssertionInfo.resultDisposition );
68366861
}
68376862

@@ -8008,14 +8033,16 @@ namespace Catch {
80088033

80098034
namespace Catch {
80108035

8011-
AssertionInfo::AssertionInfo( std::string const& _macroName,
8036+
AssertionInfo::AssertionInfo( char const * _macroName,
80128037
SourceLineInfo const& _lineInfo,
8013-
std::string const& _capturedExpression,
8014-
ResultDisposition::Flags _resultDisposition )
8038+
char const * _capturedExpression,
8039+
ResultDisposition::Flags _resultDisposition,
8040+
char const * _secondArg)
80158041
: macroName( _macroName ),
80168042
lineInfo( _lineInfo ),
80178043
capturedExpression( _capturedExpression ),
8018-
resultDisposition( _resultDisposition )
8044+
resultDisposition( _resultDisposition ),
8045+
secondArg( _secondArg )
80198046
{}
80208047

80218048
AssertionResult::AssertionResult() {}
@@ -8042,24 +8069,30 @@ namespace Catch {
80428069
}
80438070

80448071
bool AssertionResult::hasExpression() const {
8045-
return !m_info.capturedExpression.empty();
8072+
return m_info.capturedExpression[0] != 0;
80468073
}
80478074

80488075
bool AssertionResult::hasMessage() const {
80498076
return !m_resultData.message.empty();
80508077
}
80518078

8079+
std::string capturedExpressionWithSecondArgument( char const * capturedExpression, char const * secondArg ) {
8080+
return (secondArg[0] == 0 || secondArg[0] == '"' && secondArg[1] == '"')
8081+
? capturedExpression
8082+
: std::string(capturedExpression) + ", " + secondArg;
8083+
}
8084+
80528085
std::string AssertionResult::getExpression() const {
80538086
if( isFalseTest( m_info.resultDisposition ) )
8054-
return '!' + m_info.capturedExpression;
8087+
return '!' + capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg);
80558088
else
8056-
return m_info.capturedExpression;
8089+
return capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg);
80578090
}
80588091
std::string AssertionResult::getExpressionInMacro() const {
8059-
if( m_info.macroName.empty() )
8060-
return m_info.capturedExpression;
8092+
if( m_info.macroName[0] == 0 )
8093+
return capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg);
80618094
else
8062-
return m_info.macroName + "( " + m_info.capturedExpression + " )";
8095+
return std::string(m_info.macroName) + "( " + capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg) + " )";
80638096
}
80648097

80658098
bool AssertionResult::hasExpandedExpression() const {
@@ -8309,7 +8342,7 @@ namespace Catch {
83098342
}
83108343

83118344
inline Version libraryVersion() {
8312-
static Version version( 1, 9, 5, "", 0 );
8345+
static Version version( 1, 9, 6, "", 0 );
83138346
return version;
83148347
}
83158348

@@ -9009,26 +9042,23 @@ std::string toString( std::nullptr_t ) {
90099042

90109043
namespace Catch {
90119044

9012-
std::string capturedExpressionWithSecondArgument( std::string const& capturedExpression, std::string const& secondArg ) {
9013-
return secondArg.empty() || secondArg == "\"\""
9014-
? capturedExpression
9015-
: capturedExpression + ", " + secondArg;
9016-
}
90179045
ResultBuilder::ResultBuilder( char const* macroName,
90189046
SourceLineInfo const& lineInfo,
90199047
char const* capturedExpression,
90209048
ResultDisposition::Flags resultDisposition,
90219049
char const* secondArg )
9022-
: m_assertionInfo( macroName, lineInfo, capturedExpressionWithSecondArgument( capturedExpression, secondArg ), resultDisposition ),
9050+
: m_assertionInfo( macroName, lineInfo, capturedExpression, resultDisposition, secondArg ),
90239051
m_shouldDebugBreak( false ),
90249052
m_shouldThrow( false ),
90259053
m_guardException( false )
9026-
{}
9054+
{
9055+
m_stream().oss.str("");
9056+
}
90279057

90289058
ResultBuilder::~ResultBuilder() {
90299059
#if defined(CATCH_CONFIG_FAST_COMPILE)
90309060
if ( m_guardException ) {
9031-
m_stream.oss << "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE";
9061+
m_stream().oss << "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE";
90329062
captureResult( ResultWas::ThrewException );
90339063
getCurrentContext().getResultCapture()->exceptionEarlyReported();
90349064
}
@@ -9051,7 +9081,7 @@ namespace Catch {
90519081

90529082
void ResultBuilder::useActiveException( ResultDisposition::Flags resultDisposition ) {
90539083
m_assertionInfo.resultDisposition = resultDisposition;
9054-
m_stream.oss << Catch::translateActiveException();
9084+
m_stream().oss << Catch::translateActiveException();
90559085
captureResult( ResultWas::ThrewException );
90569086
}
90579087

@@ -9072,7 +9102,7 @@ namespace Catch {
90729102
assert( !isFalseTest( m_assertionInfo.resultDisposition ) );
90739103
AssertionResultData data = m_data;
90749104
data.resultType = ResultWas::Ok;
9075-
data.reconstructedExpression = m_assertionInfo.capturedExpression;
9105+
data.reconstructedExpression = capturedExpressionWithSecondArgument(m_assertionInfo.capturedExpression, m_assertionInfo.secondArg);
90769106

90779107
std::string actualMessage = Catch::translateActiveException();
90789108
if( !matcher.match( actualMessage ) ) {
@@ -9138,13 +9168,13 @@ namespace Catch {
91389168
data.negate( expr.isBinaryExpression() );
91399169
}
91409170

9141-
data.message = m_stream.oss.str();
9171+
data.message = m_stream().oss.str();
91429172
data.decomposedExpression = &expr; // for lazy reconstruction
91439173
return AssertionResult( m_assertionInfo, data );
91449174
}
91459175

91469176
void ResultBuilder::reconstructExpression( std::string& dest ) const {
9147-
dest = m_assertionInfo.capturedExpression;
9177+
dest = capturedExpressionWithSecondArgument(m_assertionInfo.capturedExpression, m_assertionInfo.secondArg);
91489178
}
91499179

91509180
void ResultBuilder::setExceptionGuard() {

0 commit comments

Comments
 (0)