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

Display type name in TEMPLATE_LIST_TEST_CASE output #2537

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions src/catch2/catch_all.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
#include <catch2/internal/catch_test_spec_parser.hpp>
#include <catch2/internal/catch_textflow.hpp>
#include <catch2/internal/catch_to_string.hpp>
#include <catch2/internal/catch_type_to_string.hpp>
#include <catch2/internal/catch_uncaught_exceptions.hpp>
#include <catch2/internal/catch_unique_name.hpp>
#include <catch2/internal/catch_unique_ptr.hpp>
Expand Down
2 changes: 2 additions & 0 deletions src/catch2/internal/catch_compiler_capabilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@

# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__)

# define CATCH_INTERNAL_TYPEID_DEMANGLE
#endif

#if defined(__CUDACC__) && !defined(__clang__)
Expand All @@ -73,6 +74,7 @@
# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic push" )
# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic pop" )

# define CATCH_INTERNAL_TYPEID_DEMANGLE
#endif // __clang__ && !_MSC_VER

#if defined(__clang__)
Expand Down
3 changes: 2 additions & 1 deletion src/catch2/internal/catch_template_test_registry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <catch2/internal/catch_preprocessor.hpp>
#include <catch2/internal/catch_meta.hpp>
#include <catch2/internal/catch_unique_name.hpp>
#include <catch2/internal/catch_type_to_string.hpp>


// GCC 5 and older do not properly handle disabling unused-variable warning
Expand Down Expand Up @@ -178,7 +179,7 @@
void reg_tests() { \
size_t index = 0; \
using expander = size_t[]; \
(void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestFunc<Types> ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ Name " - " + std::string(INTERNAL_CATCH_STRINGIZE(TmplList)) + " - " + std::to_string(index), Tags } ), index++)... };/* NOLINT */\
(void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestFunc<Types> ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ Name " - " + std::string(INTERNAL_CATCH_STRINGIZE(TmplList)) + " - " + std::to_string(index) + " - " + Catch::type_to_string<Types>(), Tags } ), index++)... };/* NOLINT */\
} \
};\
static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){ \
Expand Down
33 changes: 33 additions & 0 deletions src/catch2/internal/catch_type_to_string.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

// Copyright Catch2 Authors
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)

// SPDX-License-Identifier: BSL-1.0
#ifndef CATCH_TYPE_TO_STRING_HPP_INCLUDED
#define CATCH_TYPE_TO_STRING_HPP_INCLUDED

#include <typeinfo>

#if defined( CATCH_INTERNAL_TYPEID_DEMANGLE )
# include <memory>
# include <cxxabi.h>
#endif

namespace Catch {
template <typename T> std::string type_to_string() {
#if defined( CATCH_INTERNAL_TYPEID_DEMANGLE )
const char* name = typeid( T ).name();
int status = 0;
std::unique_ptr<char, void ( * )( void* )> res{
abi::__cxa_demangle( name, NULL, NULL, &status ), std::free };

return status == 0 ? res.get() : name;
#else
return typeid( T ).name();
#endif
}
} // end namespace Catch

