00001 #ifndef BOOST_DETAIL_LIGHTWEIGHT_TEST_HPP_INCLUDED
00002 #define BOOST_DETAIL_LIGHTWEIGHT_TEST_HPP_INCLUDED
00003
00004
00005
00006 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
00007 # pragma once
00008 #endif
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <sysc/packages/boost/current_function.hpp>
00026 #include <iostream>
00027
00028 namespace boost
00029 {
00030
00031 namespace detail
00032 {
00033
00034 inline int & test_errors()
00035 {
00036 static int x = 0;
00037 return x;
00038 }
00039
00040 inline void test_failed_impl(char const * expr, char const * file, int line, char const * function)
00041 {
00042 std::cerr << file << "(" << line << "): test '" << expr << "' failed in function '" << function << "'" << std::endl;
00043 ++test_errors();
00044 }
00045
00046 inline void error_impl(char const * msg, char const * file, int line, char const * function)
00047 {
00048 std::cerr << file << "(" << line << "): " << msg << " in function '" << function << "'" << std::endl;
00049 ++test_errors();
00050 }
00051
00052 }
00053
00054 inline int report_errors()
00055 {
00056 int errors = detail::test_errors();
00057
00058 if(errors == 0)
00059 {
00060 std::cerr << "No errors detected." << std::endl;
00061 return 0;
00062 }
00063 else
00064 {
00065 std::cerr << errors << " error" << (errors == 1? "": "s") << " detected." << std::endl;
00066 return 1;
00067 }
00068 }
00069
00070 }
00071
00072 #define BOOST_TEST(expr) ((expr)? (void)0: ::boost::detail::test_failed_impl(#expr, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION))
00073 #define BOOST_ERROR(msg) ::boost::detail::error_impl(msg, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION)
00074
00075 #endif // #ifndef BOOST_DETAIL_LIGHTWEIGHT_TEST_HPP_INCLUDED