mirror of https://github.com/catchorg/Catch2.git
commit
505d2f8977
|
@ -45,21 +45,16 @@ namespace Catch {
|
||||||
IResultCapture* m_resultCapture = nullptr;
|
IResultCapture* m_resultCapture = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace {
|
IMutableContext *IMutableContext::currentContext = nullptr;
|
||||||
Context* currentContext = nullptr;
|
|
||||||
}
|
void IMutableContext::createContext()
|
||||||
IMutableContext& getCurrentMutableContext() {
|
{
|
||||||
if( !currentContext )
|
currentContext = new Context();
|
||||||
currentContext = new Context();
|
|
||||||
return *currentContext;
|
|
||||||
}
|
|
||||||
IContext& getCurrentContext() {
|
|
||||||
return getCurrentMutableContext();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanUpContext() {
|
void cleanUpContext() {
|
||||||
delete currentContext;
|
delete IMutableContext::currentContext;
|
||||||
currentContext = nullptr;
|
IMutableContext::currentContext = nullptr;
|
||||||
}
|
}
|
||||||
IContext::~IContext() = default;
|
IContext::~IContext() = default;
|
||||||
IMutableContext::~IMutableContext() = default;
|
IMutableContext::~IMutableContext() = default;
|
||||||
|
|
|
@ -15,6 +15,7 @@ namespace Catch {
|
||||||
struct IResultCapture;
|
struct IResultCapture;
|
||||||
struct IRunner;
|
struct IRunner;
|
||||||
struct IConfig;
|
struct IConfig;
|
||||||
|
struct IMutableContext;
|
||||||
|
|
||||||
using IConfigPtr = std::shared_ptr<IConfig const>;
|
using IConfigPtr = std::shared_ptr<IConfig const>;
|
||||||
|
|
||||||
|
@ -33,10 +34,26 @@ namespace Catch {
|
||||||
virtual void setResultCapture( IResultCapture* resultCapture ) = 0;
|
virtual void setResultCapture( IResultCapture* resultCapture ) = 0;
|
||||||
virtual void setRunner( IRunner* runner ) = 0;
|
virtual void setRunner( IRunner* runner ) = 0;
|
||||||
virtual void setConfig( IConfigPtr const& config ) = 0;
|
virtual void setConfig( IConfigPtr const& config ) = 0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static IMutableContext *currentContext;
|
||||||
|
friend IMutableContext& getCurrentMutableContext();
|
||||||
|
friend void cleanUpContext();
|
||||||
|
static void createContext();
|
||||||
};
|
};
|
||||||
|
|
||||||
IContext& getCurrentContext();
|
inline IMutableContext& getCurrentMutableContext()
|
||||||
IMutableContext& getCurrentMutableContext();
|
{
|
||||||
|
if( !IMutableContext::currentContext )
|
||||||
|
IMutableContext::createContext();
|
||||||
|
return *IMutableContext::currentContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline IContext& getCurrentContext()
|
||||||
|
{
|
||||||
|
return getCurrentMutableContext();
|
||||||
|
}
|
||||||
|
|
||||||
void cleanUpContext();
|
void cleanUpContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,6 @@
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
auto StringRef::operator = ( StringRef other ) noexcept -> StringRef& {
|
|
||||||
swap( other );
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
StringRef::operator std::string() const {
|
StringRef::operator std::string() const {
|
||||||
return std::string( m_start, m_size );
|
return std::string( m_start, m_size );
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,14 @@ namespace Catch {
|
||||||
delete[] m_data;
|
delete[] m_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto operator = ( StringRef other ) noexcept -> StringRef&;
|
auto operator = ( StringRef const &other ) noexcept -> StringRef& {
|
||||||
|
delete[] m_data;
|
||||||
|
m_data = nullptr;
|
||||||
|
m_start = other.m_start;
|
||||||
|
m_size = other.m_size;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
operator std::string() const;
|
operator std::string() const;
|
||||||
|
|
||||||
void swap( StringRef& other ) noexcept;
|
void swap( StringRef& other ) noexcept;
|
||||||
|
|
Loading…
Reference in New Issue