diff --git a/include/boost/core/lightweight_test.hpp b/include/boost/core/lightweight_test.hpp index 260a1ac..fc8ea74 100644 --- a/include/boost/core/lightweight_test.hpp +++ b/include/boost/core/lightweight_test.hpp @@ -25,6 +25,7 @@ #include #include #include +#include // IDE's like Visual Studio perform better if output goes to std::cout or // some other stream, so allow user to configure output stream: @@ -113,6 +114,10 @@ inline const void* test_output_impl(unsigned char* v) { return v; } inline const void* test_output_impl(signed char* v) { return v; } template inline const void* test_output_impl(T volatile* v) { return const_cast(v); } +#if !defined( BOOST_NO_CXX11_NULLPTR ) +inline const void* test_output_impl(std::nullptr_t v) { return v; } +#endif + template inline void test_eq_impl( char const * expr1, char const * expr2, char const * file, int line, char const * function, T const & t, U const & u ) { diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 5e0e5d3..8b1c9b7 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -71,6 +71,8 @@ run lightweight_test_all_with_test.cpp ; run lightweight_test_all_with_fail.cpp ; run lightweight_test_lt_le_test.cpp ; +run lightweight_test_eq_nullptr.cpp ; + run-fail lightweight_test_fail.cpp ; run-fail lightweight_test_fail2.cpp ; run-fail lightweight_test_fail3.cpp ; diff --git a/test/lightweight_test_eq_nullptr.cpp b/test/lightweight_test_eq_nullptr.cpp new file mode 100644 index 0000000..519d4d8 --- /dev/null +++ b/test/lightweight_test_eq_nullptr.cpp @@ -0,0 +1,28 @@ +// +// Test BOOST_TEST_EQ( p, nullptr ) +// +// Copyright 2017 Peter Dimov +// +// 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 +// + +#include +#include + +int main() +{ +#if !defined( BOOST_NO_CXX11_NULLPTR ) + + int x = 0; + int* p1 = 0; + int* p2 = &x; + + BOOST_TEST_EQ( p1, nullptr ); + BOOST_TEST_NE( p2, nullptr ); + +#endif + + return boost::report_errors(); +}