struct -> class normalization for various interface types

This commit is contained in:
Martin Hořeňovský 2022-04-11 00:00:19 +02:00
parent 1a56ba851b
commit 8cdaebe964
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
23 changed files with 66 additions and 53 deletions

View File

@ -42,7 +42,7 @@ namespace Catch {
friend bool operator==( Tag const& lhs, Tag const& rhs ); friend bool operator==( Tag const& lhs, Tag const& rhs );
}; };
struct ITestInvoker; class ITestInvoker;
enum class TestCaseProperties : uint8_t { enum class TestCaseProperties : uint8_t {
None = 0, None = 0,

View File

@ -21,7 +21,7 @@
namespace Catch { namespace Catch {
struct IConfig; class IConfig;
struct TestCaseInfo; struct TestCaseInfo;
class TestCaseHandle; class TestCaseHandle;

View File

@ -29,7 +29,8 @@ namespace Detail {
} // end namespace detail } // end namespace detail
template<typename T> template<typename T>
struct IGenerator : GeneratorUntypedBase { class IGenerator : public GeneratorUntypedBase {
public:
~IGenerator() override = default; ~IGenerator() override = default;
IGenerator() = default; IGenerator() = default;
IGenerator(IGenerator const&) = default; IGenerator(IGenerator const&) = default;

View File

@ -26,15 +26,15 @@ namespace Catch {
struct AssertionReaction; struct AssertionReaction;
struct SourceLineInfo; struct SourceLineInfo;
struct ITransientExpression; class ITransientExpression;
struct IGeneratorTracker; class IGeneratorTracker;
struct BenchmarkInfo; struct BenchmarkInfo;
template <typename Duration = std::chrono::duration<double, std::nano>> template <typename Duration = std::chrono::duration<double, std::nano>>
struct BenchmarkStats; struct BenchmarkStats;
struct IResultCapture { class IResultCapture {
public:
virtual ~IResultCapture(); virtual ~IResultCapture();
virtual bool sectionStarted( SectionInfo const& sectionInfo, virtual bool sectionStarted( SectionInfo const& sectionInfo,

View File

@ -62,8 +62,8 @@ namespace Catch {
class TestSpec; class TestSpec;
class IStream; class IStream;
struct IConfig : Detail::NonCopyable { class IConfig : public Detail::NonCopyable {
public:
virtual ~IConfig(); virtual ~IConfig();
virtual bool allowThrows() const = 0; virtual bool allowThrows() const = 0;

View File

@ -25,7 +25,8 @@ namespace Catch {
}; };
} // namespace Detail } // namespace Detail
struct IMutableEnumValuesRegistry { class IMutableEnumValuesRegistry {
public:
virtual ~IMutableEnumValuesRegistry(); // = default; virtual ~IMutableEnumValuesRegistry(); // = default;
virtual Detail::EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::vector<int> const& values ) = 0; virtual Detail::EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::vector<int> const& values ) = 0;

View File

@ -17,17 +17,18 @@
namespace Catch { namespace Catch {
using exceptionTranslateFunction = std::string(*)(); using exceptionTranslateFunction = std::string(*)();
struct IExceptionTranslator; class IExceptionTranslator;
using ExceptionTranslators = std::vector<Detail::unique_ptr<IExceptionTranslator const>>; using ExceptionTranslators = std::vector<Detail::unique_ptr<IExceptionTranslator const>>;
struct IExceptionTranslator { class IExceptionTranslator {
public:
virtual ~IExceptionTranslator(); // = default virtual ~IExceptionTranslator(); // = default
virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const = 0; virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const = 0;
}; };
struct IExceptionTranslatorRegistry { class IExceptionTranslatorRegistry {
public:
virtual ~IExceptionTranslatorRegistry(); // = default virtual ~IExceptionTranslatorRegistry(); // = default
virtual std::string translateActiveException() const = 0; virtual std::string translateActiveException() const = 0;
}; };

View File

@ -33,7 +33,8 @@ namespace Catch {
} // namespace Generators } // namespace Generators
struct IGeneratorTracker { class IGeneratorTracker {
public:
virtual ~IGeneratorTracker(); // = default; virtual ~IGeneratorTracker(); // = default;
virtual auto hasGenerator() const -> bool = 0; virtual auto hasGenerator() const -> bool = 0;
virtual auto getGenerator() const -> Generators::GeneratorBasePtr const& = 0; virtual auto getGenerator() const -> Generators::GeneratorBasePtr const& = 0;

View File

@ -16,14 +16,14 @@ namespace Catch {
class TestCaseHandle; class TestCaseHandle;
struct TestCaseInfo; struct TestCaseInfo;
struct ITestCaseRegistry; class ITestCaseRegistry;
struct IExceptionTranslatorRegistry; class IExceptionTranslatorRegistry;
struct IExceptionTranslator; class IExceptionTranslator;
struct IReporterRegistry; class IReporterRegistry;
struct IReporterFactory; class IReporterFactory;
struct ITagAliasRegistry; class ITagAliasRegistry;
struct ITestInvoker; class ITestInvoker;
struct IMutableEnumValuesRegistry; class IMutableEnumValuesRegistry;
struct SourceLineInfo; struct SourceLineInfo;
class StartupExceptionRegistry; class StartupExceptionRegistry;
@ -31,7 +31,8 @@ namespace Catch {
using IReporterFactoryPtr = Detail::unique_ptr<IReporterFactory>; using IReporterFactoryPtr = Detail::unique_ptr<IReporterFactory>;
struct IRegistryHub { class IRegistryHub {
public:
virtual ~IRegistryHub(); // = default virtual ~IRegistryHub(); // = default
virtual IReporterRegistry const& getReporterRegistry() const = 0; virtual IReporterRegistry const& getReporterRegistry() const = 0;
@ -43,7 +44,8 @@ namespace Catch {
virtual StartupExceptionRegistry const& getStartupExceptionRegistry() const = 0; virtual StartupExceptionRegistry const& getStartupExceptionRegistry() const = 0;
}; };
struct IMutableRegistryHub { class IMutableRegistryHub {
public:
virtual ~IMutableRegistryHub(); // = default virtual ~IMutableRegistryHub(); // = default
virtual void registerReporter( std::string const& name, IReporterFactoryPtr factory ) = 0; virtual void registerReporter( std::string const& name, IReporterFactoryPtr factory ) = 0;
virtual void registerListener( Detail::unique_ptr<EventListenerFactory> factory ) = 0; virtual void registerListener( Detail::unique_ptr<EventListenerFactory> factory ) = 0;

View File

@ -30,7 +30,7 @@ namespace Catch {
struct TagInfo; struct TagInfo;
struct TestCaseInfo; struct TestCaseInfo;
class TestCaseHandle; class TestCaseHandle;
struct IConfig; class IConfig;
class IStream; class IStream;
enum class ColourMode : std::uint8_t; enum class ColourMode : std::uint8_t;

View File

@ -15,12 +15,13 @@
namespace Catch { namespace Catch {
struct ReporterConfig; struct ReporterConfig;
struct IConfig; class IConfig;
class IEventListener; class IEventListener;
using IEventListenerPtr = Detail::unique_ptr<IEventListener>; using IEventListenerPtr = Detail::unique_ptr<IEventListener>;
struct IReporterFactory { class IReporterFactory {
public:
virtual ~IReporterFactory(); // = default virtual ~IReporterFactory(); // = default
virtual IEventListenerPtr virtual IEventListenerPtr

View File

@ -17,16 +17,17 @@
namespace Catch { namespace Catch {
struct IConfig; class IConfig;
class IEventListener; class IEventListener;
using IEventListenerPtr = Detail::unique_ptr<IEventListener>; using IEventListenerPtr = Detail::unique_ptr<IEventListener>;
struct IReporterFactory; class IReporterFactory;
using IReporterFactoryPtr = Detail::unique_ptr<IReporterFactory>; using IReporterFactoryPtr = Detail::unique_ptr<IReporterFactory>;
struct ReporterConfig; struct ReporterConfig;
class EventListenerFactory; class EventListenerFactory;
struct IReporterRegistry { class IReporterRegistry {
public:
using FactoryMap = std::map<std::string, IReporterFactoryPtr, Detail::CaseInsensitiveLess>; using FactoryMap = std::map<std::string, IReporterFactoryPtr, Detail::CaseInsensitiveLess>;
using Listeners = std::vector<Detail::unique_ptr<EventListenerFactory>>; using Listeners = std::vector<Detail::unique_ptr<EventListenerFactory>>;

View File

@ -14,7 +14,8 @@ namespace Catch {
struct TagAlias; struct TagAlias;
struct ITagAliasRegistry { class ITagAliasRegistry {
public:
virtual ~ITagAliasRegistry(); // = default virtual ~ITagAliasRegistry(); // = default
// Nullptr if not present // Nullptr if not present
virtual TagAlias const* find( std::string const& alias ) const = 0; virtual TagAlias const* find( std::string const& alias ) const = 0;

View File

@ -15,15 +15,17 @@ namespace Catch {
class TestSpec; class TestSpec;
struct TestCaseInfo; struct TestCaseInfo;
struct ITestInvoker { class ITestInvoker {
public:
virtual void invoke () const = 0; virtual void invoke () const = 0;
virtual ~ITestInvoker(); // = default virtual ~ITestInvoker(); // = default
}; };
class TestCaseHandle; class TestCaseHandle;
struct IConfig; class IConfig;
struct ITestCaseRegistry { class ITestCaseRegistry {
public:
virtual ~ITestCaseRegistry(); // = default virtual ~ITestCaseRegistry(); // = default
// TODO: this exists only for adding filenames to test cases -- let's expose this in a saner way later // TODO: this exists only for adding filenames to test cases -- let's expose this in a saner way later
virtual std::vector<TestCaseInfo* > const& getAllInfos() const = 0; virtual std::vector<TestCaseInfo* > const& getAllInfos() const = 0;

View File

@ -16,7 +16,7 @@
namespace Catch { namespace Catch {
struct AssertionResultData; struct AssertionResultData;
struct IResultCapture; class IResultCapture;
class RunContext; class RunContext;
struct AssertionReaction { struct AssertionReaction {

View File

@ -16,7 +16,7 @@
namespace Catch { namespace Catch {
enum class ColourMode : std::uint8_t; enum class ColourMode : std::uint8_t;
struct IConfig; class IConfig;
class IStream; class IStream;
struct Colour { struct Colour {

View File

@ -10,19 +10,19 @@
namespace Catch { namespace Catch {
struct IResultCapture; class IResultCapture;
struct IConfig; class IConfig;
struct IContext class IContext {
{ public:
virtual ~IContext(); // = default virtual ~IContext(); // = default
virtual IResultCapture* getResultCapture() = 0; virtual IResultCapture* getResultCapture() = 0;
virtual IConfig const* getConfig() const = 0; virtual IConfig const* getConfig() const = 0;
}; };
struct IMutableContext : IContext class IMutableContext : public IContext {
{ public:
virtual ~IMutableContext(); // = default virtual ~IMutableContext(); // = default
virtual void setResultCapture( IResultCapture* resultCapture ) = 0; virtual void setResultCapture( IResultCapture* resultCapture ) = 0;
virtual void setConfig( IConfig const* config ) = 0; virtual void setConfig( IConfig const* config ) = 0;

View File

@ -33,7 +33,11 @@
namespace Catch { namespace Catch {
struct ITransientExpression { class ITransientExpression {
bool m_isBinaryExpression;
bool m_result;
public:
auto isBinaryExpression() const -> bool { return m_isBinaryExpression; } auto isBinaryExpression() const -> bool { return m_isBinaryExpression; }
auto getResult() const -> bool { return m_result; } auto getResult() const -> bool { return m_result; }
virtual void streamReconstructedExpression( std::ostream &os ) const = 0; virtual void streamReconstructedExpression( std::ostream &os ) const = 0;
@ -51,8 +55,6 @@ namespace Catch {
// complain if it's not here :-( // complain if it's not here :-(
virtual ~ITransientExpression(); // = default; virtual ~ITransientExpression(); // = default;
bool m_isBinaryExpression;
bool m_result;
friend std::ostream& operator<<(std::ostream& out, ITransientExpression const& expr) { friend std::ostream& operator<<(std::ostream& out, ITransientExpression const& expr) {
expr.streamReconstructedExpression(out); expr.streamReconstructedExpression(out);
return out; return out;

View File

@ -12,7 +12,7 @@
namespace Catch { namespace Catch {
struct ITransientExpression; class ITransientExpression;
class LazyExpression { class LazyExpression {
friend class AssertionHandler; friend class AssertionHandler;

View File

@ -24,9 +24,9 @@
namespace Catch { namespace Catch {
struct IMutableContext; class IMutableContext;
struct IGeneratorTracker; class IGeneratorTracker;
struct IConfig; class IConfig;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////

View File

@ -16,7 +16,7 @@
namespace Catch { namespace Catch {
class TestCaseHandle; class TestCaseHandle;
struct IConfig; class IConfig;
class TestSpec; class TestSpec;
std::vector<TestCaseHandle> sortTests( IConfig const& config, std::vector<TestCaseHandle> const& unsortedTestCases ); std::vector<TestCaseHandle> sortTests( IConfig const& config, std::vector<TestCaseHandle> const& unsortedTestCases );

View File

@ -20,7 +20,7 @@
namespace Catch { namespace Catch {
struct ITagAliasRegistry; class ITagAliasRegistry;
class TestSpecParser { class TestSpecParser {
enum Mode{ None, Name, QuotedName, Tag, EscapedName }; enum Mode{ None, Name, QuotedName, Tag, EscapedName };

View File

@ -17,7 +17,7 @@
namespace Catch { namespace Catch {
struct IConfig; class IConfig;
class TestCaseHandle; class TestCaseHandle;
class ColourImpl; class ColourImpl;