Refactor SectionInfo constructors

This commit is contained in:
Martin Hořeňovský 2019-11-16 21:53:32 +01:00
parent d36c15c3ca
commit c9067b2253
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
11 changed files with 47 additions and 37 deletions

View File

@ -1,19 +0,0 @@
/*
* Created by Martin on 01/08/2017.
*
* 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)
*/
#include "catch_section_info.h"
namespace Catch {
SectionInfo::SectionInfo
( SourceLineInfo const& _lineInfo,
std::string const& _name )
: name( _name ),
lineInfo( _lineInfo )
{}
} // end namespace Catch

View File

@ -17,17 +17,14 @@
namespace Catch { namespace Catch {
struct SectionInfo { struct SectionInfo {
SectionInfo
( SourceLineInfo const& _lineInfo,
std::string const& _name );
// The last argument is ignored, so that people can write // The last argument is ignored, so that people can write
// SECTION("ShortName", "Proper description that is long") and // SECTION("ShortName", "Proper description that is long") and
// still use the `-c` flag comfortably. // still use the `-c` flag comfortably.
SectionInfo SectionInfo( SourceLineInfo const& _lineInfo, std::string _name,
( SourceLineInfo const& _lineInfo, const char* const = nullptr ):
std::string const& _name, name(std::move(_name)),
const char* const ) : SectionInfo( _lineInfo, _name ) {} lineInfo(_lineInfo)
{}
std::string name; std::string name;
SourceLineInfo lineInfo; SourceLineInfo lineInfo;

View File

@ -244,7 +244,6 @@ set(IMPL_SOURCES
${HEADER_DIR}/internal/catch_result_type.cpp ${HEADER_DIR}/internal/catch_result_type.cpp
${HEADER_DIR}/internal/catch_run_context.cpp ${HEADER_DIR}/internal/catch_run_context.cpp
${HEADER_DIR}/internal/catch_section.cpp ${HEADER_DIR}/internal/catch_section.cpp
${HEADER_DIR}/internal/catch_section_info.cpp
${HEADER_DIR}/internal/catch_session.cpp ${HEADER_DIR}/internal/catch_session.cpp
${HEADER_DIR}/internal/catch_singletons.cpp ${HEADER_DIR}/internal/catch_singletons.cpp
${HEADER_DIR}/internal/catch_startup_exception_registry.cpp ${HEADER_DIR}/internal/catch_startup_exception_registry.cpp

View File

@ -15,6 +15,7 @@ Misc.tests.cpp:<line number>: passed:
Compilation.tests.cpp:<line number>: passed: std::memcmp(uarr, "123", sizeof(uarr)) == 0 for: 0 == 0 with 2 messages: 'uarr := "123"' and 'sarr := "456"' Compilation.tests.cpp:<line number>: passed: std::memcmp(uarr, "123", sizeof(uarr)) == 0 for: 0 == 0 with 2 messages: 'uarr := "123"' and 'sarr := "456"'
Compilation.tests.cpp:<line number>: passed: std::memcmp(sarr, "456", sizeof(sarr)) == 0 for: 0 == 0 with 2 messages: 'uarr := "123"' and 'sarr := "456"' Compilation.tests.cpp:<line number>: passed: std::memcmp(sarr, "456", sizeof(sarr)) == 0 for: 0 == 0 with 2 messages: 'uarr := "123"' and 'sarr := "456"'
Compilation.tests.cpp:<line number>: passed: Compilation.tests.cpp:<line number>: passed:
Compilation.tests.cpp:<line number>: passed:
Compilation.tests.cpp:<line number>: passed: h1 == h2 for: [1403 helper] == [1403 helper] Compilation.tests.cpp:<line number>: passed: h1 == h2 for: [1403 helper] == [1403 helper]
Message.tests.cpp:<line number>: warning: ' Message.tests.cpp:<line number>: warning: '
This info message starts with a linebreak' with 1 message: ' This info message starts with a linebreak' with 1 message: '

View File

@ -1380,6 +1380,6 @@ due to unexpected exception with message:
Why would you throw a std::string? Why would you throw a std::string?
=============================================================================== ===============================================================================
test cases: 304 | 230 passed | 70 failed | 4 failed as expected test cases: 305 | 231 passed | 70 failed | 4 failed as expected
assertions: 1653 | 1501 passed | 131 failed | 21 failed as expected assertions: 1654 | 1502 passed | 131 failed | 21 failed as expected

View File

@ -139,6 +139,15 @@ Compilation.tests.cpp:<line number>
Compilation.tests.cpp:<line number>: PASSED: Compilation.tests.cpp:<line number>: PASSED:
-------------------------------------------------------------------------------
#1319: Sections can have description (even if it is not saved
SectionName
-------------------------------------------------------------------------------
Compilation.tests.cpp:<line number>
...............................................................................
Compilation.tests.cpp:<line number>: PASSED:
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
#1403 #1403
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
@ -13207,6 +13216,6 @@ Misc.tests.cpp:<line number>
Misc.tests.cpp:<line number>: PASSED: Misc.tests.cpp:<line number>: PASSED:
=============================================================================== ===============================================================================
test cases: 304 | 214 passed | 86 failed | 4 failed as expected test cases: 305 | 215 passed | 86 failed | 4 failed as expected
assertions: 1670 | 1501 passed | 148 failed | 21 failed as expected assertions: 1671 | 1502 passed | 148 failed | 21 failed as expected

View File

@ -139,6 +139,15 @@ Compilation.tests.cpp:<line number>
Compilation.tests.cpp:<line number>: PASSED: Compilation.tests.cpp:<line number>: PASSED:
-------------------------------------------------------------------------------
#1319: Sections can have description (even if it is not saved
SectionName
-------------------------------------------------------------------------------
Compilation.tests.cpp:<line number>
...............................................................................
Compilation.tests.cpp:<line number>: PASSED:
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
#1403 #1403
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
@ -368,6 +377,6 @@ Condition.tests.cpp:<line number>: FAILED:
CHECK( true != true ) CHECK( true != true )
=============================================================================== ===============================================================================
test cases: 19 | 14 passed | 3 failed | 2 failed as expected test cases: 20 | 15 passed | 3 failed | 2 failed as expected
assertions: 42 | 35 passed | 4 failed | 3 failed as expected assertions: 43 | 36 passed | 4 failed | 3 failed as expected

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<testsuitesloose text artifact <testsuitesloose text artifact
> >
<testsuite name="<exe-name>" errors="17" failures="132" tests="1671" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> <testsuite name="<exe-name>" errors="17" failures="132" tests="1672" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties> <properties>
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals] *"/> <property name="filters" value="~[!nonportable]~[!benchmark]~[approvals] *"/>
<property name="random-seed" value="1"/> <property name="random-seed" value="1"/>
@ -14,6 +14,7 @@
<testcase classname="<exe-name>.global" name="#1175 - Hidden Test" time="{duration}"/> <testcase classname="<exe-name>.global" name="#1175 - Hidden Test" time="{duration}"/>
<testcase classname="<exe-name>.global" name="#1238" time="{duration}"/> <testcase classname="<exe-name>.global" name="#1238" time="{duration}"/>
<testcase classname="<exe-name>.(Fixture_1245&lt;int, int>)" name="#1245" time="{duration}"/> <testcase classname="<exe-name>.(Fixture_1245&lt;int, int>)" name="#1245" time="{duration}"/>
<testcase classname="<exe-name>.global" name="#1319: Sections can have description (even if it is not saved/SectionName" time="{duration}"/>
<testcase classname="<exe-name>.global" name="#1403" time="{duration}"/> <testcase classname="<exe-name>.global" name="#1403" time="{duration}"/>
<testcase classname="<exe-name>.global" name="#1455 - INFO and WARN can start with a linebreak" time="{duration}"/> <testcase classname="<exe-name>.global" name="#1455 - INFO and WARN can start with a linebreak" time="{duration}"/>
<testcase classname="<exe-name>.global" name="#1514: stderr/stdout is not captured in tests aborted by an exception" time="{duration}"> <testcase classname="<exe-name>.global" name="#1514: stderr/stdout is not captured in tests aborted by an exception" time="{duration}">

View File

@ -358,6 +358,7 @@ Class.tests.cpp:<line number>
<testCase name="#1147" duration="{duration}"/> <testCase name="#1147" duration="{duration}"/>
<testCase name="#1238" duration="{duration}"/> <testCase name="#1238" duration="{duration}"/>
<testCase name="#1245" duration="{duration}"/> <testCase name="#1245" duration="{duration}"/>
<testCase name="#1319: Sections can have description (even if it is not saved/SectionName" duration="{duration}"/>
<testCase name="#1403" duration="{duration}"/> <testCase name="#1403" duration="{duration}"/>
<testCase name="#1548" duration="{duration}"/> <testCase name="#1548" duration="{duration}"/>
<testCase name="#809" duration="{duration}"/> <testCase name="#809" duration="{duration}"/>

View File

@ -150,6 +150,12 @@
<TestCase name="#1245" tags="[compilation]" filename="projects/<exe-name>/UsageTests/Compilation.tests.cpp" > <TestCase name="#1245" tags="[compilation]" filename="projects/<exe-name>/UsageTests/Compilation.tests.cpp" >
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
<TestCase name="#1319: Sections can have description (even if it is not saved" tags="[compilation]" filename="projects/<exe-name>/UsageTests/Compilation.tests.cpp" >
<Section name="SectionName" filename="projects/<exe-name>/UsageTests/Compilation.tests.cpp" >
<OverallResults successes="1" failures="0" expectedFailures="0"/>
</Section>
<OverallResult success="true"/>
</TestCase>
<TestCase name="#1403" tags="[compilation]" filename="projects/<exe-name>/UsageTests/Compilation.tests.cpp" > <TestCase name="#1403" tags="[compilation]" filename="projects/<exe-name>/UsageTests/Compilation.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Compilation.tests.cpp" > <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Compilation.tests.cpp" >
<Original> <Original>
@ -15790,7 +15796,7 @@ loose text artifact
</Section> </Section>
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
<OverallResults successes="1501" failures="149" expectedFailures="21"/> <OverallResults successes="1502" failures="149" expectedFailures="21"/>
</Group> </Group>
<OverallResults successes="1501" failures="148" expectedFailures="21"/> <OverallResults successes="1502" failures="148" expectedFailures="21"/>
</Catch> </Catch>

View File

@ -219,6 +219,12 @@ namespace { namespace CompilationTests {
REQUIRE( 0 == y.v ); REQUIRE( 0 == y.v );
} }
TEST_CASE("#1319: Sections can have description (even if it is not saved", "[compilation]") {
SECTION("SectionName", "This is a long form section description") {
SUCCEED();
}
}
}} // namespace CompilationTests }} // namespace CompilationTests