if_.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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/if_.hpp>
  6. #include <boost/metaparse/digit.hpp>
  7. #include <boost/metaparse/start.hpp>
  8. #include <boost/metaparse/get_result.hpp>
  9. #include "common.hpp"
  10. #include <boost/mpl/equal_to.hpp>
  11. #include <boost/mpl/apply_wrap.hpp>
  12. #include <boost/mpl/assert.hpp>
  13. #include "test_case.hpp"
  14. BOOST_METAPARSE_TEST_CASE(if)
  15. {
  16. using boost::metaparse::get_result;
  17. using boost::metaparse::if_;
  18. using boost::metaparse::digit;
  19. using boost::metaparse::start;
  20. using boost::mpl::equal_to;
  21. using boost::mpl::apply_wrap2;
  22. // test_true
  23. BOOST_MPL_ASSERT((
  24. equal_to<
  25. get_result<apply_wrap2<if_<digit, int11, int13>, str_1, start> >::type,
  26. int11
  27. >
  28. ));
  29. // test_false
  30. BOOST_MPL_ASSERT((
  31. equal_to<
  32. get_result<apply_wrap2<if_<digit, int11, int13>, str_a, start> >::type,
  33. int13
  34. >
  35. ));
  36. }