From 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 20:24:20 +0200 Subject: Adding upstream version 14.2.21. Signed-off-by: Daniel Baumann --- src/boost/libs/spirit/test/x3/test.hpp | 125 +++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 src/boost/libs/spirit/test/x3/test.hpp (limited to 'src/boost/libs/spirit/test/x3/test.hpp') diff --git a/src/boost/libs/spirit/test/x3/test.hpp b/src/boost/libs/spirit/test/x3/test.hpp new file mode 100644 index 00000000..af1c22ee --- /dev/null +++ b/src/boost/libs/spirit/test/x3/test.hpp @@ -0,0 +1,125 @@ +/*============================================================================= + Copyright (c) 2001-2013 Joel de Guzman + + Distributed under 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) +=============================================================================*/ +#if !defined(BOOST_SPIRIT_TEST_FEBRUARY_01_2007_0605PM) +#define BOOST_SPIRIT_TEST_FEBRUARY_01_2007_0605PM + +#include +#include +#include + +namespace spirit_test +{ + template + bool test(Char const* in, Parser const& p, bool full_match = true) + { + Char const* last = in; + while (*last) + last++; + return boost::spirit::x3::parse(in, last, p) + && (!full_match || (in == last)); + } + + template + bool test(boost::basic_string_view> in, + Parser const& p, bool full_match = true) + { + auto const last = in.end(); + auto pos = in.begin(); + + return boost::spirit::x3::parse(pos, last, p) && (!full_match || (pos == last)); + } + + template + bool test(Char const* in, Parser const& p + , Skipper const& s, bool full_match = true) + { + Char const* last = in; + while (*last) + last++; + return boost::spirit::x3::phrase_parse(in, last, p, s) + && (!full_match || (in == last)); + } + + template + bool test_failure(Char const* in, Parser const& p) + { + Char const * const start = in; + Char const* last = in; + while (*last) + last++; + + return !boost::spirit::x3::parse(in, last, p) && (in == start); + } + + template + bool test_failure(boost::basic_string_view> const in, + Parser const& p) + { + auto pos = in.begin(); + return !boost::spirit::x3::parse(pos, in.end(), p) && (pos == in.begin()); + } + + template + bool test_attr(Char const* in, Parser const& p + , Attr& attr, bool full_match = true) + { + Char const* last = in; + while (*last) + last++; + return boost::spirit::x3::parse(in, last, p, attr) + && (!full_match || (in == last)); + } + + template + bool test_attr(Char const* in, Parser const& p + , Attr& attr, Skipper const& s, bool full_match = true) + { + Char const* last = in; + while (*last) + last++; + return boost::spirit::x3::phrase_parse(in, last, p, s, attr) + && (!full_match || (in == last)); + } + + template + bool binary_test(Char const* in, std::size_t size, Parser const& p, + bool full_match = true) + { + Char const* last = in + size; + return boost::spirit::x3::parse(in, last, p) + && (!full_match || (in == last)); + } + + template + bool binary_test(Char const* in, std::size_t size, Parser const& p, + Skipper const& s, bool full_match = true) + { + Char const* last = in + size; + return boost::spirit::x3::phrase_parse(in, last, p, s) + && (!full_match || (in == last)); + } + + template + bool binary_test_attr(Char const* in, std::size_t size, Parser const& p, + Attr& attr, bool full_match = true) + { + Char const* last = in + size; + return boost::spirit::x3::parse(in, last, p, attr) + && (!full_match || (in == last)); + } + + template + bool binary_test_attr(Char const* in, std::size_t size, Parser const& p, + Attr& attr, Skipper const& s, bool full_match = true) + { + Char const* last = in + size; + return boost::spirit::x3::phrase_parse(in, last, p, s, attr) + && (!full_match || (in == last)); + } +} + +#endif -- cgit v1.2.3