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/karma/pattern4.cpp | 141 ++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 src/boost/libs/spirit/test/karma/pattern4.cpp (limited to 'src/boost/libs/spirit/test/karma/pattern4.cpp') diff --git a/src/boost/libs/spirit/test/karma/pattern4.cpp b/src/boost/libs/spirit/test/karma/pattern4.cpp new file mode 100644 index 00000000..b67939c6 --- /dev/null +++ b/src/boost/libs/spirit/test/karma/pattern4.cpp @@ -0,0 +1,141 @@ +// Copyright (c) 2001-2010 Hartmut Kaiser +// +// 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) + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "test.hpp" + +using namespace spirit_test; + +/////////////////////////////////////////////////////////////////////////////// +int main() +{ + using namespace boost; + using namespace boost::spirit; + using namespace boost::spirit::ascii; + + typedef spirit_test::output_iterator::type outiter_type; + + { + karma::rule start; + fusion::vector vec('a', 10, 12.4); + + start = char_[_1 = _r1] << int_[_1 = _r2] << double_[_1 = _r3]; + BOOST_TEST(test("a1012.4", start('a', 10, 12.4))); + + start = (char_ << int_ << double_)[_1 = _r1, _2 = _r2, _3 = _r3]; + BOOST_TEST(test("a1012.4", start('a', 10, 12.4))); + + karma::rule a; + karma::rule b; + karma::rule c; + + a = char_[_1 = _r1]; + b = int_[_1 = _r1]; + c = double_[_1 = _r1]; + start = a(_r1) << b(_r2) << c(_r3); + BOOST_TEST(test("a1012.4", start('a', 10, 12.4))); + } + + { + karma::rule start; + fusion::vector vec('a', 10, 12.4); + + start = char_[_1 = _r1] << int_[_1 = _r2] << double_[_1 = _r3]; + BOOST_TEST(test_delimited("a 10 12.4 ", start('a', 10, 12.4), space)); + + start = (char_ << int_ << double_)[_1 = _r1, _2 = _r2, _3 = _r3]; + BOOST_TEST(test_delimited("a 10 12.4 ", start('a', 10, 12.4), space)); + + karma::rule a; + karma::rule b; + karma::rule c; + + a = char_[_1 = _r1]; + b = int_[_1 = _r1]; + c = double_[_1 = _r1]; + start = a(_r1) << b(_r2) << c(_r3); + BOOST_TEST(test_delimited("a 10 12.4 ", start('a', 10, 12.4), space)); + } + + // copy tests + { + karma::rule a, b, c, start; + + a = 'a'; + b = int_(10); + c = double_(12.4); + + // The FF is the dynamic equivalent of start = a << b << c; + start = a; + start = start.copy() << b; + start = start.copy() << c; + start = start.copy(); + + BOOST_TEST(test("a1012.4", start)); + } + + { + karma::rule a, b, c, start; + + a = 'a'; + b = int_(10); + c = double_(12.4); + + // The FF is the dynamic equivalent of start = a << b << c; + start = a; + start = start.copy() << b; + start = start.copy() << c; + start = start.copy(); + + BOOST_TEST(test_delimited("a 10 12.4 ", start, space)); + } + + { // specifying the encoding + using karma::lower; + using karma::upper; + using karma::string; + + typedef boost::spirit::char_encoding::iso8859_1 iso8859_1; + karma::rule r; + + r = lower['\xE1']; + BOOST_TEST(test("\xE1", r)); + r = lower[char_('\xC1')]; + BOOST_TEST(test("\xE1", r)); + r = upper['\xE1']; + BOOST_TEST(test("\xC1", r)); + r = upper[char_('\xC1')]; + BOOST_TEST(test("\xC1", r)); + + r = lower["\xE1\xC1"]; + BOOST_TEST(test("\xE1\xE1", r)); + r = lower[lit("\xE1\xC1")]; + BOOST_TEST(test("\xE1\xE1", r)); + r = lower[string("\xE1\xC1")]; + BOOST_TEST(test("\xE1\xE1", r)); + r = upper["\xE1\xC1"]; + BOOST_TEST(test("\xC1\xC1", r)); + r = upper[lit("\xE1\xC1")]; + BOOST_TEST(test("\xC1\xC1", r)); + r = upper[string("\xE1\xC1")]; + BOOST_TEST(test("\xC1\xC1", r)); + } + + return boost::report_errors(); +} + -- cgit v1.2.3