unless_error.cpp 959 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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/unless_error.hpp>
  6. #include <boost/metaparse/is_error.hpp>
  7. #include <boost/metaparse/fail.hpp>
  8. #include "common.hpp"
  9. #include <boost/mpl/equal_to.hpp>
  10. #include <boost/mpl/apply_wrap.hpp>
  11. #include <boost/mpl/assert.hpp>
  12. #include "test_case.hpp"
  13. namespace
  14. {
  15. using boost::mpl::apply_wrap2;
  16. using boost::metaparse::fail;
  17. typedef apply_wrap2<fail<int1>, int11, int2> err;
  18. }
  19. BOOST_METAPARSE_TEST_CASE(util_unless_error)
  20. {
  21. using boost::metaparse::is_error;
  22. using boost::metaparse::unless_error;
  23. using boost::mpl::equal_to;
  24. // test_error
  25. BOOST_MPL_ASSERT((is_error<unless_error<err, int13> >));
  26. // test_not_error
  27. BOOST_MPL_ASSERT((equal_to<int13, unless_error<int11, int13>::type>));
  28. }