confix_tests.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*=============================================================================
  2. Copyright (c) 2003 2003 Vaclav Vesely
  3. http://spirit.sourceforge.net/
  4. Use, modification and distribution is subject to the Boost Software
  5. License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. =============================================================================*/
  8. #include <boost/spirit/include/classic_core.hpp>
  9. #include <boost/spirit/include/classic_confix.hpp>
  10. #include <boost/detail/lightweight_test.hpp>
  11. using namespace boost;
  12. using namespace BOOST_SPIRIT_CLASSIC_NS;
  13. typedef
  14. scanner<char const*, scanner_policies<skipper_iteration_policy<> > >
  15. scanner_t;
  16. typedef
  17. rule<scanner_t>
  18. rule_t;
  19. void comment_nest_p_test()
  20. {
  21. rule_t r = comment_nest_p('{', '}');
  22. {
  23. parse_info<> info = parse("{a{b}c{d}e}", r, space_p);
  24. BOOST_TEST(info.full);
  25. }
  26. {
  27. parse_info<> info = parse("{a{b}c{d}e}x", r, space_p);
  28. BOOST_TEST(info.hit);
  29. BOOST_TEST(info.length == 11);
  30. }
  31. {
  32. char const* str = "x{a{b}c{d}e}";
  33. parse_info<> info = parse(str, r, space_p);
  34. BOOST_TEST(!info.hit);
  35. BOOST_TEST(info.stop == str);
  36. }
  37. {
  38. char const* str = "{a{b}c{d}e";
  39. parse_info<> info = parse(str, r, space_p);
  40. BOOST_TEST(!info.hit);
  41. BOOST_TEST(info.stop == (str + 10));
  42. }
  43. }
  44. int
  45. main()
  46. {
  47. comment_nest_p_test();
  48. return boost::report_errors();
  49. }