• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_auxiliary.hpp>
10 #include <boost/spirit/include/karma_char.hpp>
11 #include <boost/spirit/include/karma_numeric.hpp>
12 #include <boost/spirit/include/karma_generate.hpp>
13 #include <boost/spirit/include/karma_operator.hpp>
14 #include <boost/spirit/include/phoenix_core.hpp>
15 
16 #include <iostream>
17 #include "test.hpp"
18 
19 int
main()20 main()
21 {
22     using namespace spirit_test;
23     using namespace boost::spirit;
24 
25     {
26         using namespace boost::spirit::ascii;
27 
28         BOOST_TEST(test("", eps));
29         BOOST_TEST(test_delimited(" ", eps, space));
30 
31         BOOST_TEST(!test("", !eps));
32         BOOST_TEST(!test_delimited(" ", !eps, space));
33     }
34 
35     {   // test direct argument
36         using namespace boost::phoenix;
37 
38         BOOST_TEST(test("", eps(true)));
39         BOOST_TEST(!test("", eps(false)));
40     }
41 
42     {   // test action
43         using namespace boost::phoenix;
44 
45         BOOST_TEST(test("", eps(val(true))));
46         BOOST_TEST(!test("", eps(val(false))));
47     }
48 
49     {   // test no delimiter when argument is false
50         using namespace boost::spirit::ascii;
51 
52         std::string generated;
53         std::back_insert_iterator<std::string> outit(generated);
54         BOOST_TEST(!karma::generate_delimited(outit, eps(false), space));
55         BOOST_TEST(generated.empty());
56     }
57 
58     return boost::report_errors();
59 }
60