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/generate_attr.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/generate_attr.cpp')
-rw-r--r-- | src/boost/libs/spirit/test/karma/generate_attr.cpp | 169 |
1 files changed, 169 insertions, 0 deletions
diff --git a/src/boost/libs/spirit/test/karma/generate_attr.cpp b/src/boost/libs/spirit/test/karma/generate_attr.cpp new file mode 100644 index 00000000..7656f4c3 --- /dev/null +++ b/src/boost/libs/spirit/test/karma/generate_attr.cpp @@ -0,0 +1,169 @@ +// 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_operator.hpp> +#include <boost/spirit/include/karma_generate_attr.hpp> + +#include "test_attr.hpp" + +#if SPIRIT_ARGUMENTS_LIMIT < 10 +# error SPIRIT_ARGUMENTS_LIMIT must be at least 10 to run the test +#endif + +using namespace spirit_test; + +/////////////////////////////////////////////////////////////////////////////// +int +main() +{ + using namespace boost::spirit; + + { + using namespace boost::spirit::ascii; + + BOOST_TEST(test("1", char_, '1')); + BOOST_TEST(test("12", char_ << char_, '1', '2')); + BOOST_TEST(test("123", char_ << char_ << char_, '1', '2', '3')); + BOOST_TEST(test("1234" + , char_ << char_ << char_ << char_ + , '1', '2', '3', '4')); + BOOST_TEST(test("12345" + , char_ << char_ << char_ << char_ << char_ + , '1', '2', '3', '4', '5')); + BOOST_TEST(test("123456" + , char_ << char_ << char_ << char_ << char_ << char_ + , '1', '2', '3', '4', '5', '6')); + BOOST_TEST(test("1234567" + , char_ << char_ << char_ << char_ << char_ << char_ << char_ + , '1', '2', '3', '4', '5', '6', '7')); + BOOST_TEST(test("12345678" + , char_ << char_ << char_ << char_ << char_ << char_ << char_ << char_ + , '1', '2', '3', '4', '5', '6', '7', '8')); + BOOST_TEST(test("123456789" + , char_ << char_ << char_ << char_ << char_ << char_ << char_ << char_ << char_ + , '1', '2', '3', '4', '5', '6', '7', '8', '9')); + BOOST_TEST(test("1234567890" + , char_ << char_ << char_ << char_ << char_ << char_ << char_ << char_ << char_ << char_ + , '1', '2', '3', '4', '5', '6', '7', '8', '9', '0')); + } + + { + using namespace boost::spirit::ascii; + + BOOST_TEST(test_delimited("1 ", char_, space, '1')); + BOOST_TEST(test_delimited("1 2 " + , char_ << char_, space, '1', '2')); + BOOST_TEST(test_delimited("1 2 3 " + , char_ << char_ << char_, space, '1', '2', '3')); + BOOST_TEST(test_delimited("1 2 3 4 " + , char_ << char_ << char_ << char_ + , space, '1', '2', '3', '4')); + BOOST_TEST(test_delimited("1 2 3 4 5 " + , char_ << char_ << char_ << char_ << char_ + , space, '1', '2', '3', '4', '5')); + BOOST_TEST(test_delimited("1 2 3 4 5 6 " + , char_ << char_ << char_ << char_ << char_ << char_ + , space, '1', '2', '3', '4', '5', '6')); + BOOST_TEST(test_delimited("1 2 3 4 5 6 7 " + , char_ << char_ << char_ << char_ << char_ << char_ << char_ + , space, '1', '2', '3', '4', '5', '6', '7')); + BOOST_TEST(test_delimited("1 2 3 4 5 6 7 8 " + , char_ << char_ << char_ << char_ << char_ << char_ << char_ << char_ + , space, '1', '2', '3', '4', '5', '6', '7', '8')); + BOOST_TEST(test_delimited("1 2 3 4 5 6 7 8 9 " + , char_ << char_ << char_ << char_ << char_ << char_ << char_ << char_ << char_ + , space, '1', '2', '3', '4', '5', '6', '7', '8', '9')); + BOOST_TEST(test_delimited("1 2 3 4 5 6 7 8 9 0 " + , char_ << char_ << char_ << char_ << char_ << char_ << char_ << char_ << char_ << char_ + , space, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0')); + } + + { + using namespace boost::spirit::ascii; + using boost::spirit::karma::delimit_flag; + + BOOST_TEST(test_predelimited(" 1 ", char_, space + , delimit_flag::predelimit, '1')); + BOOST_TEST(test_predelimited(" 1 2 " + , char_ << char_, space, delimit_flag::predelimit + , '1', '2')); + BOOST_TEST(test_predelimited(" 1 2 3 " + , char_ << char_ << char_, space + , delimit_flag::predelimit, '1', '2', '3')); + BOOST_TEST(test_predelimited(" 1 2 3 4 " + , char_ << char_ << char_ << char_ + , space, delimit_flag::predelimit, '1', '2', '3', '4')); + BOOST_TEST(test_predelimited(" 1 2 3 4 5 " + , char_ << char_ << char_ << char_ << char_ + , space, delimit_flag::predelimit, '1', '2', '3', '4', '5')); + BOOST_TEST(test_predelimited(" 1 2 3 4 5 6 " + , char_ << char_ << char_ << char_ << char_ << char_ + , space, delimit_flag::predelimit + , '1', '2', '3', '4', '5', '6')); + BOOST_TEST(test_predelimited(" 1 2 3 4 5 6 7 " + , char_ << char_ << char_ << char_ << char_ << char_ << char_ + , space, delimit_flag::predelimit + , '1', '2', '3', '4', '5', '6', '7')); + BOOST_TEST(test_predelimited(" 1 2 3 4 5 6 7 8 " + , char_ << char_ << char_ << char_ << char_ << char_ << char_ << char_ + , space, delimit_flag::predelimit + , '1', '2', '3', '4', '5', '6', '7', '8')); + BOOST_TEST(test_predelimited(" 1 2 3 4 5 6 7 8 9 " + , char_ << char_ << char_ << char_ << char_ << char_ << char_ << char_ << char_ + , space, delimit_flag::predelimit + , '1', '2', '3', '4', '5', '6', '7', '8', '9')); + BOOST_TEST(test_predelimited(" 1 2 3 4 5 6 7 8 9 0 " + , char_ << char_ << char_ << char_ << char_ << char_ << char_ << char_ << char_ << char_ + , space, delimit_flag::predelimit + , '1', '2', '3', '4', '5', '6', '7', '8', '9', '0')); + } + + { + using namespace boost::spirit::ascii; + using boost::spirit::karma::delimit_flag; + + BOOST_TEST(test_predelimited("1 ", char_, space + , delimit_flag::dont_predelimit, '1')); + BOOST_TEST(test_predelimited("1 2 " + , char_ << char_, space, delimit_flag::dont_predelimit + , '1', '2')); + BOOST_TEST(test_predelimited("1 2 3 " + , char_ << char_ << char_, space + , delimit_flag::dont_predelimit, '1', '2', '3')); + BOOST_TEST(test_predelimited("1 2 3 4 " + , char_ << char_ << char_ << char_ + , space, delimit_flag::dont_predelimit, '1', '2', '3', '4')); + BOOST_TEST(test_predelimited("1 2 3 4 5 " + , char_ << char_ << char_ << char_ << char_ + , space, delimit_flag::dont_predelimit, '1', '2', '3', '4', '5')); + BOOST_TEST(test_predelimited("1 2 3 4 5 6 " + , char_ << char_ << char_ << char_ << char_ << char_ + , space, delimit_flag::dont_predelimit + , '1', '2', '3', '4', '5', '6')); + BOOST_TEST(test_predelimited("1 2 3 4 5 6 7 " + , char_ << char_ << char_ << char_ << char_ << char_ << char_ + , space, delimit_flag::dont_predelimit + , '1', '2', '3', '4', '5', '6', '7')); + BOOST_TEST(test_predelimited("1 2 3 4 5 6 7 8 " + , char_ << char_ << char_ << char_ << char_ << char_ << char_ << char_ + , space, delimit_flag::dont_predelimit + , '1', '2', '3', '4', '5', '6', '7', '8')); + BOOST_TEST(test_predelimited("1 2 3 4 5 6 7 8 9 " + , char_ << char_ << char_ << char_ << char_ << char_ << char_ << char_ << char_ + , space, delimit_flag::dont_predelimit + , '1', '2', '3', '4', '5', '6', '7', '8', '9')); + BOOST_TEST(test_predelimited("1 2 3 4 5 6 7 8 9 0 " + , char_ << char_ << char_ << char_ << char_ << char_ << char_ << char_ << char_ << char_ + , space, delimit_flag::dont_predelimit + , '1', '2', '3', '4', '5', '6', '7', '8', '9', '0')); + } + + return boost::report_errors(); +} + |