#endif // CATCH_TYPE_TO_STRING_HPP_INCLUDED
14 changes: 7 additions & 7 deletions tests/SelfTest/Baselines/automake.sw.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,13 @@ Message from section two
:test-result: PASS Template test case method with test types specified inside std::tuple - MyTypes - 0
:test-result: PASS Template test case method with test types specified inside std::tuple - MyTypes - 1
:test-result: PASS Template test case method with test types specified inside std::tuple - MyTypes - 2
:test-result: PASS Template test case with test types specified inside non-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 0
:test-result: PASS Template test case with test types specified inside non-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 1
:test-result: PASS Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 0
:test-result: PASS Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 1
:test-result: PASS Template test case with test types specified inside std::tuple - MyTypes - 0
:test-result: PASS Template test case with test types specified inside std::tuple - MyTypes - 1
:test-result: PASS Template test case with test types specified inside std::tuple - MyTypes - 2
:test-result: PASS Template test case with test types specified inside non-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 0 - NonCopyableAndNonMovableType
:test-result: PASS Template test case with test types specified inside non-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 1 - float
:test-result: PASS Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 0 - NonDefaultConstructibleType
:test-result: PASS Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 1 - float
:test-result: PASS Template test case with test types specified inside std::tuple - MyTypes - 0 - int
:test-result: PASS Template test case with test types specified inside std::tuple - MyTypes - 1 - char
:test-result: PASS Template test case with test types specified inside std::tuple - MyTypes - 2 - float
:test-result: PASS TemplateTest: vectors can be sized and resized - float
:test-result: PASS TemplateTest: vectors can be sized and resized - int
:test-result: PASS TemplateTest: vectors can be sized and resized - std::string
Expand Down
14 changes: 7 additions & 7 deletions tests/SelfTest/Baselines/automake.sw.multi.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,13 @@
:test-result: PASS Template test case method with test types specified inside std::tuple - MyTypes - 0
:test-result: PASS Template test case method with test types specified inside std::tuple - MyTypes - 1
:test-result: PASS Template test case method with test types specified inside std::tuple - MyTypes - 2
:test-result: PASS Template test case with test types specified inside non-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 0
:test-result: PASS Template test case with test types specified inside non-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 1
:test-result: PASS Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 0
:test-result: PASS Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 1
:test-result: PASS Template test case with test types specified inside std::tuple - MyTypes - 0
:test-result: PASS Template test case with test types specified inside std::tuple - MyTypes - 1
:test-result: PASS Template test case with test types specified inside std::tuple - MyTypes - 2
:test-result: PASS Template test case with test types specified inside non-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 0 - NonCopyableAndNonMovableType
:test-result: PASS Template test case with test types specified inside non-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 1 - float
:test-result: PASS Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 0 - NonDefaultConstructibleType
:test-result: PASS Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 1 - float
:test-result: PASS Template test case with test types specified inside std::tuple - MyTypes - 0 - int
:test-result: PASS Template test case with test types specified inside std::tuple - MyTypes - 1 - char
:test-result: PASS Template test case with test types specified inside std::tuple - MyTypes - 2 - float
:test-result: PASS TemplateTest: vectors can be sized and resized - float
:test-result: PASS TemplateTest: vectors can be sized and resized - int
:test-result: PASS TemplateTest: vectors can be sized and resized - std::string
Expand Down
18 changes: 11 additions & 7 deletions tests/SelfTest/Baselines/console.sw.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12056,7 +12056,8 @@ with expansion:

-------------------------------------------------------------------------------
Template test case with test types specified inside non-copyable and non-
movable std::tuple - NonCopyableAndNonMovableTypes - 0
movable std::tuple - NonCopyableAndNonMovableTypes - 0 -
NonCopyableAndNonMovableType
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
Expand All @@ -12068,7 +12069,7 @@ with expansion:

-------------------------------------------------------------------------------
Template test case with test types specified inside non-copyable and non-
movable std::tuple - NonCopyableAndNonMovableTypes - 1
movable std::tuple - NonCopyableAndNonMovableTypes - 1 - float
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
Expand All @@ -12080,7 +12081,7 @@ with expansion:

-------------------------------------------------------------------------------
Template test case with test types specified inside non-default-constructible
std::tuple - MyNonDefaultConstructibleTypes - 0
std::tuple - MyNonDefaultConstructibleTypes - 0 - NonDefaultConstructibleType
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
Expand All @@ -12092,7 +12093,7 @@ with expansion:

-------------------------------------------------------------------------------
Template test case with test types specified inside non-default-constructible
std::tuple - MyNonDefaultConstructibleTypes - 1
std::tuple - MyNonDefaultConstructibleTypes - 1 - float
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
Expand All @@ -12103,7 +12104,8 @@ with expansion:
4 > 0

-------------------------------------------------------------------------------
Template test case with test types specified inside std::tuple - MyTypes - 0
Template test case with test types specified inside std::tuple - MyTypes - 0 -
int
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
Expand All @@ -12114,7 +12116,8 @@ with expansion:
4 > 0

