1 #ifndef BOOST_DETAIL_LIGHTWEIGHT_TEST_HPP_INCLUDED
\r
2 #define BOOST_DETAIL_LIGHTWEIGHT_TEST_HPP_INCLUDED
\r
4 // MS compatible compilers support #pragma once
\r
6 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
\r
11 // boost/detail/lightweight_test.hpp - lightweight test library
\r
13 // Copyright (c) 2002, 2009 Peter Dimov
\r
15 // Distributed under the Boost Software License, Version 1.0.
\r
16 // See accompanying file LICENSE_1_0.txt or copy at
\r
17 // http://www.boost.org/LICENSE_1_0.txt
\r
19 // BOOST_TEST(expression)
\r
20 // BOOST_ERROR(message)
\r
21 // BOOST_TEST_EQ(expr1, expr2)
\r
23 // int boost::report_errors()
\r
26 #include <boost/current_function.hpp>
\r
35 inline int & test_errors()
\r
41 inline void test_failed_impl(char const * expr, char const * file, int line, char const * function)
\r
43 std::cerr << file << "(" << line << "): test '" << expr << "' failed in function '" << function << "'" << std::endl;
\r
47 inline void error_impl(char const * msg, char const * file, int line, char const * function)
\r
49 std::cerr << file << "(" << line << "): " << msg << " in function '" << function << "'" << std::endl;
\r
53 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 )
\r
60 std::cerr << file << "(" << line << "): test '" << expr1 << " == " << expr2
\r
61 << "' failed in function '" << function << "': "
\r
62 << "'" << t << "' != '" << u << "'" << std::endl;
\r
67 } // namespace detail
\r
69 inline int report_errors()
\r
71 int errors = detail::test_errors();
\r
75 std::cerr << "No errors detected." << std::endl;
\r
80 std::cerr << errors << " error" << (errors == 1? "": "s") << " detected." << std::endl;
\r
85 } // namespace boost
\r
87 #define BOOST_TEST(expr) ((expr)? (void)0: ::boost::detail::test_failed_impl(#expr, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION))
\r
88 #define BOOST_ERROR(msg) ::boost::detail::error_impl(msg, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION)
\r
89 #define BOOST_TEST_EQ(expr1,expr2) ( ::boost::detail::test_eq_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
\r
91 #endif // #ifndef BOOST_DETAIL_LIGHTWEIGHT_TEST_HPP_INCLUDED
\r