diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index edb9ac7..4993ed9 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -14,8 +14,9 @@ test-suite "assert" [ run assert_test.cpp ] [ run current_function_test.cpp : : : always_show_run_output ] [ run verify_test.cpp ] - [ run assert_exp_test.cpp ] - [ run assert_msg_exp_test.cpp ] - [ run verify_exp_test.cpp ] - [ run verify_msg_exp_test.cpp ] + # expansion tests are in exp/ so that there is a backslash in the path on Windows + [ run exp/assert_exp_test.cpp ] + [ run exp/assert_msg_exp_test.cpp ] + [ run exp/verify_exp_test.cpp ] + [ run exp/verify_msg_exp_test.cpp ] ; diff --git a/test/assert_exp_test.cpp b/test/exp/assert_exp_test.cpp similarity index 85% rename from test/assert_exp_test.cpp rename to test/exp/assert_exp_test.cpp index cf8e3cc..c56cdef 100644 --- a/test/assert_exp_test.cpp +++ b/test/exp/assert_exp_test.cpp @@ -13,6 +13,21 @@ #include #include +// 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 // BOOST_ASSERT(x) -> assert(x) @@ -80,7 +95,7 @@ void test_disabled_ndebug() 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()"; BOOST_TEST_EQ( v5, w5 ); @@ -94,7 +109,7 @@ void test_handler() 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()"; BOOST_TEST_EQ( v6, w6 ); @@ -112,7 +127,7 @@ void test_handler_ndebug() 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()"; BOOST_TEST_EQ( v7, w7 ); diff --git a/test/assert_msg_exp_test.cpp b/test/exp/assert_msg_exp_test.cpp similarity index 88% rename from test/assert_msg_exp_test.cpp rename to test/exp/assert_msg_exp_test.cpp index ad9ab93..faff616 100644 --- a/test/assert_msg_exp_test.cpp +++ b/test/exp/assert_msg_exp_test.cpp @@ -13,6 +13,21 @@ #include #include +// 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 // BOOST_ASSERT_MSG(x,"m") -> assert((x)&&("m")) @@ -80,7 +95,7 @@ void test_disabled_ndebug() 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()"; BOOST_TEST_EQ( v5, w5 ); @@ -94,7 +109,7 @@ void test_handler() 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()"; BOOST_TEST_EQ( v6, w6 ); @@ -112,7 +127,7 @@ void test_handler_ndebug() 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()"; BOOST_TEST_EQ( v7, w7 ); diff --git a/test/verify_exp_test.cpp b/test/exp/verify_exp_test.cpp similarity index 100% rename from test/verify_exp_test.cpp rename to test/exp/verify_exp_test.cpp diff --git a/test/verify_msg_exp_test.cpp b/test/exp/verify_msg_exp_test.cpp similarity index 100% rename from test/verify_msg_exp_test.cpp rename to test/exp/verify_msg_exp_test.cpp