forked from boostorg/core
fix for trac issue #12814, including a new test for the issue
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
#include <boost/current_function.hpp>
|
#include <boost/current_function.hpp>
|
||||||
#include <boost/core/no_exceptions_support.hpp>
|
#include <boost/core/no_exceptions_support.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
// IDE's like Visual Studio perform better if output goes to std::cout or
|
// IDE's like Visual Studio perform better if output goes to std::cout or
|
||||||
// some other stream, so allow user to configure output stream:
|
// some other stream, so allow user to configure output stream:
|
||||||
@@ -118,6 +119,24 @@ template<class T, class U> inline void test_eq_impl( char const * expr1, char co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// overload for const char*
|
||||||
|
inline void test_eq_impl( char const * expr1, char const * expr2,
|
||||||
|
char const * file, int line, char const * function, const char* t, const char* u )
|
||||||
|
{
|
||||||
|
if( std::strcmp(t, u) == 0 )
|
||||||
|
{
|
||||||
|
report_errors_remind();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||||
|
<< file << "(" << line << "): test '" << expr1 << " == " << expr2
|
||||||
|
<< "' failed in function '" << function << "': "
|
||||||
|
<< "'" << t << "' != '" << u << "'" << std::endl;
|
||||||
|
++test_errors();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template<class T, class U> inline void test_ne_impl( char const * expr1, char const * expr2,
|
template<class T, class U> inline void test_ne_impl( char const * expr1, char const * expr2,
|
||||||
char const * file, int line, char const * function, T const & t, U const & u )
|
char const * file, int line, char const * function, T const & t, U const & u )
|
||||||
{
|
{
|
||||||
@@ -135,6 +154,24 @@ template<class T, class U> inline void test_ne_impl( char const * expr1, char co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// overload for const char*
|
||||||
|
inline void test_ne_impl( char const * expr1, char const * expr2,
|
||||||
|
char const * file, int line, char const * function, const char* t, const char* u )
|
||||||
|
{
|
||||||
|
if( std::strcmp(t, u) != 0 )
|
||||||
|
{
|
||||||
|
report_errors_remind();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||||
|
<< file << "(" << line << "): test '" << expr1 << " == " << expr2
|
||||||
|
<< "' failed in function '" << function << "': "
|
||||||
|
<< "'" << t << "' == '" << u << "'" << std::endl;
|
||||||
|
++test_errors();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
# pragma warning(pop)
|
# pragma warning(pop)
|
||||||
#elif defined(__clang__) && defined(__has_warning)
|
#elif defined(__clang__) && defined(__has_warning)
|
||||||
|
@@ -65,10 +65,15 @@ int main()
|
|||||||
BOOST_TEST_EQ( ++x, ++y );
|
BOOST_TEST_EQ( ++x, ++y );
|
||||||
BOOST_TEST_EQ( x++, y++ );
|
BOOST_TEST_EQ( x++, y++ );
|
||||||
|
|
||||||
|
const char* s1 = "abc"; // make sure addresses are different
|
||||||
|
const char* s2 = "abc"; // make sure addresses are different
|
||||||
|
BOOST_TEST_EQ(s1, s2);
|
||||||
|
|
||||||
// BOOST_TEST_NE
|
// BOOST_TEST_NE
|
||||||
|
|
||||||
BOOST_TEST_NE( ++x, y );
|
BOOST_TEST_NE( ++x, y );
|
||||||
BOOST_TEST_NE( &x, &y );
|
BOOST_TEST_NE( &x, &y );
|
||||||
|
BOOST_TEST_NE( "abc", "ABC" );
|
||||||
|
|
||||||
// BOOST_TEST_THROWS
|
// BOOST_TEST_THROWS
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user