interaction_based.ipp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // (C) Copyright Gennadiy Rozental 2005-2008.
  2. // Use, modification, and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  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: 54633 $
  10. //
  11. // Description : Facilities to perform interaction-based testing
  12. // ***************************************************************************
  13. #ifndef BOOST_TEST_INTERACTION_BASED_IPP_112105GER
  14. #define BOOST_TEST_INTERACTION_BASED_IPP_112105GER
  15. // Boost.Test
  16. #include <boost/test/detail/config.hpp>
  17. #if BOOST_TEST_SUPPORT_INTERACTION_TESTING
  18. // Boost.Test
  19. #include <boost/test/detail/config.hpp>
  20. #include <boost/test/utils/callback.hpp>
  21. #include <boost/test/interaction_based.hpp>
  22. #include <boost/test/mock_object.hpp>
  23. #include <boost/test/framework.hpp> // for setup_error
  24. #include <boost/test/detail/suppress_warnings.hpp>
  25. // STL
  26. #include <stdexcept>
  27. #include <string>
  28. //____________________________________________________________________________//
  29. namespace boost {
  30. namespace itest { // interaction-based testing
  31. // ************************************************************************** //
  32. // ************** manager ************** //
  33. // ************************************************************************** //
  34. manager::manager()
  35. {
  36. instance_ptr( true, this );
  37. }
  38. //____________________________________________________________________________//
  39. manager::~manager()
  40. {
  41. instance_ptr( true );
  42. }
  43. //____________________________________________________________________________//
  44. manager*
  45. manager::instance_ptr( bool reset, manager* new_ptr )
  46. {
  47. static manager dummy( 0 );
  48. static manager* ptr = &dummy;
  49. if( reset ) {
  50. if( new_ptr ) {
  51. BOOST_TEST_SETUP_ASSERT( ptr == &dummy, BOOST_TEST_L( "Can't run two interation based test the same time" ) );
  52. ptr = new_ptr;
  53. }
  54. else
  55. ptr = &dummy;
  56. }
  57. return ptr;
  58. }
  59. } // namespace itest
  60. } // namespace boost
  61. //____________________________________________________________________________//
  62. #include <boost/test/detail/enable_warnings.hpp>
  63. #endif // not ancient compiler
  64. #endif // BOOST_TEST_INTERACTION_BASED_IPP_112105GER