From 0b60caac4ae8e7762cc530a0a7b6a7abe8c33262 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 30 May 2014 10:56:12 +0200 Subject: Test failures are reported verbosely and into the debug console on Win. --- src/Globals.h | 20 ++++++++++++++++++-- tests/ChunkData/CMakeLists.txt | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Globals.h b/src/Globals.h index 85cfd2f18..7b7a34541 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -271,9 +271,25 @@ void inline LOGERROR(const char* a_Format, ...) { }; + #ifdef _WIN32 + #define REPORT_ERROR(FMT, ...) \ + { \ + AString msg = Printf(FMT, __VA_ARGS__); \ + puts(msg.c_str()); \ + fflush(stdout); \ + OutputDebugStringA(msg.c_str()); \ + } + #else + #define REPORT_ERROR(FMT, ...) \ + { \ + AString msg = Printf(FMT, __VA_ARGS__); \ + puts(msg.c_str()); \ + fflush(stdout); \ + } + #endif #define ASSERT(x) do { if (!(x)) { throw cAssertFailure();} } while (0) - #define testassert(x) do { if(!(x)) { exit(1); } } while (0) - #define CheckAsserts(x) do { try {x} catch (cAssertFailure) { break; } exit(1); } while (0) + #define testassert(x) do { if(!(x)) { REPORT_ERROR("Test failure: %s, file %s, line %d\n", #x, __FILE__, __LINE__); exit(1); } } while (0) + #define CheckAsserts(x) do { try {x} catch (cAssertFailure) { break; } REPORT_ERROR("Test failure: assert didn't fire for %s, file %s, line %d\n", #x, __FILE__, __LINE__); exit(1); } while (0) #else #ifdef _DEBUG diff --git a/tests/ChunkData/CMakeLists.txt b/tests/ChunkData/CMakeLists.txt index a2bd9fd22..fd508cc6e 100644 --- a/tests/ChunkData/CMakeLists.txt +++ b/tests/ChunkData/CMakeLists.txt @@ -5,7 +5,7 @@ enable_testing() include_directories(${CMAKE_SOURCE_DIR}/src/) add_definitions(-DTEST_GLOBALS=1) -add_library(ChunkBuffer ${CMAKE_SOURCE_DIR}/src/ChunkData.cpp) +add_library(ChunkBuffer ${CMAKE_SOURCE_DIR}/src/ChunkData.cpp ${CMAKE_SOURCE_DIR}/src/StringUtils.cpp) add_executable(creatable-exe creatable.cpp) -- cgit v1.2.3