entire_input.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright Abel Sinkovics (abel@sinkovics.hu) 2011.
  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/entire_input.hpp>
  6. #include <boost/metaparse/is_error.hpp>
  7. #include <boost/metaparse/start.hpp>
  8. #include <boost/metaparse/get_result.hpp>
  9. #include <boost/metaparse/one_char.hpp>
  10. #include <boost/metaparse/get_message.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 <boost/type_traits/is_same.hpp>
  16. #include "test_case.hpp"
  17. BOOST_METAPARSE_TEST_CASE(entire_input)
  18. {
  19. using boost::metaparse::get_result;
  20. using boost::metaparse::entire_input;
  21. using boost::metaparse::start;
  22. using boost::metaparse::is_error;
  23. using boost::metaparse::one_char;
  24. using boost::metaparse::get_message;
  25. using boost::mpl::equal_to;
  26. using boost::mpl::apply_wrap2;
  27. using boost::is_same;
  28. typedef entire_input<one_char> ei;
  29. // test_accept_entire_input
  30. BOOST_MPL_ASSERT((
  31. equal_to<get_result<apply_wrap2<ei, str_h, start> >::type, char_h>
  32. ));
  33. // test_reject_non_entire_input
  34. BOOST_MPL_ASSERT((is_error<apply_wrap2<ei, str_hello, start> >));
  35. // test_predefined_error_message
  36. BOOST_MPL_ASSERT((
  37. is_same<
  38. test_failure,
  39. get_message<
  40. apply_wrap2<entire_input<one_char, test_failure>, str_hello, start>
  41. >::type
  42. >
  43. ));
  44. }