at_c.cpp 913 B

1234567891011121314151617181920212223242526272829303132333435
  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/v1/impl/at_c.hpp>
  6. #include <boost/metaparse/string.hpp>
  7. #include <boost/mpl/equal_to.hpp>
  8. #include <boost/mpl/char.hpp>
  9. #include <boost/mpl/assert.hpp>
  10. #include "test_case.hpp"
  11. BOOST_METAPARSE_TEST_CASE(at_c)
  12. {
  13. using boost::metaparse::v1::impl::at_c;
  14. using boost::metaparse::string;
  15. using boost::mpl::equal_to;
  16. using boost::mpl::char_;
  17. typedef string<'h','e','l','l','o'> hello;
  18. // test_first_char
  19. BOOST_MPL_ASSERT((equal_to<char_<'h'>, at_c<hello, 0>::type>));
  20. // test_middle_char
  21. BOOST_MPL_ASSERT((equal_to<char_<'l'>, at_c<hello, 2>::type>));
  22. // test_last_char
  23. BOOST_MPL_ASSERT((equal_to<char_<'o'>, at_c<hello, 4>::type>));
  24. }