diff --git a/include/internal/catch_preprocessor.hpp b/include/internal/catch_preprocessor.hpp index e58e0bc5..545e9705 100644 --- a/include/internal/catch_preprocessor.hpp +++ b/include/internal/catch_preprocessor.hpp @@ -57,6 +57,16 @@ #define INTERNAL_CATCH_EXPAND2(...) INTERNAL_CATCH_NO## __VA_ARGS__ #define INTERNAL_CATCH_DEF(...) INTERNAL_CATCH_DEF __VA_ARGS__ #define INTERNAL_CATCH_NOINTERNAL_CATCH_DEF +#define INTERNAL_CATCH_STRINGIZE(...) INTERNAL_CATCH_STRINGIZE2(__VA_ARGS__) +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#define INTERNAL_CATCH_STRINGIZE2(...) #__VA_ARGS__ +#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) +#else +// MSVC is adding extra space and needs another indirection to expand INTERNAL_CATCH_NOINTERNAL_CATCH_DEF +#define INTERNAL_CATCH_STRINGIZE2(...) INTERNAL_CATCH_STRINGIZE3(__VA_ARGS__) +#define INTERNAL_CATCH_STRINGIZE3(...) #__VA_ARGS__ +#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) (INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) + 1) +#endif #define INTERNAL_CATCH_REMOVE_PARENS(...) INTERNAL_CATCH_EXPAND1(INTERNAL_CATCH_DEF __VA_ARGS__) diff --git a/include/internal/catch_test_registry.h b/include/internal/catch_test_registry.h index 7ad8c802..4d247f36 100644 --- a/include/internal/catch_test_registry.h +++ b/include/internal/catch_test_registry.h @@ -161,7 +161,10 @@ struct AutoReg : NonCopyable { CATCH_INTERNAL_CHECK_UNIQUE_TYPES(Types...) \ int index = 0; \ using expander = int[]; \ - (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestFuncName ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ Name " - " + Catch::StringMaker::convert(index++), Tags } ), 0)... };/* NOLINT */ \ + constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TmplTypes))};\ + constexpr char const* types_list[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TypesList))};\ + constexpr auto num_types = sizeof(types_list) / sizeof(types_list[0]);\ + (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestFuncName ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index / num_types]) + "<" + std::string(types_list[index % num_types]) + ">", Tags } ), index++, 0)... };/* NOLINT */\ } \ }; \ static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){ \ @@ -226,7 +229,10 @@ struct AutoReg : NonCopyable { CATCH_INTERNAL_CHECK_UNIQUE_TYPES(Types...)\ int index = 0;\ using expander = int[];\ - (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestName::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ Name " - " + Catch::StringMaker::convert(index++), Tags } ), 0)... };/* NOLINT */ \ + constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TmplTypes))};\ + constexpr char const* types_list[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TypesList))};\ + constexpr auto num_types = sizeof(types_list) / sizeof(types_list[0]);\ + (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestName::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index / num_types]) + "<" + std::string(types_list[index % num_types]) + ">", Tags } ), index++, 0)... };/* NOLINT */ \ }\ };\ static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\ diff --git a/projects/SelfTest/Baselines/compact.sw.approved.txt b/projects/SelfTest/Baselines/compact.sw.approved.txt index 615e368b..0c706c79 100644 --- a/projects/SelfTest/Baselines/compact.sw.approved.txt +++ b/projects/SelfTest/Baselines/compact.sw.approved.txt @@ -793,9 +793,9 @@ CmdLine.tests.cpp:: passed: cli.parse({"test", "--use-colour", "no" CmdLine.tests.cpp:: passed: config.useColour == UseColour::No for: 2 == 2 CmdLine.tests.cpp:: passed: !result for: true CmdLine.tests.cpp:: 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:: passed: std::tuple_size::value >= 1 for: 1 >= 1 -Misc.tests.cpp:: passed: std::tuple_size::value >= 1 for: 2 >= 1 Misc.tests.cpp:: passed: std::tuple_size::value >= 1 for: 3 >= 1 +Misc.tests.cpp:: passed: std::tuple_size::value >= 1 for: 2 >= 1 +Misc.tests.cpp:: passed: std::tuple_size::value >= 1 for: 1 >= 1 Decomposition.tests.cpp:: failed: truthy(false) for: Hey, its truthy! Matchers.tests.cpp:: 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:: failed: testStringForMatching(), Matches("contains 'abc' as a substring") for: "this string contains 'abc' as a substring" matches "contains 'abc' as a substring" case sensitively diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt index a9ca0277..8e2d5718 100644 --- a/projects/SelfTest/Baselines/console.std.approved.txt +++ b/projects/SelfTest/Baselines/console.std.approved.txt @@ -93,7 +93,8 @@ with expansion: "hello" == "world" ------------------------------------------------------------------------------- -A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - 0 +A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - Template_Foo + ------------------------------------------------------------------------------- Class.tests.cpp: ............................................................................... @@ -104,7 +105,8 @@ with expansion: 0 == 1 ------------------------------------------------------------------------------- -A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - 1 +A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - Template_Foo + ------------------------------------------------------------------------------- Class.tests.cpp: ............................................................................... @@ -115,7 +117,8 @@ with expansion: 0 == 1 ------------------------------------------------------------------------------- -A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - 2 +A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - std::vector + ------------------------------------------------------------------------------- Class.tests.cpp: ............................................................................... @@ -126,7 +129,8 @@ with expansion: 0 == 1 ------------------------------------------------------------------------------- -A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - 3 +A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - std::vector + ------------------------------------------------------------------------------- Class.tests.cpp: ............................................................................... diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index 92a78c57..bcaa5ff8 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -1045,7 +1045,8 @@ with expansion: "hello" == "hello" ------------------------------------------------------------------------------- -A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - 0 +A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - Template_Foo + ------------------------------------------------------------------------------- Class.tests.cpp: ............................................................................... @@ -1056,7 +1057,8 @@ with expansion: 0 == 1 ------------------------------------------------------------------------------- -A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - 1 +A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - Template_Foo + ------------------------------------------------------------------------------- Class.tests.cpp: ............................................................................... @@ -1067,7 +1069,8 @@ with expansion: 0 == 1 ------------------------------------------------------------------------------- -A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - 2 +A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - std::vector + ------------------------------------------------------------------------------- Class.tests.cpp: ............................................................................... @@ -1078,7 +1081,8 @@ with expansion: 0 == 1 ------------------------------------------------------------------------------- -A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - 3 +A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that fails - std::vector + ------------------------------------------------------------------------------- Class.tests.cpp: ............................................................................... @@ -1089,7 +1093,8 @@ with expansion: 0 == 1 ------------------------------------------------------------------------------- -A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that succeeds - 0 +A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that succeeds - Template_Foo + ------------------------------------------------------------------------------- Class.tests.cpp: ............................................................................... @@ -1100,7 +1105,8 @@ with expansion: 0 == 0 ------------------------------------------------------------------------------- -A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that succeeds - 1 +A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that succeeds - Template_Foo + ------------------------------------------------------------------------------- Class.tests.cpp: ............................................................................... @@ -1111,7 +1117,8 @@ with expansion: 0 == 0 ------------------------------------------------------------------------------- -A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that succeeds - 2 +A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that succeeds - std::vector + ------------------------------------------------------------------------------- Class.tests.cpp: ............................................................................... @@ -1122,7 +1129,8 @@ with expansion: 0 == 0 ------------------------------------------------------------------------------- -A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that succeeds - 3 +A TEMPLATE_PRODUCT_TEST_CASE_METHOD based test run that succeeds - std::vector + ------------------------------------------------------------------------------- Class.tests.cpp: ............................................................................... @@ -1221,7 +1229,7 @@ with expansion: 1 == 1 ------------------------------------------------------------------------------- -A Template product test case - 0 +A Template product test case - Foo ------------------------------------------------------------------------------- Misc.tests.cpp: ............................................................................... @@ -1232,7 +1240,7 @@ with expansion: 0 == 0 ------------------------------------------------------------------------------- -A Template product test case - 1 +A Template product test case - Foo ------------------------------------------------------------------------------- Misc.tests.cpp: ............................................................................... @@ -1243,7 +1251,7 @@ with expansion: 0 == 0 ------------------------------------------------------------------------------- -A Template product test case - 2 +A Template product test case - std::vector ------------------------------------------------------------------------------- Misc.tests.cpp: ............................................................................... @@ -1254,7 +1262,7 @@ with expansion: 0 == 0 ------------------------------------------------------------------------------- -A Template product test case - 3 +A Template product test case - std::vector ------------------------------------------------------------------------------- Misc.tests.cpp: ............................................................................... @@ -5779,7 +5787,7 @@ with expansion: contains: "colour mode must be one of" ------------------------------------------------------------------------------- -Product with differing arities - 0 +Product with differing arities - std::tuple ------------------------------------------------------------------------------- Misc.tests.cpp: ............................................................................... @@ -5787,10 +5795,10 @@ Misc.tests.cpp: Misc.tests.cpp:: PASSED: REQUIRE( std::tuple_size::value >= 1 ) with expansion: - 1 >= 1 + 3 >= 1 ------------------------------------------------------------------------------- -Product with differing arities - 1 +Product with differing arities - std::tuple ------------------------------------------------------------------------------- Misc.tests.cpp: ............................................................................... @@ -5801,7 +5809,7 @@ with expansion: 2 >= 1 ------------------------------------------------------------------------------- -Product with differing arities - 2 +Product with differing arities - std::tuple ------------------------------------------------------------------------------- Misc.tests.cpp: ............................................................................... @@ -5809,7 +5817,7 @@ Misc.tests.cpp: Misc.tests.cpp:: PASSED: REQUIRE( std::tuple_size::value >= 1 ) with expansion: - 3 >= 1 + 1 >= 1 ------------------------------------------------------------------------------- Reconstruction should be based on stringification: #914 diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt index 77ea5697..6f315396 100644 --- a/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -80,30 +80,30 @@ Class.tests.cpp: - + Class.tests.cpp: - + Class.tests.cpp: - + Class.tests.cpp: - + Class.tests.cpp: - - - - + + + + Class.tests.cpp: @@ -128,10 +128,10 @@ Class.tests.cpp: - - - - + + + + @@ -566,9 +566,9 @@ Message.tests.cpp: - - - + + + Decomposition.tests.cpp: diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index 6558d6f2..e54f8426 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -1195,7 +1195,7 @@ - + Template_Fixture_2<TestType>::m_a.size() == 1 @@ -1206,7 +1206,7 @@ - + Template_Fixture_2<TestType>::m_a.size() == 1 @@ -1217,7 +1217,7 @@ - + Template_Fixture_2<TestType>::m_a.size() == 1 @@ -1228,7 +1228,7 @@ - + Template_Fixture_2<TestType>::m_a.size() == 1 @@ -1239,7 +1239,7 @@ - + Template_Fixture_2<TestType>::m_a.size() == 0 @@ -1250,7 +1250,7 @@ - + Template_Fixture_2<TestType>::m_a.size() == 0 @@ -1261,7 +1261,7 @@ - + Template_Fixture_2<TestType>::m_a.size() == 0 @@ -1272,7 +1272,7 @@ - + Template_Fixture_2<TestType>::m_a.size() == 0 @@ -1371,7 +1371,7 @@ - + x.size() == 0 @@ -1382,7 +1382,7 @@ - + x.size() == 0 @@ -1393,7 +1393,7 @@ - + x.size() == 0 @@ -1404,7 +1404,7 @@ - + x.size() == 0 @@ -7247,18 +7247,18 @@ - + std::tuple_size<TestType>::value >= 1 - 1 >= 1 + 3 >= 1 - + std::tuple_size<TestType>::value >= 1 @@ -7269,13 +7269,13 @@ - + std::tuple_size<TestType>::value >= 1 - 3 >= 1 + 1 >= 1