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/config/warning_disable.hpp>
7 #include <boost/detail/lightweight_test.hpp>
8 
9 #include <boost/spirit/include/karma.hpp>
10 
11 #include <iostream>
12 #include "test.hpp"
13 
14 using namespace spirit_test;
15 
main()16 int main()
17 {
18     using boost::spirit::karma::double_;
19     using boost::spirit::karma::space;
20     using boost::spirit::karma::duplicate;
21 
22     // test for sequences
23     {
24         BOOST_TEST(test("2.02.0", duplicate[double_ << double_], 2.0));
25         BOOST_TEST(test_delimited("2.0 2.0 ",
26             duplicate[double_ << double_], 2.0, space));
27         BOOST_TEST(test("2.02.02.0",
28             duplicate[double_ << double_ << double_], 2.0));
29         BOOST_TEST(test_delimited("2.0 2.0 2.0 ",
30             duplicate[double_ << double_ << double_], 2.0, space));
31     }
32 
33     // test for non-sequences
34     {
35         BOOST_TEST(test("2.02.0", duplicate["2.0" << double_], 2.0));
36         BOOST_TEST(test_delimited("2.0 2.0 ",
37             duplicate["2.0" << double_], 2.0, space));
38     }
39 
40     // test for subjects exposing no attribute
41     {
42         BOOST_TEST(test("2.02.0", duplicate["2.0"] << double_, 2.0));
43         BOOST_TEST(test_delimited("2.0 2.0 ",
44             duplicate["2.0"] << double_, 2.0, space));
45     }
46 
47     // test for attribute reporting
48     {
49         BOOST_TEST(test("bar", (duplicate["bar"] | "foo")));
50         BOOST_TEST(test("2.0", (duplicate[double_] | "foo"), 2.0));
51         BOOST_TEST(test("2.02.0",
52             (duplicate[double_ << double_] | "foo"), 2.0));
53     }
54 
55     return boost::report_errors();
56 }
57