diff options
Diffstat (limited to 'boost/core/lightweight_test.hpp')
-rw-r--r-- | boost/core/lightweight_test.hpp | 82 |
1 files changed, 80 insertions, 2 deletions
diff --git a/boost/core/lightweight_test.hpp b/boost/core/lightweight_test.hpp index b580dd2fa6..603e905bb5 100644 --- a/boost/core/lightweight_test.hpp +++ b/boost/core/lightweight_test.hpp @@ -19,12 +19,13 @@ // http://www.boost.org/LICENSE_1_0.txt // -#include <iterator> +#include <boost/core/no_exceptions_support.hpp> #include <boost/assert.hpp> #include <boost/current_function.hpp> -#include <boost/core/no_exceptions_support.hpp> #include <iostream> +#include <iterator> #include <cstring> +#include <cstddef> // 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<class T> inline const void* test_output_impl(T volatile* v) { return const_cast<T*>(v); } +#if !defined( BOOST_NO_CXX11_NULLPTR ) +inline const void* test_output_impl(std::nullptr_t v) { return v; } +#endif + template<class T, class U> 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 ) { @@ -147,6 +152,74 @@ template<class T, class U> inline void test_ne_impl( char const * expr1, char co } } +template<class T, class U> inline void test_lt_impl( char const * expr1, char const * expr2, + char const * file, int line, char const * function, T const & t, U const & u ) +{ + if( t < u ) + { + report_errors_remind(); + } + else + { + BOOST_LIGHTWEIGHT_TEST_OSTREAM + << file << "(" << line << "): test '" << expr1 << " < " << expr2 + << "' failed in function '" << function << "': " + << "'" << test_output_impl(t) << "' >= '" << test_output_impl(u) << "'" << std::endl; + ++test_errors(); + } +} + +template<class T, class U> inline void test_le_impl( char const * expr1, char const * expr2, + char const * file, int line, char const * function, T const & t, U const & u ) +{ + if( t <= u ) + { + report_errors_remind(); + } + else + { + BOOST_LIGHTWEIGHT_TEST_OSTREAM + << file << "(" << line << "): test '" << expr1 << " <= " << expr2 + << "' failed in function '" << function << "': " + << "'" << test_output_impl(t) << "' > '" << test_output_impl(u) << "'" << std::endl; + ++test_errors(); + } +} + +template<class T, class U> inline void test_gt_impl( char const * expr1, char const * expr2, + char const * file, int line, char const * function, T const & t, U const & u ) +{ + if( t > u ) + { + report_errors_remind(); + } + else + { + BOOST_LIGHTWEIGHT_TEST_OSTREAM + << file << "(" << line << "): test '" << expr1 << " > " << expr2 + << "' failed in function '" << function << "': " + << "'" << test_output_impl(t) << "' <= '" << test_output_impl(u) << "'" << std::endl; + ++test_errors(); + } +} + +template<class T, class U> inline void test_ge_impl( char const * expr1, char const * expr2, + char const * file, int line, char const * function, T const & t, U const & u ) +{ + if( t >= u ) + { + report_errors_remind(); + } + else + { + BOOST_LIGHTWEIGHT_TEST_OSTREAM + << file << "(" << line << "): test '" << expr1 << " >= " << expr2 + << "' failed in function '" << function << "': " + << "'" << test_output_impl(t) << "' < '" << test_output_impl(u) << "'" << std::endl; + ++test_errors(); + } +} + inline void test_cstr_eq_impl( char const * expr1, char const * expr2, char const * file, int line, char const * function, char const * const t, char const * const u ) { @@ -360,6 +433,11 @@ inline int report_errors() #define BOOST_TEST_EQ(expr1,expr2) ( ::boost::detail::test_eq_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) ) #define BOOST_TEST_NE(expr1,expr2) ( ::boost::detail::test_ne_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) ) +#define BOOST_TEST_LT(expr1,expr2) ( ::boost::detail::test_lt_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) ) +#define BOOST_TEST_LE(expr1,expr2) ( ::boost::detail::test_le_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) ) +#define BOOST_TEST_GT(expr1,expr2) ( ::boost::detail::test_gt_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) ) +#define BOOST_TEST_GE(expr1,expr2) ( ::boost::detail::test_ge_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) ) + #define BOOST_TEST_CSTR_EQ(expr1,expr2) ( ::boost::detail::test_cstr_eq_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) ) #define BOOST_TEST_CSTR_NE(expr1,expr2) ( ::boost::detail::test_cstr_ne_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) ) |