always_c.cpp 1010 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright Abel Sinkovics (abel@sinkovics.hu) 2013.
  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/always_c.hpp>
  6. #include <boost/metaparse/is_error.hpp>
  7. #include <boost/metaparse/start.hpp>
  8. #include <boost/metaparse/get_result.hpp>
  9. #include "common.hpp"
  10. #include <boost/mpl/apply_wrap.hpp>
  11. #include <boost/mpl/assert.hpp>
  12. #include "test_case.hpp"
  13. BOOST_METAPARSE_TEST_CASE(always_c)
  14. {
  15. using boost::metaparse::get_result;
  16. using boost::metaparse::always_c;
  17. using boost::metaparse::start;
  18. using boost::metaparse::is_error;
  19. using boost::mpl::equal_to;
  20. using boost::mpl::apply_wrap2;
  21. // test_result
  22. BOOST_MPL_ASSERT((
  23. equal_to<
  24. get_result<apply_wrap2<always_c<'1', int13>, str_1, start> >::type,
  25. int13
  26. >
  27. ));
  28. // test_fail
  29. BOOST_MPL_ASSERT((
  30. is_error<apply_wrap2<always_c<'1', int13>, str_a, start> >
  31. ));
  32. }