line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
// Copyright Catch2 Authors |
3
|
|
|
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. |
4
|
|
|
|
|
|
|
// (See accompanying file LICENSE_1_0.txt or copy at |
5
|
|
|
|
|
|
|
// https://www.boost.org/LICENSE_1_0.txt) |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
// SPDX-License-Identifier: BSL-1.0 |
8
|
|
|
|
|
|
|
#ifndef CATCH_TEST_REGISTRY_HPP_INCLUDED |
9
|
|
|
|
|
|
|
#define CATCH_TEST_REGISTRY_HPP_INCLUDED |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
#include |
12
|
|
|
|
|
|
|
#include |
13
|
|
|
|
|
|
|
#include |
14
|
|
|
|
|
|
|
#include |
15
|
|
|
|
|
|
|
#include |
16
|
|
|
|
|
|
|
#include |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
// GCC 5 and older do not properly handle disabling unused-variable warning |
19
|
|
|
|
|
|
|
// with a _Pragma. This means that we have to leak the suppression to the |
20
|
|
|
|
|
|
|
// user code as well :-( |
21
|
|
|
|
|
|
|
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ <= 5 |
22
|
|
|
|
|
|
|
#pragma GCC diagnostic ignored "-Wunused-variable" |
23
|
|
|
|
|
|
|
#endif |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
namespace Catch { |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
template |
30
|
|
|
|
|
|
|
class TestInvokerAsMethod : public ITestInvoker { |
31
|
|
|
|
|
|
|
void (C::*m_testAsMethod)(); |
32
|
|
|
|
|
|
|
public: |
33
|
|
|
|
|
|
|
TestInvokerAsMethod( void (C::*testAsMethod)() ) noexcept : m_testAsMethod( testAsMethod ) {} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
void invoke() const override { |
36
|
|
|
|
|
|
|
C obj; |
37
|
|
|
|
|
|
|
(obj.*m_testAsMethod)(); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Detail::unique_ptr makeTestInvoker( void(*testAsFunction)() ); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
template |
44
|
|
|
|
|
|
|
Detail::unique_ptr makeTestInvoker( void (C::*testAsMethod)() ) { |
45
|
|
|
|
|
|
|
return Detail::make_unique>( testAsMethod ); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
struct NameAndTags { |
49
|
0
|
|
|
|
|
|
constexpr NameAndTags( StringRef name_ = StringRef(), |
50
|
|
|
|
|
|
|
StringRef tags_ = StringRef() ) noexcept: |
51
|
0
|
|
|
|
|
|
name( name_ ), tags( tags_ ) {} |
52
|
|
|
|
|
|
|
StringRef name; |
53
|
|
|
|
|
|
|
StringRef tags; |
54
|
|
|
|
|
|
|
}; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
struct AutoReg : Detail::NonCopyable { |
57
|
|
|
|
|
|
|
AutoReg( Detail::unique_ptr invoker, SourceLineInfo const& lineInfo, StringRef classOrMethod, NameAndTags const& nameAndTags ) noexcept; |
58
|
|
|
|
|
|
|
}; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
} // end namespace Catch |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
#if defined(CATCH_CONFIG_DISABLE) |
63
|
|
|
|
|
|
|
#define INTERNAL_CATCH_TESTCASE_NO_REGISTRATION( TestName, ... ) \ |
64
|
|
|
|
|
|
|
static inline void TestName() |
65
|
|
|
|
|
|
|
#define INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION( TestName, ClassName, ... ) \ |
66
|
|
|
|
|
|
|
namespace{ \ |
67
|
|
|
|
|
|
|
struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName) { \ |
68
|
|
|
|
|
|
|
void test(); \ |
69
|
|
|
|
|
|
|
}; \ |
70
|
|
|
|
|
|
|
} \ |
71
|
|
|
|
|
|
|
void TestName::test() |
72
|
|
|
|
|
|
|
#endif |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////// |
75
|
|
|
|
|
|
|
#define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \ |
76
|
|
|
|
|
|
|
static void TestName(); \ |
77
|
|
|
|
|
|
|
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
78
|
|
|
|
|
|
|
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
79
|
|
|
|
|
|
|
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &TestName ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ __VA_ARGS__ } ); } /* NOLINT */ \ |
80
|
|
|
|
|
|
|
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ |
81
|
|
|
|
|
|
|
static void TestName() |
82
|
|
|
|
|
|
|
#define INTERNAL_CATCH_TESTCASE( ... ) \ |
83
|
|
|
|
|
|
|
INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ ), __VA_ARGS__ ) |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////// |
86
|
|
|
|
|
|
|
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \ |
87
|
|
|
|
|
|
|
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
88
|
|
|
|
|
|
|
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
89
|
|
|
|
|
|
|
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &QualifiedMethod ), CATCH_INTERNAL_LINEINFO, "&" #QualifiedMethod, Catch::NameAndTags{ __VA_ARGS__ } ); } /* NOLINT */ \ |
90
|
|
|
|
|
|
|
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////// |
93
|
|
|
|
|
|
|
#define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\ |
94
|
|
|
|
|
|
|
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
95
|
|
|
|
|
|
|
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
96
|
|
|
|
|
|
|
namespace{ \ |
97
|
|
|
|
|
|
|
struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName) { \ |
98
|
|
|
|
|
|
|
void test(); \ |
99
|
|
|
|
|
|
|
}; \ |
100
|
|
|
|
|
|
|
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( Catch::makeTestInvoker( &TestName::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \ |
101
|
|
|
|
|
|
|
} \ |
102
|
|
|
|
|
|
|
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ |
103
|
|
|
|
|
|
|
void TestName::test() |
104
|
|
|
|
|
|
|
#define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \ |
105
|
|
|
|
|
|
|
INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ ), ClassName, __VA_ARGS__ ) |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////// |
108
|
|
|
|
|
|
|
#define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \ |
109
|
|
|
|
|
|
|
do { \ |
110
|
|
|
|
|
|
|
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
111
|
|
|
|
|
|
|
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
112
|
|
|
|
|
|
|
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( Function ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \ |
113
|
|
|
|
|
|
|
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ |
114
|
|
|
|
|
|
|
} while(false) |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
#endif // CATCH_TEST_REGISTRY_HPP_INCLUDED |