except.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright Abel Sinkovics (abel@sinkovics.hu) 2010.
  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. #include <boost/metaparse/except.hpp>
  6. #include <boost/metaparse/one_char.hpp>
  7. #include <boost/metaparse/fail.hpp>
  8. #include <boost/metaparse/is_error.hpp>
  9. #include <boost/metaparse/start.hpp>
  10. #include <boost/metaparse/get_result.hpp>
  11. #include "common.hpp"
  12. #include <boost/mpl/equal_to.hpp>
  13. #include <boost/mpl/apply_wrap.hpp>
  14. #include <boost/mpl/assert.hpp>
  15. #include "test_case.hpp"
  16. BOOST_METAPARSE_TEST_CASE(except)
  17. {
  18. using boost::metaparse::is_error;
  19. using boost::metaparse::except;
  20. using boost::metaparse::one_char;
  21. using boost::metaparse::start;
  22. using boost::metaparse::get_result;
  23. using boost::metaparse::fail;
  24. using boost::mpl::apply_wrap2;
  25. using boost::mpl::equal_to;
  26. // test_with_good
  27. BOOST_MPL_ASSERT((
  28. is_error<
  29. apply_wrap2<except<one_char, int13, test_failure>, str_hello, start>
  30. >
  31. ));
  32. // test_with_bad
  33. BOOST_MPL_ASSERT((
  34. equal_to<
  35. get_result<
  36. apply_wrap2<
  37. except<fail<test_failure>, int13, test_failure>,
  38. str_hello,
  39. start
  40. >
  41. >::type,
  42. int13
  43. >
  44. ));
  45. }