File indexing completed on 2025-09-16 08:52:14
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef CATCH_TEST_CASE_INFO_HPP_INCLUDED
0009 #define CATCH_TEST_CASE_INFO_HPP_INCLUDED
0010
0011 #include <catch2/interfaces/catch_interfaces_test_invoker.hpp>
0012 #include <catch2/internal/catch_source_line_info.hpp>
0013 #include <catch2/internal/catch_noncopyable.hpp>
0014 #include <catch2/internal/catch_stringref.hpp>
0015 #include <catch2/internal/catch_unique_ptr.hpp>
0016
0017
0018 #include <cstdint>
0019 #include <string>
0020 #include <cstdint>
0021 #include <vector>
0022
0023 #ifdef __clang__
0024 #pragma clang diagnostic push
0025 #pragma clang diagnostic ignored "-Wpadded"
0026 #endif
0027
0028 namespace Catch {
0029
0030
0031
0032
0033
0034
0035
0036
0037 struct Tag {
0038 constexpr Tag(StringRef original_):
0039 original(original_)
0040 {}
0041 StringRef original;
0042
0043 friend bool operator< ( Tag const& lhs, Tag const& rhs );
0044 friend bool operator==( Tag const& lhs, Tag const& rhs );
0045 };
0046
0047 class ITestInvoker;
0048 struct NameAndTags;
0049
0050 enum class TestCaseProperties : uint8_t {
0051 None = 0,
0052 IsHidden = 1 << 1,
0053 ShouldFail = 1 << 2,
0054 MayFail = 1 << 3,
0055 Throws = 1 << 4,
0056 NonPortable = 1 << 5,
0057 Benchmark = 1 << 6
0058 };
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069 struct TestCaseInfo : Detail::NonCopyable {
0070
0071 TestCaseInfo(StringRef _className,
0072 NameAndTags const& _nameAndTags,
0073 SourceLineInfo const& _lineInfo);
0074
0075 bool isHidden() const;
0076 bool throws() const;
0077 bool okToFail() const;
0078 bool expectedToFail() const;
0079
0080
0081 void addFilenameTag();
0082
0083
0084 friend bool operator<( TestCaseInfo const& lhs,
0085 TestCaseInfo const& rhs );
0086
0087
0088 std::string tagsAsString() const;
0089
0090 std::string name;
0091 StringRef className;
0092 private:
0093 std::string backingTags;
0094
0095
0096 void internalAppendTag(StringRef tagString);
0097 public:
0098 std::vector<Tag> tags;
0099 SourceLineInfo lineInfo;
0100 TestCaseProperties properties = TestCaseProperties::None;
0101 };
0102
0103
0104
0105
0106
0107
0108
0109 class TestCaseHandle {
0110 TestCaseInfo* m_info;
0111 ITestInvoker* m_invoker;
0112 public:
0113 constexpr TestCaseHandle(TestCaseInfo* info, ITestInvoker* invoker) :
0114 m_info(info), m_invoker(invoker) {}
0115
0116 void prepareTestCase() const {
0117 m_invoker->prepareTestCase();
0118 }
0119
0120 void tearDownTestCase() const {
0121 m_invoker->tearDownTestCase();
0122 }
0123
0124 void invoke() const {
0125 m_invoker->invoke();
0126 }
0127
0128 constexpr TestCaseInfo const& getTestCaseInfo() const {
0129 return *m_info;
0130 }
0131 };
0132
0133 Detail::unique_ptr<TestCaseInfo>
0134 makeTestCaseInfo( StringRef className,
0135 NameAndTags const& nameAndTags,
0136 SourceLineInfo const& lineInfo );
0137 }
0138
0139 #ifdef __clang__
0140 #pragma clang diagnostic pop
0141 #endif
0142
0143 #endif