logged_expectations.hpp 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // (C) Copyright Gennadiy Rozental 2005-2008.
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // See http://www.boost.org/libs/test for the library home page.
  6. //
  7. // File : $RCSfile$
  8. //
  9. // Version : $Revision: 49312 $
  10. //
  11. // Description : Facilities to perform interaction based testng of logged expectations
  12. // ***************************************************************************
  13. #ifndef BOOST_TEST_LOGGED_EXPECTATIONS_HPP_120905GER
  14. #define BOOST_TEST_LOGGED_EXPECTATIONS_HPP_120905GER
  15. // Boost.Test
  16. #include <boost/test/detail/config.hpp>
  17. #include <boost/test/detail/unit_test_parameters.hpp>
  18. #include <boost/test/utils/callback.hpp>
  19. #include <boost/test/detail/suppress_warnings.hpp>
  20. //____________________________________________________________________________//
  21. // ************************************************************************** //
  22. // ************** BOOST_TEST_LOGGED_EXPECTATIONS ************** //
  23. // ************************************************************************** //
  24. #define BOOST_TEST_LOGGED_EXPECTATIONS( test_name ) \
  25. struct test_name : public BOOST_AUTO_TEST_CASE_FIXTURE \
  26. { void test_method(); }; \
  27. \
  28. static void BOOST_AUTO_TC_INVOKER( test_name )() \
  29. { \
  30. test_name t; \
  31. ::boost::itest::logged_expectations( \
  32. boost::bind( &test_name::test_method, t ), \
  33. BOOST_STRINGIZE(test_name) ".elog", \
  34. !::boost::unit_test::runtime_config::save_pattern() ); \
  35. } \
  36. \
  37. struct BOOST_AUTO_TC_UNIQUE_ID( test_name ) {}; \
  38. \
  39. BOOST_AUTO_TU_REGISTRAR( test_name )( \
  40. boost::unit_test::make_test_case( \
  41. &BOOST_AUTO_TC_INVOKER( test_name ), #test_name ), \
  42. boost::unit_test::ut_detail::auto_tc_exp_fail< \
  43. BOOST_AUTO_TC_UNIQUE_ID( test_name )>::instance()->value() ); \
  44. \
  45. void test_name::test_method() \
  46. /**/
  47. namespace boost {
  48. namespace itest {
  49. // ************************************************************************** //
  50. // ************** logged expectations test ************** //
  51. // ************************************************************************** //
  52. void BOOST_TEST_DECL
  53. logged_expectations( unit_test::callback0<> const& F,
  54. unit_test::const_string log_file_name,
  55. bool test_or_log = true );
  56. } // namespace itest
  57. } // namespace boost
  58. #include <boost/test/detail/enable_warnings.hpp>
  59. #endif // BOOST_TEST_LOGGED_EXPECTATIONS_HPP_120905GER