1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- #ifndef TWOBLUECUBES_CATCH_FATAL_CONDITION_H_INCLUDED
- #define TWOBLUECUBES_CATCH_FATAL_CONDITION_H_INCLUDED
- #include "catch_platform.h"
- #include "catch_compiler_capabilities.h"
- #include <cassert>
- namespace Catch {
-
-
-
-
-
-
-
-
- class FatalConditionHandler {
- bool m_started = false;
-
-
-
- void engage_platform();
- void disengage_platform();
- public:
-
- FatalConditionHandler();
- ~FatalConditionHandler();
- void engage() {
- assert(!m_started && "Handler cannot be installed twice.");
- m_started = true;
- engage_platform();
- }
- void disengage() {
- assert(m_started && "Handler cannot be uninstalled without being installed first");
- m_started = false;
- disengage_platform();
- }
- };
-
- class FatalConditionHandlerGuard {
- FatalConditionHandler* m_handler;
- public:
- FatalConditionHandlerGuard(FatalConditionHandler* handler):
- m_handler(handler) {
- m_handler->engage();
- }
- ~FatalConditionHandlerGuard() {
- m_handler->disengage();
- }
- };
- }
- #endif
|