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/x3/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/x3/attr.cpp')
-rw-r--r-- | src/boost/libs/spirit/test/x3/attr.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/boost/libs/spirit/test/x3/attr.cpp b/src/boost/libs/spirit/test/x3/attr.cpp new file mode 100644 index 00000000..ead8d49f --- /dev/null +++ b/src/boost/libs/spirit/test/x3/attr.cpp @@ -0,0 +1,53 @@ +/*============================================================================= + Copyright (c) 2001-2015 Joel de Guzman + + Distributed under the Boost Software License, Version 1. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#include <boost/detail/lightweight_test.hpp> +#include <boost/spirit/home/x3.hpp> + +#include <boost/fusion/include/std_pair.hpp> +#include <vector> + +#include "test.hpp" + +int main() +{ + using spirit_test::test_attr; + using boost::spirit::x3::attr; + using boost::spirit::x3::int_; + + { + int d = 0; + BOOST_TEST(test_attr("", attr(1), d) && d == 1); + + int d1 = 1; + BOOST_TEST(test_attr("", attr(d1), d) && d == 1); + + std::pair<int, int> p; + BOOST_TEST(test_attr("1", int_ >> attr(1), p) && + p.first == 1 && p.second == 1); + + char c = '\0'; + BOOST_TEST(test_attr("", attr('a'), c) && c == 'a'); + + // $$$ Needs some special is_convertible support, or + // str ends up with an explicit null-terminator... $$$ + //~ std::string str; + //~ BOOST_TEST(test_attr("", attr("test"), str) && str == "test"); + + int array[] = {0, 1, 2}; + std::vector<int> vec; + BOOST_TEST(test_attr("", attr(array), vec) && vec.size() == 3 && + vec[0] == 0 && vec[1] == 1 && vec[2] == 2); + } + + { + std::string s; + BOOST_TEST(test_attr("s", "s" >> attr(std::string("123")), s) && + s == "123"); + } + + return boost::report_errors(); +} |