mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Split the NonCopyable helper out of catch_common.hpp
This commit is contained in:
parent
c1bb699d45
commit
e7eb749815
@ -38,6 +38,7 @@ set(INTERNAL_HEADERS
|
||||
${SOURCES_DIR}/matchers/internal/catch_matchers_impl.hpp
|
||||
${SOURCES_DIR}/internal/catch_console_width.hpp
|
||||
${SOURCES_DIR}/internal/catch_container_nonmembers.hpp
|
||||
${SOURCES_DIR}/internal/catch_noncopyable.hpp
|
||||
${SOURCES_DIR}/catch_approx.hpp
|
||||
${SOURCES_DIR}/internal/catch_assertion_handler.hpp
|
||||
${SOURCES_DIR}/catch_assertion_info.hpp
|
||||
|
@ -60,6 +60,7 @@
|
||||
#include <catch2/internal/catch_list.hpp>
|
||||
#include <catch2/internal/catch_message_info.hpp>
|
||||
#include <catch2/internal/catch_meta.hpp>
|
||||
#include <catch2/internal/catch_noncopyable.hpp>
|
||||
#include <catch2/internal/catch_option.hpp>
|
||||
#include <catch2/internal/catch_output_redirect.hpp>
|
||||
#include <catch2/internal/catch_platform.hpp>
|
||||
|
@ -18,13 +18,15 @@
|
||||
#include <catch2/internal/catch_singletons.hpp>
|
||||
#include <catch2/internal/catch_enum_values_registry.hpp>
|
||||
#include <catch2/catch_test_case_info.hpp>
|
||||
#include <catch2/internal/catch_noncopyable.hpp>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
namespace {
|
||||
|
||||
class RegistryHub : public IRegistryHub, public IMutableRegistryHub,
|
||||
private NonCopyable {
|
||||
class RegistryHub : public IRegistryHub,
|
||||
public IMutableRegistryHub,
|
||||
private Detail::NonCopyable {
|
||||
|
||||
public: // IRegistryHub
|
||||
RegistryHub() = default;
|
||||
|
@ -9,12 +9,14 @@
|
||||
#define TWOBLUECUBES_CATCH_RUNNER_HPP_INCLUDED
|
||||
|
||||
#include <catch2/internal/catch_commandline.hpp>
|
||||
#include <catch2/internal/catch_noncopyable.hpp>
|
||||
#include <catch2/catch_config.hpp>
|
||||
#include <catch2/internal/catch_unique_ptr.hpp>
|
||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
class Session : NonCopyable {
|
||||
class Session : Detail::NonCopyable {
|
||||
public:
|
||||
|
||||
Session();
|
||||
|
@ -9,6 +9,7 @@
|
||||
#define TWOBLUECUBES_CATCH_TEST_CASE_INFO_H_INCLUDED
|
||||
|
||||
#include <catch2/internal/catch_common.hpp>
|
||||
#include <catch2/internal/catch_noncopyable.hpp>
|
||||
#include <catch2/internal/catch_stringref.hpp>
|
||||
#include <catch2/internal/catch_test_registry.hpp>
|
||||
#include <catch2/internal/catch_unique_ptr.hpp>
|
||||
@ -44,7 +45,7 @@ namespace Catch {
|
||||
};
|
||||
|
||||
|
||||
struct TestCaseInfo : NonCopyable {
|
||||
struct TestCaseInfo : Detail::NonCopyable {
|
||||
|
||||
TestCaseInfo(std::string const& _className,
|
||||
NameAndTags const& _tags,
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef TWOBLUECUBES_CATCH_INTERFACES_CONFIG_H_INCLUDED
|
||||
#define TWOBLUECUBES_CATCH_INTERFACES_CONFIG_H_INCLUDED
|
||||
|
||||
#include <catch2/internal/catch_common.hpp>
|
||||
#include <catch2/internal/catch_noncopyable.hpp>
|
||||
|
||||
#include <chrono>
|
||||
#include <iosfwd>
|
||||
@ -53,7 +53,7 @@ namespace Catch {
|
||||
|
||||
class TestSpec;
|
||||
|
||||
struct IConfig : NonCopyable {
|
||||
struct IConfig : Detail::NonCopyable {
|
||||
|
||||
virtual ~IConfig();
|
||||
|
||||
|
@ -8,7 +8,6 @@
|
||||
#ifndef TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED
|
||||
#define TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED
|
||||
|
||||
#include <catch2/internal/catch_common.hpp>
|
||||
#include <catch2/internal/catch_unique_ptr.hpp>
|
||||
|
||||
#include <string>
|
||||
@ -25,6 +24,7 @@ namespace Catch {
|
||||
struct ITagAliasRegistry;
|
||||
struct ITestInvoker;
|
||||
struct IMutableEnumValuesRegistry;
|
||||
struct SourceLineInfo;
|
||||
|
||||
class StartupExceptionRegistry;
|
||||
|
||||
|
@ -30,6 +30,8 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <catch2/internal/catch_noncopyable.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <cctype>
|
||||
#include <memory>
|
||||
@ -286,15 +288,7 @@ namespace Catch {
|
||||
}
|
||||
#endif // CLARA_CONFIG_OPTIONAL_TYPE
|
||||
|
||||
struct NonCopyable {
|
||||
NonCopyable() = default;
|
||||
NonCopyable( NonCopyable const& ) = delete;
|
||||
NonCopyable( NonCopyable&& ) = delete;
|
||||
NonCopyable& operator=( NonCopyable const& ) = delete;
|
||||
NonCopyable& operator=( NonCopyable&& ) = delete;
|
||||
};
|
||||
|
||||
struct BoundRef : NonCopyable {
|
||||
struct BoundRef : Catch::Detail::NonCopyable {
|
||||
virtual ~BoundRef() = default;
|
||||
virtual auto isContainer() const -> bool { return false; }
|
||||
virtual auto isFlag() const -> bool { return false; }
|
||||
|
@ -32,15 +32,6 @@ namespace Catch {
|
||||
No
|
||||
}; };
|
||||
|
||||
class NonCopyable {
|
||||
NonCopyable( NonCopyable const& ) = delete;
|
||||
NonCopyable( NonCopyable && ) = delete;
|
||||
NonCopyable& operator = ( NonCopyable const& ) = delete;
|
||||
NonCopyable& operator = ( NonCopyable && ) = delete;
|
||||
protected:
|
||||
NonCopyable() noexcept = default;
|
||||
};
|
||||
|
||||
struct SourceLineInfo {
|
||||
|
||||
SourceLineInfo() = delete;
|
||||
|
@ -6,12 +6,12 @@
|
||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <catch2/internal/catch_context.hpp>
|
||||
#include <catch2/internal/catch_common.hpp>
|
||||
#include <catch2/internal/catch_noncopyable.hpp>
|
||||
#include <catch2/internal/catch_random_number_generator.hpp>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
class Context : public IMutableContext, NonCopyable {
|
||||
class Context : public IMutableContext, private Detail::NonCopyable {
|
||||
|
||||
public: // IContext
|
||||
IResultCapture* getResultCapture() override {
|
||||
|
21
src/catch2/internal/catch_noncopyable.hpp
Normal file
21
src/catch2/internal/catch_noncopyable.hpp
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef CATCH_NONCOPYABLE_HPP_INCLUDED
|
||||
#define CATCH_NONCOPYABLE_HPP_INCLUDED
|
||||
|
||||
namespace Catch {
|
||||
namespace Detail {
|
||||
|
||||
//! Deriving classes become noncopyable and nonmovable
|
||||
class NonCopyable {
|
||||
NonCopyable( NonCopyable const& ) = delete;
|
||||
NonCopyable( NonCopyable&& ) = delete;
|
||||
NonCopyable& operator=( NonCopyable const& ) = delete;
|
||||
NonCopyable& operator=( NonCopyable&& ) = delete;
|
||||
|
||||
protected:
|
||||
NonCopyable() noexcept = default;
|
||||
};
|
||||
|
||||
} // namespace Detail
|
||||
} // namespace Catch
|
||||
|
||||
#endif // CATCH_NONCOPYABLE_HPP_INCLUDED
|
@ -9,6 +9,7 @@
|
||||
#define TWOBLUECUBES_CATCH_SECTION_H_INCLUDED
|
||||
|
||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
||||
#include <catch2/internal/catch_noncopyable.hpp>
|
||||
#include <catch2/catch_section_info.hpp>
|
||||
#include <catch2/catch_timer.hpp>
|
||||
#include <catch2/catch_totals.hpp>
|
||||
@ -17,7 +18,7 @@
|
||||
|
||||
namespace Catch {
|
||||
|
||||
class Section : NonCopyable {
|
||||
class Section : Detail::NonCopyable {
|
||||
public:
|
||||
Section( SectionInfo&& info );
|
||||
~Section();
|
||||
|
@ -9,7 +9,7 @@
|
||||
#ifndef TWOBLUECUBES_CATCH_STREAM_H_INCLUDED
|
||||
#define TWOBLUECUBES_CATCH_STREAM_H_INCLUDED
|
||||
|
||||
#include <catch2/internal/catch_common.hpp>
|
||||
#include <catch2/internal/catch_noncopyable.hpp>
|
||||
|
||||
#include <iosfwd>
|
||||
#include <cstddef>
|
||||
@ -30,7 +30,7 @@ namespace Catch {
|
||||
|
||||
auto makeStream( StringRef const &filename ) -> IStream const*;
|
||||
|
||||
class ReusableStringStream : NonCopyable {
|
||||
class ReusableStringStream : Detail::NonCopyable {
|
||||
std::size_t m_index;
|
||||
std::ostream* m_oss;
|
||||
public:
|
||||
|
@ -9,6 +9,7 @@
|
||||
#define TWOBLUECUBES_CATCH_TEST_REGISTRY_HPP_INCLUDED
|
||||
|
||||
#include <catch2/internal/catch_common.hpp>
|
||||
#include <catch2/internal/catch_noncopyable.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_testcase.hpp>
|
||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
||||
#include <catch2/internal/catch_stringref.hpp>
|
||||
@ -52,7 +53,7 @@ struct NameAndTags {
|
||||
StringRef tags;
|
||||
};
|
||||
|
||||
struct AutoReg : NonCopyable {
|
||||
struct AutoReg : Detail::NonCopyable {
|
||||
AutoReg( Detail::unique_ptr<ITestInvoker> invoker, SourceLineInfo const& lineInfo, StringRef const& classOrMethod, NameAndTags const& nameAndTags ) noexcept;
|
||||
};
|
||||
|
||||
|
@ -11,6 +11,13 @@
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
||||
|
||||
// FixMe: Without this include (and something inside it), MSVC goes crazy
|
||||
// and reports that calls to XmlEncode's op << are ambiguous between
|
||||
// the declaration and definition.
|
||||
// It also has to be in the header.
|
||||
#include <catch2/internal/catch_common.hpp>
|
||||
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace Catch {
|
||||
|
Loading…
Reference in New Issue
Block a user