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 7 8 9 #include <libs/statechart/test/ThrowingBoostAssert.hpp> 10 #include <boost/statechart/result.hpp> 11 12 #include <boost/test/test_tools.hpp> 13 14 #include <stdexcept> // std::logic_error 15 16 17 18 namespace sc = boost::statechart; 19 20 21 make_unconsumed_result()22void make_unconsumed_result() 23 { 24 // We cannot test sc::result in its natural environment here because a 25 // failing assert triggers a stack unwind, what will lead to another 26 // failing assert... 27 28 // Creates a temp sc::result value which is destroyed immediately 29 sc::detail::result_utility::make_result( sc::detail::do_discard_event ); 30 } 31 32 // TODO: The current test setup lets an exception propagate out of a 33 // destructor. Find a better way to test this. test_main(int,char * [])34int test_main( int, char* [] ) 35 { 36 #ifdef NDEBUG 37 BOOST_REQUIRE_NO_THROW( make_unconsumed_result() ); 38 #else 39 BOOST_REQUIRE_THROW( make_unconsumed_result(), std::logic_error ); 40 #endif 41 42 return 0; 43 } 44