unit_test_monitor.hpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // (C) Copyright Gennadiy Rozental 2001-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 : defines specific version of execution monitor used to managed
  12. // run unit of test cases. Translates execution exception into error level
  13. // ***************************************************************************
  14. #ifndef BOOST_TEST_UNIT_TEST_MONITOR_HPP_020905GER
  15. #define BOOST_TEST_UNIT_TEST_MONITOR_HPP_020905GER
  16. // Boost.Test
  17. #include <boost/test/execution_monitor.hpp>
  18. #include <boost/test/detail/fwd_decl.hpp>
  19. #include <boost/test/utils/trivial_singleton.hpp>
  20. #include <boost/test/utils/callback.hpp>
  21. #include <boost/test/detail/suppress_warnings.hpp>
  22. //____________________________________________________________________________//
  23. namespace boost {
  24. namespace unit_test {
  25. // ************************************************************************** //
  26. // ************** unit_test_monitor ************** //
  27. // ************************************************************************** //
  28. class BOOST_TEST_DECL unit_test_monitor_t : public singleton<unit_test_monitor_t>, public execution_monitor {
  29. public:
  30. enum error_level {
  31. test_fail = 1,
  32. test_ok = 0,
  33. constructor_error = -1,
  34. unexpected_exception = -2,
  35. os_exception = -3,
  36. os_timeout = -4,
  37. fatal_error = -5, // includes both system and user
  38. destructor_error = -6
  39. };
  40. static bool is_critical_error( error_level e ) { return e <= fatal_error; }
  41. // monitor method
  42. error_level execute_and_translate( test_case const& );
  43. private:
  44. BOOST_TEST_SINGLETON_CONS( unit_test_monitor_t );
  45. };
  46. BOOST_TEST_SINGLETON_INST( unit_test_monitor )
  47. } // namespace unit_test
  48. } // namespace boost
  49. //____________________________________________________________________________//
  50. #include <boost/test/detail/enable_warnings.hpp>
  51. #endif // BOOST_TEST_UNIT_TEST_MONITOR_HPP_020905GER