eps.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*=============================================================================
  2. Copyright (c) 2001-2015 Joel de Guzman
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. =============================================================================*/
  6. #include <boost/detail/lightweight_test.hpp>
  7. #include <boost/spirit/home/x3.hpp>
  8. #include <iostream>
  9. #include "test.hpp"
  10. int
  11. main()
  12. {
  13. using spirit_test::test;
  14. using boost::spirit::x3::eps;
  15. using boost::spirit::x3::unused_type;
  16. {
  17. BOOST_TEST((test("", eps)));
  18. BOOST_TEST((test("xxx", eps, false)));
  19. //~ BOOST_TEST((!test("", !eps))); // not predicate $$$ Implement me! $$$
  20. }
  21. { // test non-lazy semantic predicate
  22. BOOST_TEST((test("", eps(true))));
  23. BOOST_TEST((!test("", eps(false))));
  24. BOOST_TEST((test("", !eps(false))));
  25. }
  26. { // test lazy semantic predicate
  27. auto true_ = [](unused_type) { return true; };
  28. auto false_ = [](unused_type) { return false; };
  29. BOOST_TEST((test("", eps(true_))));
  30. BOOST_TEST((!test("", eps(false_))));
  31. BOOST_TEST((test("", !eps(false_))));
  32. }
  33. return boost::report_errors();
  34. }