summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/spirit/classic/test/post_skips.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/boost/libs/spirit/classic/test/post_skips.cpp
parentInitial commit. (diff)
downloadceph-upstream.tar.xz
ceph-upstream.zip
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/spirit/classic/test/post_skips.cpp')
-rw-r--r--src/boost/libs/spirit/classic/test/post_skips.cpp113
1 files changed, 113 insertions, 0 deletions
diff --git a/src/boost/libs/spirit/classic/test/post_skips.cpp b/src/boost/libs/spirit/classic/test/post_skips.cpp
new file mode 100644
index 00000000..97b8aba1
--- /dev/null
+++ b/src/boost/libs/spirit/classic/test/post_skips.cpp
@@ -0,0 +1,113 @@
+/*=============================================================================
+ Copyright (c) 2004 Joao Abecasis
+ http://spirit.sourceforge.net/
+
+ Use, modification and distribution is subject to the Boost Software
+ License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+=============================================================================*/
+
+#include <boost/spirit/include/classic_parser.hpp>
+#include <boost/spirit/include/classic_skipper.hpp>
+#include <boost/spirit/include/classic_primitives.hpp>
+#include <boost/spirit/include/classic_optional.hpp>
+#include <boost/spirit/include/classic_sequence.hpp>
+#include <boost/spirit/include/classic_ast.hpp>
+#include <boost/spirit/include/classic_parse_tree.hpp>
+
+#include <boost/detail/lightweight_test.hpp>
+
+using namespace BOOST_SPIRIT_CLASSIC_NS;
+
+char const * test1 = " 12345 ";
+char const * test2 = " 12345 x";
+
+void parse_tests()
+{
+ parse_info<> info;
+
+ // Warming up...
+ info = parse(test1, str_p("12345"));
+ BOOST_TEST(!info.hit);
+
+ // No post-skips!
+ info = parse(test1, str_p("12345"), blank_p);
+ BOOST_TEST(info.hit);
+ BOOST_TEST(!info.full);
+
+ // Require a full match
+ info = parse(test1, str_p("12345") >> end_p, blank_p);
+ BOOST_TEST(info.full);
+ info = parse(test2, str_p("12345") >> end_p, blank_p);
+ BOOST_TEST(!info.hit);
+
+ // Check for a full match but don't make it a requirement
+ info = parse(test1, str_p("12345") >> !end_p, blank_p);
+ BOOST_TEST(info.full);
+ info = parse(test2, str_p("12345") >> !end_p, blank_p);
+ BOOST_TEST(info.hit);
+ BOOST_TEST(!info.full);
+}
+
+void ast_parse_tests()
+{
+ tree_parse_info<> info;
+
+ // Warming up...
+ info = ast_parse(test1, str_p("12345"));
+ BOOST_TEST(!info.match);
+
+ // No post-skips!
+ info = ast_parse(test1, str_p("12345"), blank_p);
+ BOOST_TEST(info.match);
+ BOOST_TEST(!info.full);
+
+ // Require a full match
+ info = ast_parse(test1, str_p("12345") >> end_p, blank_p);
+ BOOST_TEST(info.full);
+ info = ast_parse(test2, str_p("12345") >> end_p, blank_p);
+ BOOST_TEST(!info.match);
+
+ // Check for a full match but don't make it a requirement
+ info = ast_parse(test1, str_p("12345") >> !end_p, blank_p);
+ BOOST_TEST(info.full);
+ info = ast_parse(test2, str_p("12345") >> !end_p, blank_p);
+ BOOST_TEST(info.match);
+ BOOST_TEST(!info.full);
+}
+
+void pt_parse_tests()
+{
+ tree_parse_info<> info;
+
+ // Warming up...
+ info = pt_parse(test1, str_p("12345"));
+ BOOST_TEST(!info.match);
+
+ // No post-skips!
+ info = pt_parse(test1, str_p("12345"), blank_p);
+ BOOST_TEST(info.match);
+ BOOST_TEST(!info.full);
+
+ // Require a full match
+ info = pt_parse(test1, str_p("12345") >> end_p, blank_p);
+ BOOST_TEST(info.full);
+ info = pt_parse(test2, str_p("12345") >> end_p, blank_p);
+ BOOST_TEST(!info.match);
+
+ // Check for a full match but don't make it a requirement
+ info = pt_parse(test1, str_p("12345") >> !end_p, blank_p);
+ BOOST_TEST(info.full);
+ info = pt_parse(test2, str_p("12345") >> !end_p, blank_p);
+ BOOST_TEST(info.match);
+ BOOST_TEST(!info.full);
+}
+
+int main()
+{
+ parse_tests();
+ ast_parse_tests();
+ pt_parse_tests();
+
+ return boost::report_errors();
+}