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/qi/lit1.cpp | 96 ++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 src/boost/libs/spirit/test/qi/lit1.cpp (limited to 'src/boost/libs/spirit/test/qi/lit1.cpp') diff --git a/src/boost/libs/spirit/test/qi/lit1.cpp b/src/boost/libs/spirit/test/qi/lit1.cpp new file mode 100644 index 00000000..6f8eaf08 --- /dev/null +++ b/src/boost/libs/spirit/test/qi/lit1.cpp @@ -0,0 +1,96 @@ +/*============================================================================= + Copyright (c) 2001-2011 Joel de Guzman + http://spirit.sourceforge.net/ + + 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 "test.hpp" + +int +main() +{ + using spirit_test::test; + using spirit_test::test_attr; + using boost::spirit::qi::string; + using boost::spirit::qi::_1; + + { + BOOST_TEST((test("kimpo", "kimpo"))); + BOOST_TEST((test("kimpo", string("kimpo")))); + + BOOST_TEST((test("x", string("x")))); + BOOST_TEST((test(L"x", string(L"x")))); + + std::basic_string s("kimpo"); + std::basic_string ws(L"kimpo"); + BOOST_TEST((test("kimpo", s))); + BOOST_TEST((test(L"kimpo", ws))); + BOOST_TEST((test("kimpo", string(s)))); + BOOST_TEST((test(L"kimpo", string(ws)))); + } + + { + BOOST_TEST((test(L"kimpo", L"kimpo"))); + BOOST_TEST((test(L"kimpo", string(L"kimpo")))); + BOOST_TEST((test(L"x", string(L"x")))); + } + + { + std::basic_string s("kimpo"); + BOOST_TEST((test("kimpo", string(s)))); + + std::basic_string ws(L"kimpo"); + BOOST_TEST((test(L"kimpo", string(ws)))); + } + + { + using namespace boost::spirit::ascii; + BOOST_TEST((test(" kimpo", string("kimpo"), space))); + BOOST_TEST((test(L" kimpo", string(L"kimpo"), space))); + BOOST_TEST((test(" x", string("x"), space))); + } + + { + using namespace boost::spirit::ascii; + BOOST_TEST((test(" kimpo", string("kimpo"), space))); + BOOST_TEST((test(L" kimpo", string(L"kimpo"), space))); + BOOST_TEST((test(" x", string("x"), space))); + } + + { + using namespace boost::spirit::ascii; + std::string s; + BOOST_TEST((test_attr("kimpo", string("kimpo"), s))); + BOOST_TEST(s == "kimpo"); + s.clear(); + BOOST_TEST((test_attr(L"kimpo", string(L"kimpo"), s))); + BOOST_TEST(s == "kimpo"); + s.clear(); + BOOST_TEST((test_attr("x", string("x"), s))); + BOOST_TEST(s == "x"); + } + + { // lazy string + + using namespace boost::spirit::ascii; + namespace phx = boost::phoenix; + + BOOST_TEST((test("x", string(phx::val("x"))))); + + std::string str; // make sure lazy lits have an attribute + BOOST_TEST(test("x", string(phx::val("x"))[phx::ref(str) = _1])); + BOOST_TEST(str == "x"); + } + + return boost::report_errors(); +} -- cgit v1.2.3