File indexing completed on 2025-01-18 09:54:08
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/internal/catch_source_line_info.hpp>
0012 #include <catch2/internal/catch_noncopyable.hpp>
0013 #include <catch2/internal/catch_stringref.hpp>
0014 #include <catch2/internal/catch_test_registry.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
0049 enum class TestCaseProperties : uint8_t {
0050 None = 0,
0051 IsHidden = 1 << 1,
0052 ShouldFail = 1 << 2,
0053 MayFail = 1 << 3,
0054 Throws = 1 << 4,
0055 NonPortable = 1 << 5,
0056 Benchmark = 1 << 6
0057 };
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068 struct TestCaseInfo : Detail::NonCopyable {
0069
0070 TestCaseInfo(StringRef _className,
0071 NameAndTags const& _tags,
0072 SourceLineInfo const& _lineInfo);
0073
0074 bool isHidden() const;
0075 bool throws() const;
0076 bool okToFail() const;
0077 bool expectedToFail() const;
0078
0079
0080 void addFilenameTag();
0081
0082
0083 friend bool operator<( TestCaseInfo const& lhs,
0084 TestCaseInfo const& rhs );
0085
0086
0087 std::string tagsAsString() const;
0088
0089 std::string name;
0090 StringRef className;
0091 private:
0092 std::string backingTags;
0093
0094
0095 void internalAppendTag(StringRef tagString);
0096 public:
0097 std::vector<Tag> tags;
0098 SourceLineInfo lineInfo;
0099 TestCaseProperties properties = TestCaseProperties::None;
0100 };
0101
0102
0103
0104
0105
0106
0107
0108 class TestCaseHandle {
0109 TestCaseInfo* m_info;
0110 ITestInvoker* m_invoker;
0111 public:
0112 TestCaseHandle(TestCaseInfo* info, ITestInvoker* invoker) :
0113 m_info(info), m_invoker(invoker) {}
0114
0115 void invoke() const {
0116 m_invoker->invoke();
0117 }
0118
0119 TestCaseInfo const& getTestCaseInfo() const;
0120 };
0121
0122 Detail::unique_ptr<TestCaseInfo>
0123 makeTestCaseInfo( StringRef className,
0124 NameAndTags const& nameAndTags,
0125 SourceLineInfo const& lineInfo );
0126 }
0127
0128 #ifdef __clang__
0129 #pragma clang diagnostic pop
0130 #endif
0131
0132 #endif