fail_at_first_char_expected.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright Abel Sinkovics (abel@sinkovics.hu) 2015.
  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/fail_at_first_char_expected.hpp>
  6. #include <boost/metaparse/is_error.hpp>
  7. #include <boost/metaparse/start.hpp>
  8. #include <boost/metaparse/keyword.hpp>
  9. #include <boost/mpl/assert.hpp>
  10. #include "common.hpp"
  11. #include "test_case.hpp"
  12. BOOST_METAPARSE_TEST_CASE(fail_at_first_char_expected)
  13. {
  14. using boost::metaparse::fail_at_first_char_expected;
  15. using boost::metaparse::is_error;
  16. using boost::metaparse::start;
  17. typedef boost::metaparse::keyword<str_hello> accept_hello;
  18. // test_failure_at_first_char_is_ignored
  19. BOOST_MPL_ASSERT_NOT((
  20. is_error<fail_at_first_char_expected<accept_hello>::apply<str_ab, start> >
  21. ));
  22. // test_no_failure_is_error
  23. BOOST_MPL_ASSERT((
  24. is_error<
  25. fail_at_first_char_expected<accept_hello>::apply<str_hello, start>
  26. >
  27. ));
  28. // test_failure_at_second_char_is_not_ignored
  29. BOOST_MPL_ASSERT((
  30. is_error< fail_at_first_char_expected<accept_hello>::apply<str_h, start> >
  31. ));
  32. }