UnconsumedResultTest.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //////////////////////////////////////////////////////////////////////////////
  2. // Copyright 2005-2006 Andreas Huber Doenni
  3. // Distributed under the Boost Software License, Version 1.0. (See accompany-
  4. // ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. //////////////////////////////////////////////////////////////////////////////
  6. #define BOOST_ENABLE_ASSERT_HANDLER
  7. static int s_failed_assertions = 0;
  8. namespace boost
  9. {
  10. void assertion_failed(
  11. char const *, char const *, char const *, long )
  12. {
  13. ++s_failed_assertions;
  14. }
  15. } // namespace boost
  16. #include <boost/statechart/result.hpp>
  17. #include <boost/test/test_tools.hpp>
  18. namespace sc = boost::statechart;
  19. void make_unconsumed_result()
  20. {
  21. // We cannot test sc::result in its natural environment here because a
  22. // failing assert triggers a stack unwind, what will lead to another
  23. // failing assert...
  24. // Creates a temp sc::result value which is destroyed immediately
  25. sc::detail::result_utility::make_result( sc::detail::do_discard_event );
  26. }
  27. int test_main( int, char* [] )
  28. {
  29. make_unconsumed_result();
  30. #ifdef NDEBUG
  31. BOOST_TEST( s_failed_assertions == 0 );
  32. #else
  33. BOOST_TEST( s_failed_assertions == 1 );
  34. #endif
  35. return 0;
  36. }