Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix non-default-constructible type lists used in TEMPLATE_LIST_TEST_CASE #1697

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/internal/catch_test_registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ struct AutoReg : NonCopyable {
} \
};\
static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){ \
using TestInit = decltype(convert<TestName>(TmplList {})); \
using TestInit = decltype(convert<TestName>(std::declval<TmplList>())); \
TestInit t; \
t.reg_tests(); \
return 0; \
Expand Down Expand Up @@ -374,7 +374,7 @@ struct AutoReg : NonCopyable {
}\
};\
static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\
using TestInit = decltype(convert<TestNameClass>(TmplList {}));\
using TestInit = decltype(convert<TestNameClass>(std::declval<TmplList>()));\
TestInit t;\
t.reg_tests();\
return 0;\
Expand Down
3 changes: 3 additions & 0 deletions projects/SelfTest/Baselines/compact.sw.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,9 @@ Tag.tests.cpp:<line number>: passed: registry.add( "[@no square bracket at end",
Class.tests.cpp:<line number>: passed: Template_Fixture<TestType>::m_a == 1 for: 1 == 1
Class.tests.cpp:<line number>: passed: Template_Fixture<TestType>::m_a == 1 for: 1 == 1
Class.tests.cpp:<line number>: passed: Template_Fixture<TestType>::m_a == 1 for: 1.0 == 1
Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 1 > 0
Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 1 > 0
Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 4 > 0
Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 4 > 0
Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 1 > 0
Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 4 > 0
Expand Down
4 changes: 2 additions & 2 deletions projects/SelfTest/Baselines/console.std.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1380,6 +1380,6 @@ due to unexpected exception with message:
Why would you throw a std::string?

===============================================================================
test cases: 295 | 221 passed | 70 failed | 4 failed as expected
assertions: 1550 | 1398 passed | 131 failed | 21 failed as expected
test cases: 298 | 224 passed | 70 failed | 4 failed as expected
assertions: 1553 | 1401 passed | 131 failed | 21 failed as expected

40 changes: 38 additions & 2 deletions projects/SelfTest/Baselines/console.sw.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8022,6 +8022,42 @@ Class.tests.cpp:<line number>: PASSED:
with expansion:
1.0 == 1

-------------------------------------------------------------------------------
Template test case with test types specified inside non-default-constructible
std::tuple - MyNonDefaultConstructibleTypes - 0
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................

Misc.tests.cpp:<line number>: PASSED:
REQUIRE( sizeof(TestType) > 0 )
with expansion:
1 > 0

-------------------------------------------------------------------------------
Template test case with test types specified inside non-default-constructible
std::tuple - MyNonDefaultConstructibleTypes - 1
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................

Misc.tests.cpp:<line number>: PASSED:
REQUIRE( sizeof(TestType) > 0 )
with expansion:
1 > 0

-------------------------------------------------------------------------------
Template test case with test types specified inside non-default-constructible
std::tuple - MyNonDefaultConstructibleTypes - 2
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................

Misc.tests.cpp:<line number>: PASSED:
REQUIRE( sizeof(TestType) > 0 )
with expansion:
4 > 0

-------------------------------------------------------------------------------
Template test case with test types specified inside std::tuple - MyTypes - 0
-------------------------------------------------------------------------------
Expand Down Expand Up @@ -12373,6 +12409,6 @@ Misc.tests.cpp:<line number>
Misc.tests.cpp:<line number>: PASSED:

===============================================================================
test cases: 295 | 205 passed | 86 failed | 4 failed as expected
assertions: 1567 | 1398 passed | 148 failed | 21 failed as expected
test cases: 298 | 208 passed | 86 failed | 4 failed as expected
assertions: 1570 | 1401 passed | 148 failed | 21 failed as expected

5 changes: 4 additions & 1 deletion projects/SelfTest/Baselines/junit.sw.approved.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuitesloose text artifact
>
<testsuite name="<exe-name>" errors="17" failures="132" tests="1568" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<testsuite name="<exe-name>" errors="17" failures="132" tests="1571" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties>
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals]"/>
<property name="random-seed" value="1"/>
Expand Down Expand Up @@ -750,6 +750,9 @@ Misc.tests.cpp:<line number>
<testcase classname="<exe-name>.Template_Fixture" name="Template test case method with test types specified inside std::tuple - MyTypes - 0" time="{duration}"/>
<testcase classname="<exe-name>.Template_Fixture" name="Template test case method with test types specified inside std::tuple - MyTypes - 1" time="{duration}"/>
<testcase classname="<exe-name>.Template_Fixture" name="Template test case method with test types specified inside std::tuple - MyTypes - 2" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 0" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 1" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 2" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Template test case with test types specified inside std::tuple - MyTypes - 0" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Template test case with test types specified inside std::tuple - MyTypes - 1" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Template test case with test types specified inside std::tuple - MyTypes - 2" time="{duration}"/>
Expand Down
37 changes: 35 additions & 2 deletions projects/SelfTest/Baselines/xml.sw.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9895,6 +9895,39 @@ Message from section two
</Expression>
<OverallResult success="true"/>
</TestCase>
<TestCase name="Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 0" tags="[list][template]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
<Original>
sizeof(TestType) > 0
</Original>
<Expanded>
1 > 0
</Expanded>
</Expression>
<OverallResult success="true"/>
</TestCase>
<TestCase name="Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 1" tags="[list][template]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
<Original>
sizeof(TestType) > 0
</Original>
<Expanded>
1 > 0
</Expanded>
</Expression>
<OverallResult success="true"/>
</TestCase>
<TestCase name="Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 2" tags="[list][template]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
<Original>
sizeof(TestType) > 0
</Original>
<Expanded>
4 > 0
</Expanded>
</Expression>
<OverallResult success="true"/>
</TestCase>
<TestCase name="Template test case with test types specified inside std::tuple - MyTypes - 0" tags="[list][template]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
<Original>
Expand Down Expand Up @@ -14734,7 +14767,7 @@ loose text artifact
</Section>
<OverallResult success="true"/>
</TestCase>
<OverallResults successes="1398" failures="149" expectedFailures="21"/>
<OverallResults successes="1401" failures="149" expectedFailures="21"/>
</Group>
<OverallResults successes="1398" failures="148" expectedFailures="21"/>
<OverallResults successes="1401" failures="148" expectedFailures="21"/>
</Catch>
10 changes: 10 additions & 0 deletions projects/SelfTest/UsageTests/Misc.tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,16 @@ TEMPLATE_LIST_TEST_CASE("Template test case with test types specified inside std
REQUIRE(sizeof(TestType) > 0);
}

struct NonDefaultConstructibleType {
NonDefaultConstructibleType() = delete;
};

using MyNonDefaultConstructibleTypes = std::tuple<NonDefaultConstructibleType, char, float>;
TEMPLATE_LIST_TEST_CASE("Template test case with test types specified inside non-default-constructible std::tuple", "[template][list]", MyNonDefaultConstructibleTypes)
{
REQUIRE(sizeof(TestType) > 0);
}

// https://github.com/philsquared/Catch/issues/166
TEST_CASE("A couple of nested sections followed by a failure", "[failing][.]") {
SECTION("Outer")
Expand Down