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