mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Removed Ptr, Shared and SharedImpl
This commit is contained in:
parent
e6094a9503
commit
8ccbf63f28
@ -90,7 +90,6 @@ set(IMPL_SOURCES
|
|||||||
${SELF_TEST_DIR}/SurrogateCpps/catch_interfaces_testcase.cpp
|
${SELF_TEST_DIR}/SurrogateCpps/catch_interfaces_testcase.cpp
|
||||||
${SELF_TEST_DIR}/SurrogateCpps/catch_message.cpp
|
${SELF_TEST_DIR}/SurrogateCpps/catch_message.cpp
|
||||||
${SELF_TEST_DIR}/SurrogateCpps/catch_option.cpp
|
${SELF_TEST_DIR}/SurrogateCpps/catch_option.cpp
|
||||||
${SELF_TEST_DIR}/SurrogateCpps/catch_ptr.cpp
|
|
||||||
${SELF_TEST_DIR}/SurrogateCpps/catch_stream.cpp
|
${SELF_TEST_DIR}/SurrogateCpps/catch_stream.cpp
|
||||||
${SELF_TEST_DIR}/SurrogateCpps/catch_streambuf.cpp
|
${SELF_TEST_DIR}/SurrogateCpps/catch_streambuf.cpp
|
||||||
${SELF_TEST_DIR}/SurrogateCpps/catch_test_spec.cpp
|
${SELF_TEST_DIR}/SurrogateCpps/catch_test_spec.cpp
|
||||||
@ -152,8 +151,6 @@ set(INTERNAL_HEADERS
|
|||||||
${HEADER_DIR}/internal/catch_interfaces_runner.h
|
${HEADER_DIR}/internal/catch_interfaces_runner.h
|
||||||
${HEADER_DIR}/internal/catch_interfaces_tag_alias_registry.h
|
${HEADER_DIR}/internal/catch_interfaces_tag_alias_registry.h
|
||||||
${HEADER_DIR}/internal/catch_interfaces_testcase.h
|
${HEADER_DIR}/internal/catch_interfaces_testcase.h
|
||||||
${HEADER_DIR}/internal/catch_legacy_reporter_adapter.h
|
|
||||||
${HEADER_DIR}/internal/catch_legacy_reporter_adapter.hpp
|
|
||||||
${HEADER_DIR}/internal/catch_list.hpp
|
${HEADER_DIR}/internal/catch_list.hpp
|
||||||
${HEADER_DIR}/internal/catch_matchers.hpp
|
${HEADER_DIR}/internal/catch_matchers.hpp
|
||||||
${HEADER_DIR}/internal/catch_matchers_string.h
|
${HEADER_DIR}/internal/catch_matchers_string.h
|
||||||
@ -167,7 +164,6 @@ set(INTERNAL_HEADERS
|
|||||||
${HEADER_DIR}/internal/catch_objc_arc.hpp
|
${HEADER_DIR}/internal/catch_objc_arc.hpp
|
||||||
${HEADER_DIR}/internal/catch_option.hpp
|
${HEADER_DIR}/internal/catch_option.hpp
|
||||||
${HEADER_DIR}/internal/catch_platform.h
|
${HEADER_DIR}/internal/catch_platform.h
|
||||||
${HEADER_DIR}/internal/catch_ptr.hpp
|
|
||||||
${HEADER_DIR}/internal/catch_reenable_warnings.h
|
${HEADER_DIR}/internal/catch_reenable_warnings.h
|
||||||
${HEADER_DIR}/internal/catch_registry_hub.hpp
|
${HEADER_DIR}/internal/catch_registry_hub.hpp
|
||||||
${HEADER_DIR}/internal/catch_reporter_registrars.hpp
|
${HEADER_DIR}/internal/catch_reporter_registrars.hpp
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
#define TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED
|
#define TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED
|
||||||
|
|
||||||
#include "catch_interfaces_generators.h"
|
#include "catch_interfaces_generators.h"
|
||||||
#include "catch_ptr.hpp"
|
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
|
@ -47,7 +47,6 @@ namespace Catch {
|
|||||||
// These are all here to avoid warnings about not having any out of line
|
// These are all here to avoid warnings about not having any out of line
|
||||||
// virtual methods
|
// virtual methods
|
||||||
NonCopyable::~NonCopyable() {}
|
NonCopyable::~NonCopyable() {}
|
||||||
IShared::~IShared() {}
|
|
||||||
IStream::~IStream() noexcept {}
|
IStream::~IStream() noexcept {}
|
||||||
FileStream::~FileStream() noexcept {}
|
FileStream::~FileStream() noexcept {}
|
||||||
CoutStream::~CoutStream() noexcept {}
|
CoutStream::~CoutStream() noexcept {}
|
||||||
|
@ -8,11 +8,12 @@
|
|||||||
#ifndef TWOBLUECUBES_CATCH_INTERFACES_CONFIG_H_INCLUDED
|
#ifndef TWOBLUECUBES_CATCH_INTERFACES_CONFIG_H_INCLUDED
|
||||||
#define TWOBLUECUBES_CATCH_INTERFACES_CONFIG_H_INCLUDED
|
#define TWOBLUECUBES_CATCH_INTERFACES_CONFIG_H_INCLUDED
|
||||||
|
|
||||||
|
#include "catch_common.h"
|
||||||
|
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <memory>
|
||||||
#include "catch_ptr.hpp"
|
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
|
@ -8,9 +8,10 @@
|
|||||||
#ifndef TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED
|
#ifndef TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED
|
||||||
#define TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED
|
#define TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED
|
||||||
|
|
||||||
#include "catch_ptr.hpp"
|
#include "catch_common.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
#include "catch_section_info.h"
|
#include "catch_section_info.h"
|
||||||
#include "catch_common.h"
|
#include "catch_common.h"
|
||||||
#include "catch_totals.hpp"
|
#include "catch_totals.hpp"
|
||||||
#include "catch_ptr.hpp"
|
|
||||||
#include "catch_config.hpp"
|
#include "catch_config.hpp"
|
||||||
#include "catch_test_case_info.h"
|
#include "catch_test_case_info.h"
|
||||||
#include "catch_assertionresult.h"
|
#include "catch_assertionresult.h"
|
||||||
|
@ -8,9 +8,8 @@
|
|||||||
#ifndef TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED
|
#ifndef TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED
|
||||||
#define TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED
|
#define TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED
|
||||||
|
|
||||||
#include "catch_ptr.hpp"
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
|
@ -1,93 +0,0 @@
|
|||||||
/*
|
|
||||||
* Created by Phil on 02/05/2012.
|
|
||||||
* Copyright 2012 Two Blue Cubes Ltd. All rights reserved.
|
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
*/
|
|
||||||
#ifndef TWOBLUECUBES_CATCH_PTR_HPP_INCLUDED
|
|
||||||
#define TWOBLUECUBES_CATCH_PTR_HPP_INCLUDED
|
|
||||||
|
|
||||||
#include "catch_common.h"
|
|
||||||
|
|
||||||
#ifdef __clang__
|
|
||||||
#pragma clang diagnostic push
|
|
||||||
#pragma clang diagnostic ignored "-Wpadded"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace Catch {
|
|
||||||
|
|
||||||
// An intrusive reference counting smart pointer.
|
|
||||||
// T must implement addRef() and release() methods
|
|
||||||
// typically implementing the IShared interface
|
|
||||||
template<typename T>
|
|
||||||
class Ptr {
|
|
||||||
public:
|
|
||||||
Ptr() : m_p( nullptr ){}
|
|
||||||
Ptr( T* p ) : m_p( p ){
|
|
||||||
if( m_p )
|
|
||||||
m_p->addRef();
|
|
||||||
}
|
|
||||||
Ptr( Ptr const& other ) : m_p( other.m_p ){
|
|
||||||
if( m_p )
|
|
||||||
m_p->addRef();
|
|
||||||
}
|
|
||||||
~Ptr(){
|
|
||||||
if( m_p )
|
|
||||||
m_p->release();
|
|
||||||
}
|
|
||||||
void reset() {
|
|
||||||
if( m_p )
|
|
||||||
m_p->release();
|
|
||||||
m_p = nullptr;
|
|
||||||
}
|
|
||||||
Ptr& operator = ( T* p ){
|
|
||||||
Ptr temp( p );
|
|
||||||
swap( temp );
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
Ptr& operator = ( Ptr const& other ){
|
|
||||||
Ptr temp( other );
|
|
||||||
swap( temp );
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
void swap( Ptr& other ) { std::swap( m_p, other.m_p ); }
|
|
||||||
T* get() const{ return m_p; }
|
|
||||||
T& operator*() const { return *m_p; }
|
|
||||||
T* operator->() const { return m_p; }
|
|
||||||
bool operator !() const { return m_p == nullptr; }
|
|
||||||
explicit operator bool() const { return m_p != nullptr; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
T* m_p;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct IShared : NonCopyable {
|
|
||||||
virtual ~IShared();
|
|
||||||
virtual void addRef() const = 0;
|
|
||||||
virtual void release() const = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T = IShared>
|
|
||||||
struct SharedImpl : T {
|
|
||||||
|
|
||||||
SharedImpl() : m_rc( 0 ){}
|
|
||||||
|
|
||||||
virtual void addRef() const {
|
|
||||||
++m_rc;
|
|
||||||
}
|
|
||||||
virtual void release() const {
|
|
||||||
if( --m_rc == 0 )
|
|
||||||
delete this;
|
|
||||||
}
|
|
||||||
|
|
||||||
mutable unsigned int m_rc;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // end namespace Catch
|
|
||||||
|
|
||||||
#ifdef __clang__
|
|
||||||
#pragma clang diagnostic pop
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_PTR_HPP_INCLUDED
|
|
@ -9,10 +9,10 @@
|
|||||||
#define TWOBLUECUBES_CATCH_TEST_CASE_INFO_H_INCLUDED
|
#define TWOBLUECUBES_CATCH_TEST_CASE_INFO_H_INCLUDED
|
||||||
|
|
||||||
#include "catch_common.h"
|
#include "catch_common.h"
|
||||||
#include "catch_ptr.hpp"
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
#pragma clang diagnostic push
|
#pragma clang diagnostic push
|
||||||
|
@ -127,7 +127,7 @@ namespace Catch {
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class FreeFunctionTestCase : public SharedImpl<ITestCase> {
|
class FreeFunctionTestCase : public ITestCase {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FreeFunctionTestCase( TestFunction fun ) : m_fun( fun ) {}
|
FreeFunctionTestCase( TestFunction fun ) : m_fun( fun ) {}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#define TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
|
#define TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
|
||||||
|
|
||||||
#include "catch_compiler_capabilities.h"
|
#include "catch_compiler_capabilities.h"
|
||||||
#include "catch_ptr.hpp"
|
#include "catch_common.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
template<typename C>
|
template<typename C>
|
||||||
class MethodTestCase : public SharedImpl<ITestCase> {
|
class MethodTestCase : public ITestCase {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MethodTestCase( void (C::*method)() ) : m_method( method ) {}
|
MethodTestCase( void (C::*method)() ) : m_method( method ) {}
|
||||||
|
@ -41,7 +41,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct StreamingReporterBase : SharedImpl<IStreamingReporter> {
|
struct StreamingReporterBase : IStreamingReporter {
|
||||||
|
|
||||||
StreamingReporterBase( ReporterConfig const& _config )
|
StreamingReporterBase( ReporterConfig const& _config )
|
||||||
: m_config( _config.fullConfig() ),
|
: m_config( _config.fullConfig() ),
|
||||||
@ -103,7 +103,7 @@ namespace Catch {
|
|||||||
ReporterPreferences m_reporterPrefs;
|
ReporterPreferences m_reporterPrefs;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CumulativeReporterBase : SharedImpl<IStreamingReporter> {
|
struct CumulativeReporterBase : IStreamingReporter {
|
||||||
template<typename T, typename ChildNodeT>
|
template<typename T, typename ChildNodeT>
|
||||||
struct Node {
|
struct Node {
|
||||||
explicit Node( T const& _value ) : value( _value ) {}
|
explicit Node( T const& _value ) : value( _value ) {}
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
class MultipleReporters : public SharedImpl<IStreamingReporter> {
|
class MultipleReporters : public IStreamingReporter {
|
||||||
typedef std::vector<IStreamingReporterPtr > Reporters;
|
typedef std::vector<IStreamingReporterPtr > Reporters;
|
||||||
Reporters m_reporters;
|
Reporters m_reporters;
|
||||||
|
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
// This file is only here to verify (to the extent possible) the self sufficiency of the header
|
|
||||||
#include "internal/catch_suppress_warnings.h"
|
|
||||||
#include "internal/catch_ptr.hpp"
|
|
Loading…
Reference in New Issue
Block a user