InvalidResultAssignTest.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. #include <boost/statechart/state_machine.hpp>
  7. #include <boost/statechart/event.hpp>
  8. #include <boost/statechart/simple_state.hpp>
  9. #include <boost/statechart/custom_reaction.hpp>
  10. #include <boost/statechart/result.hpp>
  11. #include <boost/static_assert.hpp>
  12. namespace sc = boost::statechart;
  13. struct E : sc::event< E > {};
  14. struct A;
  15. struct InvalidResultAssignTest :
  16. sc::state_machine< InvalidResultAssignTest, A > {};
  17. struct A : sc::simple_state< A, InvalidResultAssignTest >
  18. {
  19. typedef sc::custom_reaction< E > reactions;
  20. sc::result react( const E & )
  21. {
  22. sc::result r( discard_event() );
  23. // sc::result must not be assignmable
  24. r = discard_event();
  25. return r;
  26. }
  27. };
  28. int main()
  29. {
  30. InvalidResultAssignTest machine;
  31. machine.initiate();
  32. #ifdef NDEBUG
  33. // Test only fails in DEBUG mode. Forcing failure...
  34. BOOST_STATIC_ASSERT( false );
  35. #endif
  36. return 0;
  37. }