-------------------------------------------------------------------------------
Template test case with test types specified inside std::tuple - MyTypes - 1
Template test case with test types specified inside std::tuple - MyTypes - 1 -
char
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
Expand All @@ -12125,7 +12128,8 @@ with expansion:
1 > 0

-------------------------------------------------------------------------------
Template test case with test types specified inside std::tuple - MyTypes - 2
Template test case with test types specified inside std::tuple - MyTypes - 2 -
float
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
Expand Down
18 changes: 11 additions & 7 deletions tests/SelfTest/Baselines/console.sw.multi.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12049,7 +12049,8 @@ with expansion:

-------------------------------------------------------------------------------
Template test case with test types specified inside non-copyable and non-
movable std::tuple - NonCopyableAndNonMovableTypes - 0
movable std::tuple - NonCopyableAndNonMovableTypes - 0 -
NonCopyableAndNonMovableType
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
Expand All @@ -12061,7 +12062,7 @@ with expansion:

-------------------------------------------------------------------------------
Template test case with test types specified inside non-copyable and non-
movable std::tuple - NonCopyableAndNonMovableTypes - 1
movable std::tuple - NonCopyableAndNonMovableTypes - 1 - float
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
Expand All @@ -12073,7 +12074,7 @@ with expansion:

-------------------------------------------------------------------------------
Template test case with test types specified inside non-default-constructible
std::tuple - MyNonDefaultConstructibleTypes - 0
std::tuple - MyNonDefaultConstructibleTypes - 0 - NonDefaultConstructibleType
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
Expand All @@ -12085,7 +12086,7 @@ with expansion:

-------------------------------------------------------------------------------
Template test case with test types specified inside non-default-constructible
std::tuple - MyNonDefaultConstructibleTypes - 1
std::tuple - MyNonDefaultConstructibleTypes - 1 - float
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
Expand All @@ -12096,7 +12097,8 @@ with expansion:
4 > 0

-------------------------------------------------------------------------------
Template test case with test types specified inside std::tuple - MyTypes - 0
Template test case with test types specified inside std::tuple - MyTypes - 0 -
int
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
Expand All @@ -12107,7 +12109,8 @@ with expansion:
4 > 0

-------------------------------------------------------------------------------
Template test case with test types specified inside std::tuple - MyTypes - 1
Template test case with test types specified inside std::tuple - MyTypes - 1 -
char
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
Expand All @@ -12118,7 +12121,8 @@ with expansion:
1 > 0

-------------------------------------------------------------------------------
Template test case with test types specified inside std::tuple - MyTypes - 2
Template test case with test types specified inside std::tuple - MyTypes - 2 -
float
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
Expand Down
14 changes: 7 additions & 7 deletions tests/SelfTest/Baselines/junit.sw.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1301,13 +1301,13 @@ 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}" status="run"/>
<testcase classname="<exe-name>.Template_Fixture" name="Template test case method with test types specified inside std::tuple - MyTypes - 1" time="{duration}" status="run"/>
<testcase classname="<exe-name>.Template_Fixture" name="Template test case method with test types specified inside std::tuple - MyTypes - 2" time="{duration}" status="run"/>
<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}" status="run"/>
<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}" status="run"/>
<testcase classname="<exe-name>.global" name="Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 0" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 1" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Template test case with test types specified inside std::tuple - MyTypes - 0" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Template test case with test types specified inside std::tuple - MyTypes - 1" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Template test case with test types specified inside std::tuple - MyTypes - 2" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Template test case with test types specified inside non-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 0 - NonCopyableAndNonMovableType" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Template test case with test types specified inside non-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 1 - float" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 0 - NonDefaultConstructibleType" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 1 - float" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Template test case with test types specified inside std::tuple - MyTypes - 0 - int" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Template test case with test types specified inside std::tuple - MyTypes - 1 - char" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Template test case with test types specified inside std::tuple - MyTypes - 2 - float" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="TemplateTest: vectors can be sized and resized - float" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="TemplateTest: vectors can be sized and resized - float/resizing bigger changes size and capacity" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="TemplateTest: vectors can be sized and resized - float/resizing smaller changes size but not capacity" time="{duration}" status="run"/>
Expand Down
Loading