mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 20:27:11 +01:00 
			
		
		
		
	Allow to use non-copyable and non-movable types in TEMPLATE_LIST_TEST_CASE
The parameter given to `convert` may not be copyable therefore it has to be captured by const reference. For example an `std::tuple` that contains a non-copyable type is itself non-copyable. The NonDefaultConstructible test-case was reduced by one example type because it did not add any value.
This commit is contained in:
		 Benjamin Worpitz
					Benjamin Worpitz
				
			
				
					committed by
					
						 Martin Hořeňovský
						Martin Hořeňovský
					
				
			
			
				
	
			
			
			 Martin Hořeňovský
						Martin Hořeňovský
					
				
			
						parent
						
							6629c11ef8
						
					
				
				
					commit
					18d597cf10
				
			| @@ -118,7 +118,7 @@ | ||||
|     template<template <typename...> class Final, template< typename...> class...Containers, typename...Types>\ | ||||
|     constexpr auto create(TypeList<Types...>) noexcept -> decltype(append(Final<>{}, rewrap<Containers>(Types{}...)...)) { return {}; }\ | ||||
|     template<template <typename...> class Final, template <typename...> class List, typename...Ts>\ | ||||
|     constexpr auto convert(List<Ts...>) noexcept -> decltype(append(Final<>{},TypeList<Ts>{}...)) { return {}; } | ||||
|     constexpr auto convert(const List<Ts...>& ) noexcept -> decltype(append(Final<>{},TypeList<Ts>{}...)) { return {}; } | ||||
|  | ||||
| #define INTERNAL_CATCH_NTTP_1(signature, ...)\ | ||||
|     template<INTERNAL_CATCH_REMOVE_PARENS(signature)> struct Nttp{};\ | ||||
|   | ||||
| @@ -1085,6 +1085,7 @@ Class.tests.cpp:<line number>: passed: Template_Fixture<TestType>::m_a == 1 for: | ||||
| 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: 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 | ||||
| Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 4 > 0 | ||||
|   | ||||
| @@ -1380,6 +1380,6 @@ due to unexpected exception with message: | ||||
|   Why would you throw a std::string? | ||||
|  | ||||
| =============================================================================== | ||||
| test cases:  298 |  224 passed |  70 failed |  4 failed as expected | ||||
| assertions: 1553 | 1401 passed | 131 failed | 21 failed as expected | ||||
| test cases:  299 |  225 passed |  70 failed |  4 failed as expected | ||||
| assertions: 1554 | 1402 passed | 131 failed | 21 failed as expected | ||||
|  | ||||
|   | ||||
| @@ -8022,6 +8022,30 @@ Class.tests.cpp:<line number>: PASSED: | ||||
| with expansion: | ||||
|   1.0 == 1 | ||||
|  | ||||
| ------------------------------------------------------------------------------- | ||||
| Template test case with test types specified inside non-copyable and non- | ||||
| movable std::tuple - NonCopyableAndNonMovableTypes - 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-copyable and non- | ||||
| movable std::tuple - NonCopyableAndNonMovableTypes - 1 | ||||
| ------------------------------------------------------------------------------- | ||||
| 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 non-default-constructible | ||||
| std::tuple - MyNonDefaultConstructibleTypes - 0 | ||||
| @@ -8041,18 +8065,6 @@ 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: | ||||
| @@ -12409,6 +12421,6 @@ Misc.tests.cpp:<line number> | ||||
| Misc.tests.cpp:<line number>: PASSED: | ||||
|  | ||||
| =============================================================================== | ||||
| test cases:  298 |  208 passed |  86 failed |  4 failed as expected | ||||
| assertions: 1570 | 1401 passed | 148 failed | 21 failed as expected | ||||
| test cases:  299 |  209 passed |  86 failed |  4 failed as expected | ||||
| assertions: 1571 | 1402 passed | 148 failed | 21 failed as expected | ||||
|  | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <testsuitesloose text artifact | ||||
| > | ||||
|   <testsuite name="<exe-name>" errors="17" failures="132" tests="1571" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> | ||||
|   <testsuite name="<exe-name>" errors="17" failures="132" tests="1572" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> | ||||
|     <properties> | ||||
|       <property name="filters" value="~[!nonportable]~[!benchmark]~[approvals]"/> | ||||
|       <property name="random-seed" value="1"/> | ||||
| @@ -750,9 +750,10 @@ 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-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 0" time="{duration}"/> | ||||
|     <testcase classname="<exe-name>.global" name="Template test case with test types specified inside non-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 1" 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}"/> | ||||
|   | ||||
| @@ -9895,6 +9895,28 @@ Message from section two | ||||
|       </Expression> | ||||
|       <OverallResult success="true"/> | ||||
|     </TestCase> | ||||
|     <TestCase name="Template test case with test types specified inside non-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 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-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 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> | ||||
|           4 > 0 | ||||
|         </Expanded> | ||||
|       </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> | ||||
| @@ -9907,17 +9929,6 @@ Message from section two | ||||
|       <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 | ||||
| @@ -14767,7 +14778,7 @@ loose text artifact | ||||
|       </Section> | ||||
|       <OverallResult success="true"/> | ||||
|     </TestCase> | ||||
|     <OverallResults successes="1401" failures="149" expectedFailures="21"/> | ||||
|     <OverallResults successes="1402" failures="149" expectedFailures="21"/> | ||||
|   </Group> | ||||
|   <OverallResults successes="1401" failures="148" expectedFailures="21"/> | ||||
|   <OverallResults successes="1402" failures="148" expectedFailures="21"/> | ||||
| </Catch> | ||||
|   | ||||
| @@ -375,12 +375,27 @@ struct NonDefaultConstructibleType { | ||||
|     NonDefaultConstructibleType() = delete; | ||||
| }; | ||||
|  | ||||
| using MyNonDefaultConstructibleTypes = std::tuple<NonDefaultConstructibleType, char, float>; | ||||
| using MyNonDefaultConstructibleTypes = std::tuple<NonDefaultConstructibleType, 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); | ||||
| } | ||||
|  | ||||
| struct NonCopyableAndNonMovableType { | ||||
|     NonCopyableAndNonMovableType() = default; | ||||
|  | ||||
|     NonCopyableAndNonMovableType(NonCopyableAndNonMovableType const &) = delete; | ||||
|     NonCopyableAndNonMovableType(NonCopyableAndNonMovableType &&) = delete; | ||||
|     auto operator=(NonCopyableAndNonMovableType const &) -> NonCopyableAndNonMovableType & = delete; | ||||
|     auto operator=(NonCopyableAndNonMovableType &&) -> NonCopyableAndNonMovableType & = delete; | ||||
| }; | ||||
|  | ||||
| using NonCopyableAndNonMovableTypes = std::tuple<NonCopyableAndNonMovableType, float>; | ||||
| TEMPLATE_LIST_TEST_CASE("Template test case with test types specified inside non-copyable and non-movable std::tuple", "[template][list]", NonCopyableAndNonMovableTypes) | ||||
| { | ||||
|     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") | ||||
|   | ||||
		Reference in New Issue
	
	Block a user