forked from boostorg/assert
Fix failures when __FILE__ contains backslashes
This commit is contained in:
@@ -14,8 +14,9 @@ test-suite "assert"
|
|||||||
[ run assert_test.cpp ]
|
[ run assert_test.cpp ]
|
||||||
[ run current_function_test.cpp : : : <test-info>always_show_run_output ]
|
[ run current_function_test.cpp : : : <test-info>always_show_run_output ]
|
||||||
[ run verify_test.cpp ]
|
[ run verify_test.cpp ]
|
||||||
[ run assert_exp_test.cpp ]
|
# expansion tests are in exp/ so that there is a backslash in the path on Windows
|
||||||
[ run assert_msg_exp_test.cpp ]
|
[ run exp/assert_exp_test.cpp ]
|
||||||
[ run verify_exp_test.cpp ]
|
[ run exp/assert_msg_exp_test.cpp ]
|
||||||
[ run verify_msg_exp_test.cpp ]
|
[ run exp/verify_exp_test.cpp ]
|
||||||
|
[ run exp/verify_msg_exp_test.cpp ]
|
||||||
;
|
;
|
||||||
|
@@ -13,6 +13,21 @@
|
|||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
// Each backslash in __FILE__ when passed through BOOST_STRINGIZE is doubled
|
||||||
|
static std::string quote( std::string const & s )
|
||||||
|
{
|
||||||
|
std::string r;
|
||||||
|
r.reserve( s.size() );
|
||||||
|
|
||||||
|
for( char const * p = s.c_str(); *p; ++p )
|
||||||
|
{
|
||||||
|
r += *p;
|
||||||
|
if( *p == '\\' ) r += *p;
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
// default case, !NDEBUG
|
// default case, !NDEBUG
|
||||||
// BOOST_ASSERT(x) -> assert(x)
|
// BOOST_ASSERT(x) -> assert(x)
|
||||||
|
|
||||||
@@ -80,7 +95,7 @@ void test_disabled_ndebug()
|
|||||||
|
|
||||||
void test_handler()
|
void test_handler()
|
||||||
{
|
{
|
||||||
std::string v5 = BOOST_STRINGIZE(BOOST_ASSERT(x5)); std::string w5 = "(BOOST_LIKELY(!!(x5))? ((void)0): ::boost::assertion_failed(\"x5\", BOOST_CURRENT_FUNCTION, \"" __FILE__ "\", " BOOST_STRINGIZE(__LINE__) "))";
|
std::string v5 = BOOST_STRINGIZE(BOOST_ASSERT(x5)); std::string w5 = "(BOOST_LIKELY(!!(x5))? ((void)0): ::boost::assertion_failed(\"x5\", BOOST_CURRENT_FUNCTION, \"" + quote( __FILE__ ) + "\", " BOOST_STRINGIZE(__LINE__) "))";
|
||||||
|
|
||||||
char const * BOOST_CURRENT_FUNCTION = "void test_handler()";
|
char const * BOOST_CURRENT_FUNCTION = "void test_handler()";
|
||||||
BOOST_TEST_EQ( v5, w5 );
|
BOOST_TEST_EQ( v5, w5 );
|
||||||
@@ -94,7 +109,7 @@ void test_handler()
|
|||||||
|
|
||||||
void test_handler_ndebug()
|
void test_handler_ndebug()
|
||||||
{
|
{
|
||||||
std::string v6 = BOOST_STRINGIZE(BOOST_ASSERT(x6)); std::string w6 = "(BOOST_LIKELY(!!(x6))? ((void)0): ::boost::assertion_failed(\"x6\", BOOST_CURRENT_FUNCTION, \"" __FILE__ "\", " BOOST_STRINGIZE(__LINE__) "))";
|
std::string v6 = BOOST_STRINGIZE(BOOST_ASSERT(x6)); std::string w6 = "(BOOST_LIKELY(!!(x6))? ((void)0): ::boost::assertion_failed(\"x6\", BOOST_CURRENT_FUNCTION, \"" + quote( __FILE__ ) + "\", " BOOST_STRINGIZE(__LINE__) "))";
|
||||||
|
|
||||||
char const * BOOST_CURRENT_FUNCTION = "void test_handler_ndebug()";
|
char const * BOOST_CURRENT_FUNCTION = "void test_handler_ndebug()";
|
||||||
BOOST_TEST_EQ( v6, w6 );
|
BOOST_TEST_EQ( v6, w6 );
|
||||||
@@ -112,7 +127,7 @@ void test_handler_ndebug()
|
|||||||
|
|
||||||
void test_debug_handler()
|
void test_debug_handler()
|
||||||
{
|
{
|
||||||
std::string v7 = BOOST_STRINGIZE(BOOST_ASSERT(x7)); std::string w7 = "(BOOST_LIKELY(!!(x7))? ((void)0): ::boost::assertion_failed(\"x7\", BOOST_CURRENT_FUNCTION, \"" __FILE__ "\", " BOOST_STRINGIZE(__LINE__) "))";
|
std::string v7 = BOOST_STRINGIZE(BOOST_ASSERT(x7)); std::string w7 = "(BOOST_LIKELY(!!(x7))? ((void)0): ::boost::assertion_failed(\"x7\", BOOST_CURRENT_FUNCTION, \"" + quote( __FILE__ ) + "\", " BOOST_STRINGIZE(__LINE__) "))";
|
||||||
|
|
||||||
char const * BOOST_CURRENT_FUNCTION = "void test_debug_handler()";
|
char const * BOOST_CURRENT_FUNCTION = "void test_debug_handler()";
|
||||||
BOOST_TEST_EQ( v7, w7 );
|
BOOST_TEST_EQ( v7, w7 );
|
@@ -13,6 +13,21 @@
|
|||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
// Each backslash in __FILE__ when passed through BOOST_STRINGIZE is doubled
|
||||||
|
static std::string quote( std::string const & s )
|
||||||
|
{
|
||||||
|
std::string r;
|
||||||
|
r.reserve( s.size() );
|
||||||
|
|
||||||
|
for( char const * p = s.c_str(); *p; ++p )
|
||||||
|
{
|
||||||
|
r += *p;
|
||||||
|
if( *p == '\\' ) r += *p;
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
// default case, !NDEBUG
|
// default case, !NDEBUG
|
||||||
// BOOST_ASSERT_MSG(x,"m") -> assert((x)&&("m"))
|
// BOOST_ASSERT_MSG(x,"m") -> assert((x)&&("m"))
|
||||||
|
|
||||||
@@ -80,7 +95,7 @@ void test_disabled_ndebug()
|
|||||||
|
|
||||||
void test_handler()
|
void test_handler()
|
||||||
{
|
{
|
||||||
std::string v5 = BOOST_STRINGIZE(BOOST_ASSERT_MSG(x5, "m5")); std::string w5 = "(BOOST_LIKELY(!!(x5))? ((void)0): ::boost::assertion_failed_msg(\"x5\", \"m5\", BOOST_CURRENT_FUNCTION, \"" __FILE__ "\", " BOOST_STRINGIZE(__LINE__) "))";
|
std::string v5 = BOOST_STRINGIZE(BOOST_ASSERT_MSG(x5, "m5")); std::string w5 = "(BOOST_LIKELY(!!(x5))? ((void)0): ::boost::assertion_failed_msg(\"x5\", \"m5\", BOOST_CURRENT_FUNCTION, \"" + quote( __FILE__ ) + "\", " BOOST_STRINGIZE(__LINE__) "))";
|
||||||
|
|
||||||
char const * BOOST_CURRENT_FUNCTION = "void test_handler()";
|
char const * BOOST_CURRENT_FUNCTION = "void test_handler()";
|
||||||
BOOST_TEST_EQ( v5, w5 );
|
BOOST_TEST_EQ( v5, w5 );
|
||||||
@@ -94,7 +109,7 @@ void test_handler()
|
|||||||
|
|
||||||
void test_handler_ndebug()
|
void test_handler_ndebug()
|
||||||
{
|
{
|
||||||
std::string v6 = BOOST_STRINGIZE(BOOST_ASSERT_MSG(x6, "m6")); std::string w6 = "(BOOST_LIKELY(!!(x6))? ((void)0): ::boost::assertion_failed_msg(\"x6\", \"m6\", BOOST_CURRENT_FUNCTION, \"" __FILE__ "\", " BOOST_STRINGIZE(__LINE__) "))";
|
std::string v6 = BOOST_STRINGIZE(BOOST_ASSERT_MSG(x6, "m6")); std::string w6 = "(BOOST_LIKELY(!!(x6))? ((void)0): ::boost::assertion_failed_msg(\"x6\", \"m6\", BOOST_CURRENT_FUNCTION, \"" + quote( __FILE__ ) + "\", " BOOST_STRINGIZE(__LINE__) "))";
|
||||||
|
|
||||||
char const * BOOST_CURRENT_FUNCTION = "void test_handler_ndebug()";
|
char const * BOOST_CURRENT_FUNCTION = "void test_handler_ndebug()";
|
||||||
BOOST_TEST_EQ( v6, w6 );
|
BOOST_TEST_EQ( v6, w6 );
|
||||||
@@ -112,7 +127,7 @@ void test_handler_ndebug()
|
|||||||
|
|
||||||
void test_debug_handler()
|
void test_debug_handler()
|
||||||
{
|
{
|
||||||
std::string v7 = BOOST_STRINGIZE(BOOST_ASSERT_MSG(x7, "m7")); std::string w7 = "(BOOST_LIKELY(!!(x7))? ((void)0): ::boost::assertion_failed_msg(\"x7\", \"m7\", BOOST_CURRENT_FUNCTION, \"" __FILE__ "\", " BOOST_STRINGIZE(__LINE__) "))";
|
std::string v7 = BOOST_STRINGIZE(BOOST_ASSERT_MSG(x7, "m7")); std::string w7 = "(BOOST_LIKELY(!!(x7))? ((void)0): ::boost::assertion_failed_msg(\"x7\", \"m7\", BOOST_CURRENT_FUNCTION, \"" + quote( __FILE__ ) + "\", " BOOST_STRINGIZE(__LINE__) "))";
|
||||||
|
|
||||||
char const * BOOST_CURRENT_FUNCTION = "void test_debug_handler()";
|
char const * BOOST_CURRENT_FUNCTION = "void test_debug_handler()";
|
||||||
BOOST_TEST_EQ( v7, w7 );
|
BOOST_TEST_EQ( v7, w7 );
|
Reference in New Issue
Block a user