catch_context.cpp
1 2 // Copyright Catch2 Authors 3 // Distributed under the Boost Software License, Version 1.0. 4 // (See accompanying file LICENSE.txt or copy at 5 // https://www.boost.org/LICENSE_1_0.txt) 6 7 // SPDX-License-Identifier: BSL-1.0 8 #include <catch2/internal/catch_context.hpp> 9 #include <catch2/internal/catch_noncopyable.hpp> 10 #include <catch2/internal/catch_random_number_generator.hpp> 11 12 namespace Catch { 13 14 Context* Context::currentContext = nullptr; 15 16 void cleanUpContext() { 17 delete Context::currentContext; 18 Context::currentContext = nullptr; 19 } 20 void Context::createContext() { 21 currentContext = new Context(); 22 } 23 24 Context& getCurrentMutableContext() { 25 if ( !Context::currentContext ) { Context::createContext(); } 26 // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.UndefReturn) 27 return *Context::currentContext; 28 } 29 30 void Context::setResultCapture( IResultCapture* resultCapture ) { 31 m_resultCapture = resultCapture; 32 } 33 34 void Context::setConfig( IConfig const* config ) { m_config = config; } 35 36 SimplePcg32& sharedRng() { 37 static SimplePcg32 s_rng; 38 return s_rng; 39 } 40 41 }