]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/test/karma/duplicate.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / spirit / test / karma / duplicate.cpp
1 // Copyright (c) 2001-2011 Hartmut Kaiser
2 //
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 #include <boost/spirit/include/karma_duplicate.hpp>
7
8 #include <boost/spirit/include/karma.hpp>
9
10 #include <iostream>
11 #include "test.hpp"
12
13 using namespace spirit_test;
14
15 int main()
16 {
17 using boost::spirit::karma::double_;
18 using boost::spirit::karma::space;
19 using boost::spirit::karma::duplicate;
20
21 // test for sequences
22 {
23 BOOST_TEST(test("2.02.0", duplicate[double_ << double_], 2.0));
24 BOOST_TEST(test_delimited("2.0 2.0 ",
25 duplicate[double_ << double_], 2.0, space));
26 BOOST_TEST(test("2.02.02.0",
27 duplicate[double_ << double_ << double_], 2.0));
28 BOOST_TEST(test_delimited("2.0 2.0 2.0 ",
29 duplicate[double_ << double_ << double_], 2.0, space));
30 }
31
32 // test for non-sequences
33 {
34 BOOST_TEST(test("2.02.0", duplicate["2.0" << double_], 2.0));
35 BOOST_TEST(test_delimited("2.0 2.0 ",
36 duplicate["2.0" << double_], 2.0, space));
37 }
38
39 // test for subjects exposing no attribute
40 {
41 BOOST_TEST(test("2.02.0", duplicate["2.0"] << double_, 2.0));
42 BOOST_TEST(test_delimited("2.0 2.0 ",
43 duplicate["2.0"] << double_, 2.0, space));
44 }
45
46 // test for attribute reporting
47 {
48 BOOST_TEST(test("bar", (duplicate["bar"] | "foo")));
49 BOOST_TEST(test("2.0", (duplicate[double_] | "foo"), 2.0));
50 BOOST_TEST(test("2.02.0",
51 (duplicate[double_ << double_] | "foo"), 2.0));
52 }
53
54 return boost::report_errors();
55 }