Split writeToDebugConsole out of main path

This commit is contained in:
Martin Hořeňovský 2017-08-29 13:51:55 +02:00
parent faead53151
commit 5932576f53
6 changed files with 50 additions and 24 deletions

View File

@ -132,6 +132,7 @@ set(INTERNAL_HEADERS
${HEADER_DIR}/internal/catch_config.hpp ${HEADER_DIR}/internal/catch_config.hpp
${HEADER_DIR}/internal/catch_console_colour.hpp ${HEADER_DIR}/internal/catch_console_colour.hpp
${HEADER_DIR}/internal/catch_context.h ${HEADER_DIR}/internal/catch_context.h
${HEADER_DIR}/internal/catch_debug_console.h
${HEADER_DIR}/internal/catch_debugger.h ${HEADER_DIR}/internal/catch_debugger.h
${HEADER_DIR}/internal/catch_decomposer.h ${HEADER_DIR}/internal/catch_decomposer.h
${HEADER_DIR}/internal/catch_default_main.hpp ${HEADER_DIR}/internal/catch_default_main.hpp
@ -203,6 +204,7 @@ set(IMPL_SOURCES
${HEADER_DIR}/internal/catch_config.cpp ${HEADER_DIR}/internal/catch_config.cpp
${HEADER_DIR}/internal/catch_console_colour.cpp ${HEADER_DIR}/internal/catch_console_colour.cpp
${HEADER_DIR}/internal/catch_context.cpp ${HEADER_DIR}/internal/catch_context.cpp
${HEADER_DIR}/internal/catch_debug_console.cpp
${HEADER_DIR}/internal/catch_debugger.cpp ${HEADER_DIR}/internal/catch_debugger.cpp
${HEADER_DIR}/internal/catch_decomposer.cpp ${HEADER_DIR}/internal/catch_decomposer.cpp
${HEADER_DIR}/internal/catch_errno_guard.cpp ${HEADER_DIR}/internal/catch_errno_guard.cpp

View File

@ -0,0 +1,29 @@
/*
* Created by Martin on 29/08/2017.
*
* 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)
*
*/
#include "catch_debug_console.h"
#include "catch_stream.h"
#include "catch_platform.h"
#ifdef CATCH_PLATFORM_WINDOWS
#include "catch_windows_h_proxy.h"
namespace Catch {
void writeToDebugConsole( std::string const& text ) {
::OutputDebugStringA( text.c_str() );
}
}
#else
namespace Catch {
void writeToDebugConsole( std::string const& text ) {
// !TBD: Need a version for Mac/ XCode and other IDEs
Catch::cout() << text;
}
}
#endif // Platform

View File

@ -0,0 +1,17 @@
/*
* Created by Martin on 29/08/2017.
*
* 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_DEBUG_CONSOLE_H_INCLUDED
#define TWOBLUECUBES_CATCH_DEBUG_CONSOLE_H_INCLUDED
#include <string>
namespace Catch {
void writeToDebugConsole( std::string const& text );
}
#endif // TWOBLUECUBES_CATCH_DEBUG_CONSOLE_H_INCLUDED

View File

@ -109,21 +109,3 @@
bool isDebuggerActive() { return false; } bool isDebuggerActive() { return false; }
} }
#endif // Platform #endif // Platform
#ifdef CATCH_PLATFORM_WINDOWS
#include "catch_windows_h_proxy.h"
namespace Catch {
void writeToDebugConsole( std::string const& text ) {
::OutputDebugStringA( text.c_str() );
}
}
#else
namespace Catch {
void writeToDebugConsole( std::string const& text ) {
// !TBD: Need a version for Mac/ XCode and other IDEs
Catch::cout() << text;
}
}
#endif // Platform

View File

@ -11,12 +11,8 @@
#include "catch_platform.h" #include "catch_platform.h"
#include <string> namespace Catch {
namespace Catch{
bool isDebuggerActive(); bool isDebuggerActive();
void writeToDebugConsole( std::string const& text );
} }
#ifdef CATCH_PLATFORM_MAC #ifdef CATCH_PLATFORM_MAC

View File

@ -10,7 +10,7 @@
#include "catch_common.h" #include "catch_common.h"
#include "catch_enforce.h" #include "catch_enforce.h"
#include "catch_stream.h" #include "catch_stream.h"
#include "catch_debugger.h" #include "catch_debug_console.h"
#include <stdexcept> #include <stdexcept>
#include <cstdio> #include <cstdio>