epoc32/include/stdapis/boost/detail/lightweight_test.hpp
branchSymbian2
changeset 2 2fe1408b6811
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/boost/detail/lightweight_test.hpp	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,75 @@
     1.4 +#ifndef BOOST_DETAIL_LIGHTWEIGHT_TEST_HPP_INCLUDED
     1.5 +#define BOOST_DETAIL_LIGHTWEIGHT_TEST_HPP_INCLUDED
     1.6 +
     1.7 +// MS compatible compilers support #pragma once
     1.8 +
     1.9 +#if defined(_MSC_VER) && (_MSC_VER >= 1020)
    1.10 +# pragma once
    1.11 +#endif
    1.12 +
    1.13 +//
    1.14 +//  boost/detail/lightweight_test.hpp - lightweight test library
    1.15 +//
    1.16 +//  Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
    1.17 +//
    1.18 +// Distributed under the Boost Software License, Version 1.0. (See
    1.19 +// accompanying file LICENSE_1_0.txt or copy at
    1.20 +// http://www.boost.org/LICENSE_1_0.txt)
    1.21 +//
    1.22 +//  BOOST_TEST(expression)
    1.23 +//  BOOST_ERROR(message)
    1.24 +//
    1.25 +//  int boost::report_errors()
    1.26 +//
    1.27 +
    1.28 +#include <boost/current_function.hpp>
    1.29 +#include <iostream>
    1.30 +
    1.31 +namespace boost
    1.32 +{
    1.33 +
    1.34 +namespace detail
    1.35 +{
    1.36 +
    1.37 +inline int & test_errors()
    1.38 +{
    1.39 +    static int x = 0;
    1.40 +    return x;
    1.41 +}
    1.42 +
    1.43 +inline void test_failed_impl(char const * expr, char const * file, int line, char const * function)
    1.44 +{
    1.45 +    std::cerr << file << "(" << line << "): test '" << expr << "' failed in function '" << function << "'" << std::endl;
    1.46 +    ++test_errors();
    1.47 +}
    1.48 +
    1.49 +inline void error_impl(char const * msg, char const * file, int line, char const * function)
    1.50 +{
    1.51 +    std::cerr << file << "(" << line << "): " << msg << " in function '" << function << "'" << std::endl;
    1.52 +    ++test_errors();
    1.53 +}
    1.54 +
    1.55 +} // namespace detail
    1.56 +
    1.57 +inline int report_errors()
    1.58 +{
    1.59 +    int errors = detail::test_errors();
    1.60 +
    1.61 +    if(errors == 0)
    1.62 +    {
    1.63 +        std::cerr << "No errors detected." << std::endl;
    1.64 +        return 0;
    1.65 +    }
    1.66 +    else
    1.67 +    {
    1.68 +        std::cerr << errors << " error" << (errors == 1? "": "s") << " detected." << std::endl;
    1.69 +        return 1;
    1.70 +    }
    1.71 +}
    1.72 +
    1.73 +} // namespace boost
    1.74 +
    1.75 +#define BOOST_TEST(expr) ((expr)? (void)0: ::boost::detail::test_failed_impl(#expr, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION))
    1.76 +#define BOOST_ERROR(msg) ::boost::detail::error_impl(msg, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION)
    1.77 +
    1.78 +#endif // #ifndef BOOST_DETAIL_LIGHTWEIGHT_TEST_HPP_INCLUDED