2
0
mirror of https://github.com/boostorg/nowide.git synced 2026-02-22 03:22:32 +00:00
Files
nowide/test/test.hpp

41 lines
1.7 KiB
C++

//
// Copyright (c) 2012 Artyom Beilis (Tonkikh)
// Copyright (c) 2019 Alexander Grund
//
// 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 BOOST_NOWIDE_LIB_TEST_H_INCLUDED
#define BOOST_NOWIDE_LIB_TEST_H_INCLUDED
#include <sstream>
#include <stdexcept>
/// Function called when a test failed to be able set a breakpoint for debugging
inline void test_failed(const std::string& msg)
{
throw std::runtime_error(msg);
}
#ifdef _MSC_VER
#define DISABLE_CONST_EXPR_DETECTED __pragma(warning(push)) __pragma(warning(disable : 4127))
#define DISABLE_CONST_EXPR_DETECTED_POP __pragma(warning(pop))
#else
#define DISABLE_CONST_EXPR_DETECTED
#define DISABLE_CONST_EXPR_DETECTED_POP
#endif
#define TEST(x) \
do \
{ \
if(x) \
break; \
std::ostringstream ss; \
ss << "Error " #x " in " << __FILE__ << ':' << __LINE__ << " " << __FUNCTION__; \
test_failed(ss.str()); \
DISABLE_CONST_EXPR_DETECTED \
} while(0) DISABLE_CONST_EXPR_DETECTED_POP
#endif // #ifndef BOOST_NOWIDE_LIB_TEST_H_INCLUDED