diff --git a/packages/Catch2/.gitrepo b/packages/Catch2/.gitrepo index 5ff8c4ebcd37dbee7016ad2a75e63fbb241ac60b..69a7ef8a31ff838cc194e72ba5b5218ceba72434 100644 --- a/packages/Catch2/.gitrepo +++ b/packages/Catch2/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = git@github.com:catchorg/Catch2.git branch = master - commit = 4902cd721586822ded795afe0c418c553137306a - parent = ee2eaf8ae00c09a6eaa3de857f27d607a3e6511c + commit = 461843b1f02a4bf5c59db88ff201d2c56fabf3a4 + parent = 948c251985efea2e0b476fbab221850efee6a689 cmdver = 0.4.0 method = merge diff --git a/packages/Catch2/docs/test-cases-and-sections.md b/packages/Catch2/docs/test-cases-and-sections.md index 50de14bf09d57e30bff5f22fb177eabb9c414015..abd55cd09dcb3a0c78f3a6f742ad32d5e5314737 100644 --- a/packages/Catch2/docs/test-cases-and-sections.md +++ b/packages/Catch2/docs/test-cases-and-sections.md @@ -95,7 +95,8 @@ Other than the additional prefixes and the formatting in the console reporter th ## Type parametrised test cases In addition to `TEST_CASE`s, Catch2 also supports test cases parametrised -by type, in the form of `TEMPLATE_TEST_CASE`. +by types, in the form of `TEMPLATE_TEST_CASE` and +`TEMPLATE_PRODUCT_TEST_CASE`. * **TEMPLATE_TEST_CASE(** _test name_ , _tags_, _type1_, _type2_, ..., _typen_ **)** @@ -147,9 +148,48 @@ TEMPLATE_TEST_CASE( "vectors can be sized and resized", "[vector][template]", in } ``` +* **TEMPLATE_PRODUCT_TEST_CASE(** _test name_ , _tags_, (_template-type1_, _template-type2_, ..., _template-typen_), (_template-arg1_, _template-arg2_, ..., _template-argm_) **)** + +_template-type1_ through _template-typen_ is list of template template +types which should be combined with each of _template-arg1_ through + _template-argm_, resulting in _n * m_ test cases. Inside the test case, +the resulting type is available under the name of `TestType`. + +To specify more than 1 type as a single _template-type_ or _template-arg_, +you must enclose the types in an additional set of parentheses, e.g. +`((int, float), (char, double))` specifies 2 template-args, each +consisting of 2 concrete types (`int`, `float` and `char`, `double` +respectively). You can also omit the outer set of parentheses if you +specify only one type as the full set of either the _template-types_, +or the _template-args_. + + +Example: +``` +template< typename T> +struct Foo { + size_t size() { + return 0; + } +}; + +TEMPLATE_PRODUCT_TEST_CASE("A Template product test case", "[template][product]", (std::vector, Foo), (int, float)) { + TestType x; + REQUIRE(x.size() == 0); +} +``` + +You can also have different arities in the _template-arg_ packs: +``` +TEMPLATE_PRODUCT_TEST_CASE("Product with differing arities", "[template][product]", std::tuple, (int, (int, double), (int, double, float))) { + TestType x; + REQUIRE(std::tuple_size<TestType>::value >= 1); +} +``` + _While there is an upper limit on the number of types you can specify -in single `TEMPLATE_TEST_CASE`, the limit is very high and should not -be encountered in practice._ +in single `TEMPLATE_TEST_CASE` or `TEMPLATE_PRODUCT_TEST_CASE`, the limit +is very high and should not be encountered in practice._ --- diff --git a/packages/Catch2/docs/test-fixtures.md b/packages/Catch2/docs/test-fixtures.md index bfdb1b3c53923a40405653695a33ad50bac2ba14..6b29ce68b1707a51963d99fea26dbb4c92ce71da 100644 --- a/packages/Catch2/docs/test-fixtures.md +++ b/packages/Catch2/docs/test-fixtures.md @@ -31,16 +31,22 @@ class UniqueTestsFixture { The two test cases here will create uniquely-named derived classes of UniqueTestsFixture and thus can access the `getID()` protected method and `conn` member variables. This ensures that both the test cases are able to create a DBConnection using the same method (DRY principle) and that any ID's created are unique such that the order that tests are executed does not matter. -Catch2 also provides `TEMPLATE_TEST_CASE_METHOD` that can be used together -with templated fixtures to perform tests for multiple different types. -However, unlike `TEST_CASE_METHOD`, `TEMPLATE_TEST_CASE_METHOD` requires -the tag specification to be non-empty, as it is followed by further macros -arguments. +Catch2 also provides `TEMPLATE_TEST_CASE_METHOD` and +`TEMPLATE_PRODUCT_TEST_CASE_METHOD` that can be used together +with templated fixtures and templated template fixtures to perform +tests for multiple different types. Unlike `TEST_CASE_METHOD`, +`TEMPLATE_TEST_CASE_METHOD` and `TEMPLATE_PRODUCT_TEST_CASE_METHOD` do +require the tag specification to be non-empty, as it is followed by +further macro arguments. Also note that, because of limitations of the C++ preprocessor, if you want to specify a type with multiple template parameters, you need to enclose it in parentheses, e.g. `std::map<int, std::string>` needs to be passed as `(std::map<int, std::string>)`. +In the case of `TEMPLATE_PRODUCT_TEST_CASE_METHOD`, if a member of the +type list should consist of more than single type, it needs to be enclosed +in another pair of parentheses, e.g. `(std::map, std::pair)` and +`((int, float), (char, double))`. Example: ```cpp @@ -54,11 +60,29 @@ struct Template_Fixture { TEMPLATE_TEST_CASE_METHOD(Template_Fixture,"A TEMPLATE_TEST_CASE_METHOD based test run that succeeds", "[class][template]", int, float, double) { REQUIRE( Template_Fixture<TestType>::m_a == 1 ); } + +template<typename T> +struct Template_Template_Fixture { + Template_Template_Fixture() {} + + T m_a; +}; + +template<typename T> +struct Foo_class { + size_t size() { + return 0; + } +}; + +TEMPLATE_PRODUCT_TEST_CASE_METHOD(Template_Template_Fixture, "A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test succeeds", "[class][template]", (Foo_class, std::vector), int) { + REQUIRE( Template_Template_Fixture<TestType>::m_a.size() == 0 ); +} ``` _While there is an upper limit on the number of types you can specify -in single `TEMPLATE_TEST_CASE`, the limit is very high and should not -be encountered in practice._ +in single `TEMPLATE_TEST_CASE_METHOD` or `TEMPLATE_PRODUCT_TEST_CASE_METHOD`, +the limit is very high and should not be encountered in practice._ --- diff --git a/packages/Catch2/docs/tutorial.md b/packages/Catch2/docs/tutorial.md index 247d5d86e29ef805aae5ceb945a5c1a4c691ccb4..7c0f81450a860e24354266dbd429bd2f1e0cc77b 100644 --- a/packages/Catch2/docs/tutorial.md +++ b/packages/Catch2/docs/tutorial.md @@ -260,8 +260,9 @@ Do not write your tests in header files! ## Type parametrised test cases Test cases in Catch2 can be also parametrised by type, via the -`TEMPLATE_TEST_CASE` macro, which behaves in the same way the `TEST_CASE` -macro, but is run for every type. +`TEMPLATE_TEST_CASE` and `TEMPLATE_PRODUCT_TEST_CASE` macros, +which behave in the same way the `TEST_CASE` macro, but are run for +every type or type combination. For more details, see our documentation on [test cases and sections](test-cases-and-sections.md#type-parametrised-test-cases). diff --git a/packages/Catch2/include/catch.hpp b/packages/Catch2/include/catch.hpp index b0d3d34181030b69ba6a4fdbd08499ec05afc4b3..727f602ee738b1fda8b88fe8016074209068e14c 100644 --- a/packages/Catch2/include/catch.hpp +++ b/packages/Catch2/include/catch.hpp @@ -148,9 +148,13 @@ #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR #define CATCH_TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ ) #define CATCH_TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE( __VA_ARGS__ ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, __VA_ARGS__ ) #else #define CATCH_TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ ) ) #define CATCH_TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE( __VA_ARGS__ ) ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, __VA_ARGS__ ) ) #endif @@ -226,9 +230,13 @@ #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR #define TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ ) #define TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#define TEMPLATE_PRODUCT_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE( __VA_ARGS__ ) +#define TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, __VA_ARGS__ ) #else #define TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ ) ) #define TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) ) +#define TEMPLATE_PRODUCT_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE( __VA_ARGS__ ) ) +#define TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, __VA_ARGS__ ) ) #endif @@ -313,9 +321,13 @@ using Catch::Detail::Approx; #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR #define CATCH_TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) ) #define CATCH_TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), className ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE( ... ) CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) #else #define CATCH_TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) ) ) #define CATCH_TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), className ) ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE( ... ) CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ ) +#define CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) #endif // "BDD-style" convenience wrappers @@ -384,9 +396,13 @@ using Catch::Detail::Approx; #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR #define TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) ) #define TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), className ) +#define TEMPLATE_PRODUCT_TEST_CASE( ... ) TEMPLATE_TEST_CASE( __VA_ARGS__ ) +#define TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) #else #define TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) ) ) #define TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), className ) ) +#define TEMPLATE_PRODUCT_TEST_CASE( ... ) TEMPLATE_TEST_CASE( __VA_ARGS__ ) +#define TEMPLATE_PRODUCT_TEST_CASE_METHOD( className, ... ) TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) #endif #define STATIC_REQUIRE( ... ) (void)(0) diff --git a/packages/Catch2/include/internal/catch_meta.hpp b/packages/Catch2/include/internal/catch_meta.hpp new file mode 100644 index 0000000000000000000000000000000000000000..43ba30fbc0470453048e1a4128bb16db15c22f00 --- /dev/null +++ b/packages/Catch2/include/internal/catch_meta.hpp @@ -0,0 +1,76 @@ +/* + * Created by Jozef on 02/12/2018. + * Copyright 2018 Two Blue Cubes Ltd. All rights reserved. + * + * 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) + */ + +#ifndef TWOBLUECUBES_CATCH_META_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_META_HPP_INCLUDED + +template< typename... > +struct TypeList{}; + +template< typename... > +struct append; + +template< template<typename...> class L1 + , typename...E1 + , template<typename...> class L2 + , typename...E2 + > +struct append< L1<E1...>, L2<E2...> > +{ + using type = L1<E1..., E2...>; +}; + +template< template<typename...> class L1 + , typename...E1 + , template<typename...> class L2 + , typename...E2 + , typename...Rest + > +struct append< L1<E1...>, L2<E2...>, Rest...> +{ + using type = typename append< L1<E1..., E2...>, Rest... >::type; +}; + +template< template<typename...> class + , typename... + > +struct rewrap; + +template< template<typename...> class Container + , template<typename...> class List + , typename...elems + > +struct rewrap<Container, List<elems...>> +{ + using type = TypeList< Container< elems... > >; +}; + +template< template<typename...> class Container + , template<typename...> class List + , class...Elems + , typename...Elements> +struct rewrap<Container, List<Elems...>, Elements...> +{ + using type = typename append<TypeList<Container<Elems...>>, typename rewrap<Container, Elements...>::type>::type; +}; + +template< template<typename...> class...Containers > +struct combine +{ + template< typename...Types > + struct with_types + { + template< template <typename...> class Final > + struct into + { + using type = typename append<Final<>, typename rewrap<Containers, Types...>::type...>::type; + }; + }; +}; + +#endif // TWOBLUECUBES_CATCH_META_HPP_INCLUDED diff --git a/packages/Catch2/include/internal/catch_preprocessor.hpp b/packages/Catch2/include/internal/catch_preprocessor.hpp index 0bfb660f5c3d21693eadd40fe85056984b8ab3c4..e58e0bc583c0f10a028e78452b8a549877915429 100644 --- a/packages/Catch2/include/internal/catch_preprocessor.hpp +++ b/packages/Catch2/include/internal/catch_preprocessor.hpp @@ -71,4 +71,9 @@ #define INTERNAL_CATCH_TEMPLATE_UNIQUE_NAME(Name, ...) INTERNAL_CATCH_TEMPLATE_UNIQUE_NAME1(Name, INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__))) #endif +#define INTERNAL_CATCH_MAKE_TYPE_LIST(types) TypeList<INTERNAL_CATCH_REMOVE_PARENS(types)> + +#define INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(types)\ + CATCH_REC_LIST(INTERNAL_CATCH_MAKE_TYPE_LIST,INTERNAL_CATCH_REMOVE_PARENS(types)) + #endif // TWOBLUECUBES_CATCH_PREPROCESSOR_HPP_INCLUDED diff --git a/packages/Catch2/include/internal/catch_test_registry.h b/packages/Catch2/include/internal/catch_test_registry.h index 060cb374e704a523eeef47e1a272ba255ae85de8..7ad8c802d22a32d7ce417632b8e886d19c2b2e79 100644 --- a/packages/Catch2/include/internal/catch_test_registry.h +++ b/packages/Catch2/include/internal/catch_test_registry.h @@ -14,6 +14,7 @@ #include "catch_stringref.h" #include "catch_type_traits.hpp" #include "catch_preprocessor.hpp" +#include "catch_meta.hpp" namespace Catch { @@ -150,6 +151,38 @@ struct AutoReg : NonCopyable { return 0;\ }(); + #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2(TestName, TestFuncName, Name, Tags, TmplTypes, TypesList) \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + template<typename TestType> static void TestFuncName(); \ + namespace { \ + template<typename... Types> \ + struct TestName { \ + TestName() { \ + CATCH_INTERNAL_CHECK_UNIQUE_TYPES(Types...) \ + int index = 0; \ + using expander = int[]; \ + (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestFuncName<Types> ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ Name " - " + Catch::StringMaker<int>::convert(index++), Tags } ), 0)... };/* NOLINT */ \ + } \ + }; \ + static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){ \ + using TestInit = combine<INTERNAL_CATCH_REMOVE_PARENS(TmplTypes)> \ + ::with_types<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(TypesList)>::into<TestName>::type; \ + TestInit(); \ + return 0; \ + }(); \ + } \ + CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \ + template<typename TestType> \ + static void TestFuncName() + +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR + #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE(Name, Tags, ...)\ + INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ),Name,Tags,__VA_ARGS__) +#else + #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE(Name, Tags, ...)\ + INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, __VA_ARGS__ ) ) +#endif + #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( TestNameClass, TestName, ClassName, Name, Tags, ... ) \ CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ namespace{ \ @@ -180,4 +213,39 @@ struct AutoReg : NonCopyable { INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____C_L_A_S_S____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) , ClassName, Name, Tags, __VA_ARGS__ ) ) #endif + #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2(TestNameClass, TestName, ClassName, Name, Tags, TmplTypes, TypesList)\ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + template<typename TestType> \ + struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName <TestType>) { \ + void test();\ + };\ + namespace {\ + template<typename...Types>\ + struct TestNameClass{\ + TestNameClass(){\ + CATCH_INTERNAL_CHECK_UNIQUE_TYPES(Types...)\ + int index = 0;\ + using expander = int[];\ + (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestName<Types>::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ Name " - " + Catch::StringMaker<int>::convert(index++), Tags } ), 0)... };/* NOLINT */ \ + }\ + };\ + static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\ + using TestInit = combine<INTERNAL_CATCH_REMOVE_PARENS(TmplTypes)>\ + ::with_types<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(TypesList)>::into<TestNameClass>::type;\ + TestInit();\ + return 0;\ + }(); \ + }\ + CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \ + template<typename TestType> \ + void TestName<TestType>::test() + +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR + #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( ClassName, Name, Tags, ... )\ + INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), ClassName, Name, Tags, __VA_ARGS__ ) +#else + #define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( ClassName, Name, Tags, ... )\ + INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), ClassName, Name, Tags, __VA_ARGS__ ) ) +#endif + #endif // TWOBLUECUBES_CATCH_TEST_REGISTRY_HPP_INCLUDED diff --git a/packages/Catch2/projects/CMakeLists.txt b/packages/Catch2/projects/CMakeLists.txt index 5dc945e8302986b58b33e93fc4fa56be19705715..fbd3fd2ee2cb49b0ee0a2ea364d5b5166235c24e 100644 --- a/packages/Catch2/projects/CMakeLists.txt +++ b/packages/Catch2/projects/CMakeLists.txt @@ -118,6 +118,7 @@ set(INTERNAL_HEADERS ${HEADER_DIR}/internal/catch_matchers_string.h ${HEADER_DIR}/internal/catch_matchers_vector.h ${HEADER_DIR}/internal/catch_message.h + ${HEADER_DIR}/internal/catch_meta.hpp ${HEADER_DIR}/internal/catch_objc.hpp ${HEADER_DIR}/internal/catch_objc_arc.hpp ${HEADER_DIR}/internal/catch_option.hpp diff --git a/packages/Catch2/projects/SelfTest/Baselines/compact.sw.approved.txt b/packages/Catch2/projects/SelfTest/Baselines/compact.sw.approved.txt index 1b32b42e9664ee7afb7019abf82ca3c36150422d..547678ceaf728571cfacbdcb3b003ad21ba52178 100644 --- a/packages/Catch2/projects/SelfTest/Baselines/compact.sw.approved.txt +++ b/packages/Catch2/projects/SelfTest/Baselines/compact.sw.approved.txt @@ -159,6 +159,14 @@ Generators.tests.cpp:<line number>: passed: x < y for: 10 < 109 Generators.tests.cpp:<line number>: passed: x < y for: 10 < 110 Class.tests.cpp:<line number>: failed: s == "world" for: "hello" == "world" Class.tests.cpp:<line number>: passed: s == "hello" for: "hello" == "hello" +Class.tests.cpp:<line number>: failed: Template_Fixture_2<TestType>::m_a.size() == 1 for: 0 == 1 +Class.tests.cpp:<line number>: failed: Template_Fixture_2<TestType>::m_a.size() == 1 for: 0 == 1 +Class.tests.cpp:<line number>: failed: Template_Fixture_2<TestType>::m_a.size() == 1 for: 0 == 1 +Class.tests.cpp:<line number>: failed: Template_Fixture_2<TestType>::m_a.size() == 1 for: 0 == 1 +Class.tests.cpp:<line number>: passed: Template_Fixture_2<TestType>::m_a.size() == 0 for: 0 == 0 +Class.tests.cpp:<line number>: passed: Template_Fixture_2<TestType>::m_a.size() == 0 for: 0 == 0 +Class.tests.cpp:<line number>: passed: Template_Fixture_2<TestType>::m_a.size() == 0 for: 0 == 0 +Class.tests.cpp:<line number>: passed: Template_Fixture_2<TestType>::m_a.size() == 0 for: 0 == 0 Class.tests.cpp:<line number>: failed: Template_Fixture<TestType>::m_a == 2 for: 1.0 == 2 Class.tests.cpp:<line number>: failed: Template_Fixture<TestType>::m_a == 2 for: 1.0f == 2 Class.tests.cpp:<line number>: failed: Template_Fixture<TestType>::m_a == 2 for: 1 == 2 @@ -167,6 +175,10 @@ 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>: failed: m_a == 2 for: 1 == 2 Class.tests.cpp:<line number>: passed: m_a == 1 for: 1 == 1 +Misc.tests.cpp:<line number>: passed: x.size() == 0 for: 0 == 0 +Misc.tests.cpp:<line number>: passed: x.size() == 0 for: 0 == 0 +Misc.tests.cpp:<line number>: passed: x.size() == 0 for: 0 == 0 +Misc.tests.cpp:<line number>: passed: x.size() == 0 for: 0 == 0 Approx.tests.cpp:<line number>: passed: d == 1.23_a for: 1.23 == Approx( 1.23 ) Approx.tests.cpp:<line number>: passed: d != 1.22_a for: 1.23 != Approx( 1.22 ) Approx.tests.cpp:<line number>: passed: -d == -1.23_a for: -1.23 == Approx( -1.23 ) @@ -750,6 +762,9 @@ CmdLine.tests.cpp:<line number>: passed: cli.parse({"test", "--use-colour", "no" CmdLine.tests.cpp:<line number>: passed: config.useColour == UseColour::No for: 2 == 2 CmdLine.tests.cpp:<line number>: passed: !result for: true CmdLine.tests.cpp:<line number>: passed: result.errorMessage(), Contains( "colour mode must be one of" ) for: "colour mode must be one of: auto, yes or no. 'wrong' not recognised" contains: "colour mode must be one of" +Misc.tests.cpp:<line number>: passed: std::tuple_size<TestType>::value >= 1 for: 1 >= 1 +Misc.tests.cpp:<line number>: passed: std::tuple_size<TestType>::value >= 1 for: 2 >= 1 +Misc.tests.cpp:<line number>: passed: std::tuple_size<TestType>::value >= 1 for: 3 >= 1 Decomposition.tests.cpp:<line number>: failed: truthy(false) for: Hey, its truthy! Matchers.tests.cpp:<line number>: failed: testStringForMatching(), Matches("this STRING contains 'abc' as a substring") for: "this string contains 'abc' as a substring" matches "this STRING contains 'abc' as a substring" case sensitively Matchers.tests.cpp:<line number>: failed: testStringForMatching(), Matches("contains 'abc' as a substring") for: "this string contains 'abc' as a substring" matches "contains 'abc' as a substring" case sensitively @@ -1389,5 +1404,5 @@ Misc.tests.cpp:<line number>: passed: v.size() == 5 for: 5 == 5 Misc.tests.cpp:<line number>: passed: v.capacity() >= 5 for: 5 >= 5 Misc.tests.cpp:<line number>: passed: Misc.tests.cpp:<line number>: passed: -Failed 65 test cases, failed 125 assertions. +Failed 69 test cases, failed 129 assertions. diff --git a/packages/Catch2/projects/SelfTest/Baselines/console.std.approved.txt b/packages/Catch2/projects/SelfTest/Baselines/console.std.approved.txt index 5e82417e30a5f4d732babb1870e56549e3563a2d..df483fda232e171c514b161fa33c2cee525a8545 100644 --- a/packages/Catch2/projects/SelfTest/Baselines/console.std.approved.txt +++ b/packages/Catch2/projects/SelfTest/Baselines/console.std.approved.txt @@ -92,6 +92,50 @@ Class.tests.cpp:<line number>: FAILED: with expansion: "hello" == "world" +------------------------------------------------------------------------------- +A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - 0 +------------------------------------------------------------------------------- +Class.tests.cpp:<line number> +............................................................................... + +Class.tests.cpp:<line number>: FAILED: + REQUIRE( Template_Fixture_2<TestType>::m_a.size() == 1 ) +with expansion: + 0 == 1 + +------------------------------------------------------------------------------- +A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - 1 +------------------------------------------------------------------------------- +Class.tests.cpp:<line number> +............................................................................... + +Class.tests.cpp:<line number>: FAILED: + REQUIRE( Template_Fixture_2<TestType>::m_a.size() == 1 ) +with expansion: + 0 == 1 + +------------------------------------------------------------------------------- +A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - 2 +------------------------------------------------------------------------------- +Class.tests.cpp:<line number> +............................................................................... + +Class.tests.cpp:<line number>: FAILED: + REQUIRE( Template_Fixture_2<TestType>::m_a.size() == 1 ) +with expansion: + 0 == 1 + +------------------------------------------------------------------------------- +A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - 3 +------------------------------------------------------------------------------- +Class.tests.cpp:<line number> +............................................................................... + +Class.tests.cpp:<line number>: FAILED: + REQUIRE( Template_Fixture_2<TestType>::m_a.size() == 1 ) +with expansion: + 0 == 1 + ------------------------------------------------------------------------------- A TEMPLATE_TEST_CASE_METHOD based test run that fails - double ------------------------------------------------------------------------------- @@ -1126,6 +1170,6 @@ due to unexpected exception with message: Why would you throw a std::string? =============================================================================== -test cases: 228 | 172 passed | 52 failed | 4 failed as expected -assertions: 1310 | 1178 passed | 111 failed | 21 failed as expected +test cases: 243 | 183 passed | 56 failed | 4 failed as expected +assertions: 1325 | 1189 passed | 115 failed | 21 failed as expected diff --git a/packages/Catch2/projects/SelfTest/Baselines/console.sw.approved.txt b/packages/Catch2/projects/SelfTest/Baselines/console.sw.approved.txt index 286384258b1cdd7013fb420ffba7bd6be3a26ffa..7069d0b12606c221550cb25ba4e58b915bc56191 100644 --- a/packages/Catch2/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/packages/Catch2/projects/SelfTest/Baselines/console.sw.approved.txt @@ -1577,6 +1577,94 @@ Class.tests.cpp:<line number>: PASSED: with expansion: "hello" == "hello" +------------------------------------------------------------------------------- +A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - 0 +------------------------------------------------------------------------------- +Class.tests.cpp:<line number> +............................................................................... + +Class.tests.cpp:<line number>: FAILED: + REQUIRE( Template_Fixture_2<TestType>::m_a.size() == 1 ) +with expansion: + 0 == 1 + +------------------------------------------------------------------------------- +A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - 1 +------------------------------------------------------------------------------- +Class.tests.cpp:<line number> +............................................................................... + +Class.tests.cpp:<line number>: FAILED: + REQUIRE( Template_Fixture_2<TestType>::m_a.size() == 1 ) +with expansion: + 0 == 1 + +------------------------------------------------------------------------------- +A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - 2 +------------------------------------------------------------------------------- +Class.tests.cpp:<line number> +............................................................................... + +Class.tests.cpp:<line number>: FAILED: + REQUIRE( Template_Fixture_2<TestType>::m_a.size() == 1 ) +with expansion: + 0 == 1 + +------------------------------------------------------------------------------- +A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - 3 +------------------------------------------------------------------------------- +Class.tests.cpp:<line number> +............................................................................... + +Class.tests.cpp:<line number>: FAILED: + REQUIRE( Template_Fixture_2<TestType>::m_a.size() == 1 ) +with expansion: + 0 == 1 + +------------------------------------------------------------------------------- +A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that succeeds - 0 +------------------------------------------------------------------------------- +Class.tests.cpp:<line number> +............................................................................... + +Class.tests.cpp:<line number>: PASSED: + REQUIRE( Template_Fixture_2<TestType>::m_a.size() == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that succeeds - 1 +------------------------------------------------------------------------------- +Class.tests.cpp:<line number> +............................................................................... + +Class.tests.cpp:<line number>: PASSED: + REQUIRE( Template_Fixture_2<TestType>::m_a.size() == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that succeeds - 2 +------------------------------------------------------------------------------- +Class.tests.cpp:<line number> +............................................................................... + +Class.tests.cpp:<line number>: PASSED: + REQUIRE( Template_Fixture_2<TestType>::m_a.size() == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that succeeds - 3 +------------------------------------------------------------------------------- +Class.tests.cpp:<line number> +............................................................................... + +Class.tests.cpp:<line number>: PASSED: + REQUIRE( Template_Fixture_2<TestType>::m_a.size() == 0 ) +with expansion: + 0 == 0 + ------------------------------------------------------------------------------- A TEMPLATE_TEST_CASE_METHOD based test run that fails - double ------------------------------------------------------------------------------- @@ -1665,6 +1753,50 @@ Class.tests.cpp:<line number>: PASSED: with expansion: 1 == 1 +------------------------------------------------------------------------------- +A Template product test case - 0 +------------------------------------------------------------------------------- +Misc.tests.cpp:<line number> +............................................................................... + +Misc.tests.cpp:<line number>: PASSED: + REQUIRE( x.size() == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +A Template product test case - 1 +------------------------------------------------------------------------------- +Misc.tests.cpp:<line number> +............................................................................... + +Misc.tests.cpp:<line number>: PASSED: + REQUIRE( x.size() == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +A Template product test case - 2 +------------------------------------------------------------------------------- +Misc.tests.cpp:<line number> +............................................................................... + +Misc.tests.cpp:<line number>: PASSED: + REQUIRE( x.size() == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +A Template product test case - 3 +------------------------------------------------------------------------------- +Misc.tests.cpp:<line number> +............................................................................... + +Misc.tests.cpp:<line number>: PASSED: + REQUIRE( x.size() == 0 ) +with expansion: + 0 == 0 + ------------------------------------------------------------------------------- A comparison that uses literals instead of the normal constructor ------------------------------------------------------------------------------- @@ -5767,6 +5899,39 @@ with expansion: "colour mode must be one of: auto, yes or no. 'wrong' not recognised" contains: "colour mode must be one of" +------------------------------------------------------------------------------- +Product with differing arities - 0 +------------------------------------------------------------------------------- +Misc.tests.cpp:<line number> +............................................................................... + +Misc.tests.cpp:<line number>: PASSED: + REQUIRE( std::tuple_size<TestType>::value >= 1 ) +with expansion: + 1 >= 1 + +------------------------------------------------------------------------------- +Product with differing arities - 1 +------------------------------------------------------------------------------- +Misc.tests.cpp:<line number> +............................................................................... + +Misc.tests.cpp:<line number>: PASSED: + REQUIRE( std::tuple_size<TestType>::value >= 1 ) +with expansion: + 2 >= 1 + +------------------------------------------------------------------------------- +Product with differing arities - 2 +------------------------------------------------------------------------------- +Misc.tests.cpp:<line number> +............................................................................... + +Misc.tests.cpp:<line number>: PASSED: + REQUIRE( std::tuple_size<TestType>::value >= 1 ) +with expansion: + 3 >= 1 + ------------------------------------------------------------------------------- Reconstruction should be based on stringification: #914 ------------------------------------------------------------------------------- @@ -10464,6 +10629,6 @@ Misc.tests.cpp:<line number> Misc.tests.cpp:<line number>: PASSED: =============================================================================== -test cases: 228 | 159 passed | 65 failed | 4 failed as expected -assertions: 1324 | 1178 passed | 125 failed | 21 failed as expected +test cases: 243 | 170 passed | 69 failed | 4 failed as expected +assertions: 1339 | 1189 passed | 129 failed | 21 failed as expected diff --git a/packages/Catch2/projects/SelfTest/Baselines/junit.sw.approved.txt b/packages/Catch2/projects/SelfTest/Baselines/junit.sw.approved.txt index cb03cdb790ff171ba0193fcc1b17b043e33820eb..beb8b459da6a148712fe25e2044476172f91f22d 100644 --- a/packages/Catch2/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/packages/Catch2/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <testsuitesloose text artifact > - <testsuite name="<exe-name>" errors="17" failures="109" tests="1325" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> + <testsuite name="<exe-name>" errors="17" failures="113" tests="1340" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> <testcase classname="<exe-name>.global" name="# A test name that starts with a #" time="{duration}"/> <testcase classname="<exe-name>.global" name="#1005: Comparing pointer to int and long (NULL can be either on various systems)" time="{duration}"/> <testcase classname="<exe-name>.global" name="#1027" time="{duration}"/> @@ -77,6 +77,30 @@ Class.tests.cpp:<line number> </failure> </testcase> <testcase classname="<exe-name>.TestClass" name="A METHOD_AS_TEST_CASE based test run that succeeds" time="{duration}"/> + <testcase classname="<exe-name>.Template_Fixture_2" name="A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - 0" time="{duration}"> + <failure message="0 == 1" type="REQUIRE"> +Class.tests.cpp:<line number> + </failure> + </testcase> + <testcase classname="<exe-name>.Template_Fixture_2" name="A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - 1" time="{duration}"> + <failure message="0 == 1" type="REQUIRE"> +Class.tests.cpp:<line number> + </failure> + </testcase> + <testcase classname="<exe-name>.Template_Fixture_2" name="A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - 2" time="{duration}"> + <failure message="0 == 1" type="REQUIRE"> +Class.tests.cpp:<line number> + </failure> + </testcase> + <testcase classname="<exe-name>.Template_Fixture_2" name="A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - 3" time="{duration}"> + <failure message="0 == 1" type="REQUIRE"> +Class.tests.cpp:<line number> + </failure> + </testcase> + <testcase classname="<exe-name>.Template_Fixture_2" name="A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that succeeds - 0" time="{duration}"/> + <testcase classname="<exe-name>.Template_Fixture_2" name="A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that succeeds - 1" time="{duration}"/> + <testcase classname="<exe-name>.Template_Fixture_2" name="A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that succeeds - 2" time="{duration}"/> + <testcase classname="<exe-name>.Template_Fixture_2" name="A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that succeeds - 3" time="{duration}"/> <testcase classname="<exe-name>.Template_Fixture" name="A TEMPLATE_TEST_CASE_METHOD based test run that fails - double" time="{duration}"> <failure message="1.0 == 2" type="REQUIRE"> Class.tests.cpp:<line number> @@ -101,6 +125,10 @@ Class.tests.cpp:<line number> </failure> </testcase> <testcase classname="<exe-name>.Fixture" name="A TEST_CASE_METHOD based test run that succeeds" time="{duration}"/> + <testcase classname="<exe-name>.global" name="A Template product test case - 0" time="{duration}"/> + <testcase classname="<exe-name>.global" name="A Template product test case - 1" time="{duration}"/> + <testcase classname="<exe-name>.global" name="A Template product test case - 2" time="{duration}"/> + <testcase classname="<exe-name>.global" name="A Template product test case - 3" time="{duration}"/> <testcase classname="<exe-name>.global" name="A comparison that uses literals instead of the normal constructor" time="{duration}"/> <testcase classname="<exe-name>.global" name="A couple of nested sections followed by a failure" time="{duration}"> <failure type="FAIL"> @@ -526,6 +554,9 @@ Message.tests.cpp:<line number> <testcase classname="<exe-name>.global" name="Process can be configured on command line/use-colour/yes" time="{duration}"/> <testcase classname="<exe-name>.global" name="Process can be configured on command line/use-colour/no" time="{duration}"/> <testcase classname="<exe-name>.global" name="Process can be configured on command line/use-colour/error" time="{duration}"/> + <testcase classname="<exe-name>.global" name="Product with differing arities - 0" time="{duration}"/> + <testcase classname="<exe-name>.global" name="Product with differing arities - 1" time="{duration}"/> + <testcase classname="<exe-name>.global" name="Product with differing arities - 2" time="{duration}"/> <testcase classname="<exe-name>.global" name="Reconstruction should be based on stringification: #914" time="{duration}"> <failure message="Hey, its truthy!" type="CHECK"> Decomposition.tests.cpp:<line number> diff --git a/packages/Catch2/projects/SelfTest/Baselines/xml.sw.approved.txt b/packages/Catch2/projects/SelfTest/Baselines/xml.sw.approved.txt index 7e02b772ea6e02e80a29d7d5827a6c15267ab397..b2d0c61e28d5b2a5c197219b01dd9d4cf5a14656 100644 --- a/packages/Catch2/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/packages/Catch2/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -1347,6 +1347,94 @@ </Expression> <OverallResult success="true"/> </TestCase> + <TestCase name="A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - 0" tags="[.][class][failing][product][template]" filename="projects/<exe-name>/UsageTests/Class.tests.cpp" > + <Expression success="false" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Class.tests.cpp" > + <Original> + Template_Fixture_2<TestType>::m_a.size() == 1 + </Original> + <Expanded> + 0 == 1 + </Expanded> + </Expression> + <OverallResult success="false"/> + </TestCase> + <TestCase name="A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - 1" tags="[.][class][failing][product][template]" filename="projects/<exe-name>/UsageTests/Class.tests.cpp" > + <Expression success="false" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Class.tests.cpp" > + <Original> + Template_Fixture_2<TestType>::m_a.size() == 1 + </Original> + <Expanded> + 0 == 1 + </Expanded> + </Expression> + <OverallResult success="false"/> + </TestCase> + <TestCase name="A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - 2" tags="[.][class][failing][product][template]" filename="projects/<exe-name>/UsageTests/Class.tests.cpp" > + <Expression success="false" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Class.tests.cpp" > + <Original> + Template_Fixture_2<TestType>::m_a.size() == 1 + </Original> + <Expanded> + 0 == 1 + </Expanded> + </Expression> + <OverallResult success="false"/> + </TestCase> + <TestCase name="A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - 3" tags="[.][class][failing][product][template]" filename="projects/<exe-name>/UsageTests/Class.tests.cpp" > + <Expression success="false" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Class.tests.cpp" > + <Original> + Template_Fixture_2<TestType>::m_a.size() == 1 + </Original> + <Expanded> + 0 == 1 + </Expanded> + </Expression> + <OverallResult success="false"/> + </TestCase> + <TestCase name="A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that succeeds - 0" tags="[class][product][template]" filename="projects/<exe-name>/UsageTests/Class.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Class.tests.cpp" > + <Original> + Template_Fixture_2<TestType>::m_a.size() == 0 + </Original> + <Expanded> + 0 == 0 + </Expanded> + </Expression> + <OverallResult success="true"/> + </TestCase> + <TestCase name="A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that succeeds - 1" tags="[class][product][template]" filename="projects/<exe-name>/UsageTests/Class.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Class.tests.cpp" > + <Original> + Template_Fixture_2<TestType>::m_a.size() == 0 + </Original> + <Expanded> + 0 == 0 + </Expanded> + </Expression> + <OverallResult success="true"/> + </TestCase> + <TestCase name="A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that succeeds - 2" tags="[class][product][template]" filename="projects/<exe-name>/UsageTests/Class.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Class.tests.cpp" > + <Original> + Template_Fixture_2<TestType>::m_a.size() == 0 + </Original> + <Expanded> + 0 == 0 + </Expanded> + </Expression> + <OverallResult success="true"/> + </TestCase> + <TestCase name="A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that succeeds - 3" tags="[class][product][template]" filename="projects/<exe-name>/UsageTests/Class.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Class.tests.cpp" > + <Original> + Template_Fixture_2<TestType>::m_a.size() == 0 + </Original> + <Expanded> + 0 == 0 + </Expanded> + </Expression> + <OverallResult success="true"/> + </TestCase> <TestCase name="A TEMPLATE_TEST_CASE_METHOD based test run that fails - double" tags="[.][class][failing][template]" filename="projects/<exe-name>/UsageTests/Class.tests.cpp" > <Expression success="false" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Class.tests.cpp" > <Original> @@ -1435,6 +1523,50 @@ </Expression> <OverallResult success="true"/> </TestCase> + <TestCase name="A Template product test case - 0" tags="[product][template]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" > + <Original> + x.size() == 0 + </Original> + <Expanded> + 0 == 0 + </Expanded> + </Expression> + <OverallResult success="true"/> + </TestCase> + <TestCase name="A Template product test case - 1" tags="[product][template]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" > + <Original> + x.size() == 0 + </Original> + <Expanded> + 0 == 0 + </Expanded> + </Expression> + <OverallResult success="true"/> + </TestCase> + <TestCase name="A Template product test case - 2" tags="[product][template]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" > + <Original> + x.size() == 0 + </Original> + <Expanded> + 0 == 0 + </Expanded> + </Expression> + <OverallResult success="true"/> + </TestCase> + <TestCase name="A Template product test case - 3" tags="[product][template]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" > + <Original> + x.size() == 0 + </Original> + <Expanded> + 0 == 0 + </Expanded> + </Expression> + <OverallResult success="true"/> + </TestCase> <TestCase name="A comparison that uses literals instead of the normal constructor" tags="[Approx]" filename="projects/<exe-name>/UsageTests/Approx.tests.cpp" > <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Approx.tests.cpp" > <Original> @@ -6732,6 +6864,39 @@ </Section> <OverallResult success="true"/> </TestCase> + <TestCase name="Product with differing arities - 0" tags="[product][template]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" > + <Original> + std::tuple_size<TestType>::value >= 1 + </Original> + <Expanded> + 1 >= 1 + </Expanded> + </Expression> + <OverallResult success="true"/> + </TestCase> + <TestCase name="Product with differing arities - 1" tags="[product][template]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" > + <Original> + std::tuple_size<TestType>::value >= 1 + </Original> + <Expanded> + 2 >= 1 + </Expanded> + </Expression> + <OverallResult success="true"/> + </TestCase> + <TestCase name="Product with differing arities - 2" tags="[product][template]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" > + <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" > + <Original> + std::tuple_size<TestType>::value >= 1 + </Original> + <Expanded> + 3 >= 1 + </Expanded> + </Expression> + <OverallResult success="true"/> + </TestCase> <TestCase name="Reconstruction should be based on stringification: #914" tags="[.][Decomposition][failing]" filename="projects/<exe-name>/UsageTests/Decomposition.tests.cpp" > <Expression success="false" type="CHECK" filename="projects/<exe-name>/UsageTests/Decomposition.tests.cpp" > <Original> @@ -12099,7 +12264,7 @@ loose text artifact </Section> <OverallResult success="true"/> </TestCase> - <OverallResults successes="1178" failures="126" expectedFailures="21"/> + <OverallResults successes="1189" failures="130" expectedFailures="21"/> </Group> - <OverallResults successes="1178" failures="125" expectedFailures="21"/> + <OverallResults successes="1189" failures="129" expectedFailures="21"/> </Catch> diff --git a/packages/Catch2/projects/SelfTest/UsageTests/Class.tests.cpp b/packages/Catch2/projects/SelfTest/UsageTests/Class.tests.cpp index 6f9bd85e8a848bfe75f551e55c997156411388aa..3bde1d82ab66e18a5825270e24e105df558210d3 100644 --- a/packages/Catch2/projects/SelfTest/UsageTests/Class.tests.cpp +++ b/packages/Catch2/projects/SelfTest/UsageTests/Class.tests.cpp @@ -46,6 +46,18 @@ struct Template_Fixture { T m_a; }; +template<typename T> +struct Template_Fixture_2 { + Template_Fixture_2() {} + + T m_a; +}; + +template< typename T> +struct Template_Foo { + size_t size() { return 0; } +}; + #endif @@ -62,6 +74,11 @@ TEMPLATE_TEST_CASE_METHOD(Template_Fixture, "A TEMPLATE_TEST_CASE_METHOD based t REQUIRE( Template_Fixture<TestType>::m_a == 1 ); } +TEMPLATE_PRODUCT_TEST_CASE_METHOD(Template_Fixture_2, "A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that succeeds","[class][template][product]",(std::vector,Template_Foo),(int,float)) +{ + REQUIRE( Template_Fixture_2<TestType>::m_a.size() == 0 ); +} + // We should be able to write our tests within a different namespace namespace Inner { @@ -74,6 +91,11 @@ namespace Inner { REQUIRE( Template_Fixture<TestType>::m_a == 2 ); } + + TEMPLATE_PRODUCT_TEST_CASE_METHOD(Template_Fixture_2, "A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails","[.][class][template][product][failing]",(std::vector,Template_Foo),(int,float)) + { + REQUIRE( Template_Fixture_2<TestType>::m_a.size() == 1 ); + } } diff --git a/packages/Catch2/projects/SelfTest/UsageTests/Misc.tests.cpp b/packages/Catch2/projects/SelfTest/UsageTests/Misc.tests.cpp index 0c3dae1e0b38fba4a2185d01e121d5a0b2b9d3fd..4de6f1aa0df3d84ec5df25e2c131778fea192a4b 100644 --- a/packages/Catch2/projects/SelfTest/UsageTests/Misc.tests.cpp +++ b/packages/Catch2/projects/SelfTest/UsageTests/Misc.tests.cpp @@ -61,6 +61,11 @@ CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS static AutoTestReg autoTestReg; CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS +template<typename T> +struct Foo { + size_t size() { return 0; } +}; + #endif TEST_CASE( "random SECTION tests", "[.][sections][failing]" ) { @@ -301,6 +306,15 @@ TEMPLATE_TEST_CASE( "TemplateTest: vectors can be sized and resized", "[vector][ } } +TEMPLATE_PRODUCT_TEST_CASE("A Template product test case", "[template][product]", (std::vector, Foo), (int, float)) { + TestType x; + REQUIRE(x.size() == 0); +} + +TEMPLATE_PRODUCT_TEST_CASE("Product with differing arities", "[template][product]", std::tuple, (int, (int, double), (int, double, float))) { + REQUIRE(std::tuple_size<TestType>::value >= 1); +} + // https://github.com/philsquared/Catch/issues/166 TEST_CASE("A couple of nested sections followed by a failure", "[failing][.]") { SECTION("Outer")