2020-08-30 15:43:45 +02:00
|
|
|
|
|
|
|
|
// 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
|
2020-08-29 20:48:32 +02:00
|
|
|
#ifndef CATCH_TEST_CASE_INFO_HPP_INCLUDED
|
|
|
|
|
#define CATCH_TEST_CASE_INFO_HPP_INCLUDED
|
2012-08-14 19:30:30 +01:00
|
|
|
|
2020-03-30 10:34:21 +02:00
|
|
|
#include <catch2/internal/catch_common.hpp>
|
2020-08-18 11:35:58 +02:00
|
|
|
#include <catch2/internal/catch_noncopyable.hpp>
|
2020-05-10 10:09:01 +02:00
|
|
|
#include <catch2/internal/catch_stringref.hpp>
|
2020-03-30 10:34:21 +02:00
|
|
|
#include <catch2/internal/catch_test_registry.hpp>
|
2020-05-25 09:45:24 +02:00
|
|
|
#include <catch2/internal/catch_unique_ptr.hpp>
|
|
|
|
|
|
2017-08-01 18:46:33 +02:00
|
|
|
|
2012-08-14 19:30:30 +01:00
|
|
|
#include <string>
|
2017-07-27 22:31:27 +02:00
|
|
|
#include <vector>
|
2012-08-14 19:30:30 +01:00
|
|
|
|
2013-03-13 08:04:50 +00:00
|
|
|
#ifdef __clang__
|
|
|
|
|
#pragma clang diagnostic push
|
|
|
|
|
#pragma clang diagnostic ignored "-Wpadded"
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-08-14 19:30:30 +01:00
|
|
|
namespace Catch {
|
|
|
|
|
|
2019-11-07 12:39:07 +01:00
|
|
|
struct Tag {
|
|
|
|
|
Tag(StringRef original_, StringRef lowerCased_):
|
|
|
|
|
original(original_), lowerCased(lowerCased_)
|
|
|
|
|
{}
|
|
|
|
|
StringRef original, lowerCased;
|
|
|
|
|
};
|
|
|
|
|
|
2017-07-12 18:01:54 +01:00
|
|
|
struct ITestInvoker;
|
2012-08-14 19:30:30 +01:00
|
|
|
|
2019-11-07 12:39:07 +01:00
|
|
|
enum class TestCaseProperties : uint8_t {
|
|
|
|
|
None = 0,
|
|
|
|
|
IsHidden = 1 << 1,
|
|
|
|
|
ShouldFail = 1 << 2,
|
|
|
|
|
MayFail = 1 << 3,
|
|
|
|
|
Throws = 1 << 4,
|
|
|
|
|
NonPortable = 1 << 5,
|
|
|
|
|
Benchmark = 1 << 6
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2020-08-18 11:35:58 +02:00
|
|
|
struct TestCaseInfo : Detail::NonCopyable {
|
2019-11-07 12:39:07 +01:00
|
|
|
|
|
|
|
|
TestCaseInfo(std::string const& _className,
|
|
|
|
|
NameAndTags const& _tags,
|
|
|
|
|
SourceLineInfo const& _lineInfo);
|
2015-11-04 18:01:28 +00:00
|
|
|
|
2014-07-03 08:09:57 +01:00
|
|
|
bool isHidden() const;
|
|
|
|
|
bool throws() const;
|
|
|
|
|
bool okToFail() const;
|
|
|
|
|
bool expectedToFail() const;
|
|
|
|
|
|
2019-11-07 12:39:07 +01:00
|
|
|
// Adds the tag(s) with test's filename (for the -# flag)
|
|
|
|
|
void addFilenameTag();
|
|
|
|
|
|
|
|
|
|
|
2017-07-27 22:31:27 +02:00
|
|
|
std::string tagsAsString() const;
|
|
|
|
|
|
2012-11-25 11:19:55 +00:00
|
|
|
std::string name;
|
|
|
|
|
std::string className;
|
2019-11-07 12:39:07 +01:00
|
|
|
private:
|
|
|
|
|
std::string backingTags, backingLCaseTags;
|
|
|
|
|
// Internally we copy tags to the backing storage and then add
|
|
|
|
|
// refs to this storage to the tags vector.
|
|
|
|
|
void internalAppendTag(StringRef tagString);
|
|
|
|
|
public:
|
|
|
|
|
std::vector<Tag> tags;
|
2012-11-25 11:19:55 +00:00
|
|
|
SourceLineInfo lineInfo;
|
2019-11-07 12:39:07 +01:00
|
|
|
TestCaseProperties properties = TestCaseProperties::None;
|
2012-11-25 11:19:55 +00:00
|
|
|
};
|
2013-07-03 19:14:59 +01:00
|
|
|
|
2019-11-04 21:35:57 +01:00
|
|
|
class TestCaseHandle {
|
|
|
|
|
TestCaseInfo* m_info;
|
|
|
|
|
ITestInvoker* m_invoker;
|
2012-11-25 11:19:55 +00:00
|
|
|
public:
|
2019-11-04 21:35:57 +01:00
|
|
|
TestCaseHandle(TestCaseInfo* info, ITestInvoker* invoker) :
|
|
|
|
|
m_info(info), m_invoker(invoker) {}
|
2012-11-25 11:19:55 +00:00
|
|
|
|
2019-11-04 21:35:57 +01:00
|
|
|
void invoke() const {
|
|
|
|
|
m_invoker->invoke();
|
|
|
|
|
}
|
2012-11-04 21:11:59 +00:00
|
|
|
|
2013-04-23 18:58:56 +01:00
|
|
|
TestCaseInfo const& getTestCaseInfo() const;
|
2012-11-25 11:19:55 +00:00
|
|
|
|
2019-11-04 21:35:57 +01:00
|
|
|
bool operator== ( TestCaseHandle const& rhs ) const;
|
|
|
|
|
bool operator < ( TestCaseHandle const& rhs ) const;
|
2012-08-14 19:30:30 +01:00
|
|
|
};
|
2012-11-25 11:19:55 +00:00
|
|
|
|
2020-05-25 09:45:24 +02:00
|
|
|
Detail::unique_ptr<TestCaseInfo> makeTestCaseInfo( std::string const& className,
|
2018-03-02 16:22:18 +01:00
|
|
|
NameAndTags const& nameAndTags,
|
2013-04-23 18:58:56 +01:00
|
|
|
SourceLineInfo const& lineInfo );
|
2012-08-14 19:30:30 +01:00
|
|
|
}
|
|
|
|
|
|
2013-03-13 08:04:50 +00:00
|
|
|
#ifdef __clang__
|
|
|
|
|
#pragma clang diagnostic pop
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-08-29 20:48:32 +02:00
|
|
|
#endif // CATCH_TEST_CASE_INFO_HPP_INCLUDED
|