diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
commit | 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch) | |
tree | e5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/boost/libs/spirit/test/karma/char3.cpp | |
parent | Initial commit. (diff) | |
download | ceph-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/test/karma/char3.cpp')
-rw-r--r-- | src/boost/libs/spirit/test/karma/char3.cpp | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/src/boost/libs/spirit/test/karma/char3.cpp b/src/boost/libs/spirit/test/karma/char3.cpp new file mode 100644 index 00000000..55e5978b --- /dev/null +++ b/src/boost/libs/spirit/test/karma/char3.cpp @@ -0,0 +1,103 @@ +// Copyright (c) 2001-2011 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 <boost/config/warning_disable.hpp> +#include <boost/detail/lightweight_test.hpp> + +#include <boost/spirit/include/karma_char.hpp> +#include <boost/spirit/include/karma_generate.hpp> +#include <boost/spirit/include/karma_action.hpp> +#include <boost/spirit/include/karma_phoenix_attributes.hpp> + +#include <boost/spirit/include/phoenix_core.hpp> +#include <boost/spirit/include/phoenix_operator.hpp> +#include <boost/spirit/include/phoenix_statement.hpp> + +#include "test.hpp" + +using namespace spirit_test; + +/////////////////////////////////////////////////////////////////////////////// +int +main() +{ + using namespace boost::spirit; + using namespace boost::phoenix; + using boost::spirit::karma::lit; + + { + BOOST_TEST(test("x", lit('x'))); + BOOST_TEST(!test("x", lit('y'))); + + BOOST_TEST(test("x", lit('x'), 'x')); + BOOST_TEST(!test("", lit('y'), 'x')); + +// BOOST_TEST(test("a", lit('a', 'z'), 'a')); +// BOOST_TEST(test("b", lit('a', 'z'), 'b')); +// BOOST_TEST(!test("", lit('a', 'z'), 'A')); + + BOOST_TEST(!test("", ~lit('x'))); + + BOOST_TEST(!test("", ~lit('x'), 'x')); + BOOST_TEST(test("x", ~lit('y'), 'x')); + +// BOOST_TEST(!test("", ~lit('a', 'z'), 'a')); +// BOOST_TEST(!test("", ~lit('a', 'z'), 'b')); +// BOOST_TEST(test("A", ~lit('a', 'z'), 'A')); + + BOOST_TEST(test("x", ~~lit('x'))); + BOOST_TEST(!test("x", ~~lit('y'))); + + BOOST_TEST(test("x", ~~lit('x'), 'x')); + BOOST_TEST(!test("", ~~lit('y'), 'x')); + +// BOOST_TEST(test("a", ~~lit('a', 'z'), 'a')); +// BOOST_TEST(test("b", ~~lit('a', 'z'), 'b')); +// BOOST_TEST(!test("", ~~lit('a', 'z'), 'A')); + } + + { + BOOST_TEST(test(L"x", lit('x'))); + BOOST_TEST(test(L"x", lit(L'x'))); + BOOST_TEST(!test(L"x", lit('y'))); + BOOST_TEST(!test(L"x", lit(L'y'))); + + BOOST_TEST(test(L"x", lit(L'x'), L'x')); + BOOST_TEST(!test(L"", lit('y'), L'x')); + +// BOOST_TEST(test("a", lit("a", "z"), 'a')); +// BOOST_TEST(test(L"a", lit(L"a", L"z"), L'a')); + + BOOST_TEST(!test(L"", ~lit('x'))); + BOOST_TEST(!test(L"", ~lit(L'x'))); + + BOOST_TEST(!test(L"", ~lit(L'x'), L'x')); + BOOST_TEST(test(L"x", ~lit('y'), L'x')); + } + + { // lazy chars + using namespace boost::phoenix; + + BOOST_TEST((test("x", lit(val('x'))))); + BOOST_TEST((test(L"x", lit(val(L'x'))))); + + BOOST_TEST((test("x", lit(val('x')), 'x'))); + BOOST_TEST((test(L"x", lit(val(L'x')), L'x'))); + + BOOST_TEST((!test("", lit(val('y')), 'x'))); + BOOST_TEST((!test(L"", lit(val(L'y')), L'x'))); + } + + // we can pass optionals as attributes to any generator + { + boost::optional<char> v; + boost::optional<wchar_t> w; + + BOOST_TEST(!test("", lit('x'), v)); + BOOST_TEST(!test(L"", lit(L'x'), w)); + } + + return boost::report_errors(); +} |