• 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_char.hpp>
10 #include <boost/spirit/include/karma_operator.hpp>
11 #include <boost/spirit/include/karma_numeric.hpp>
12 #include <boost/spirit/include/karma_action.hpp>
13 #include <boost/spirit/include/phoenix_core.hpp>
14 #include <boost/spirit/include/phoenix_operator.hpp>
15 
16 #include <iostream>
17 #include "test.hpp"
18 
main()19 int main()
20 {
21     using namespace spirit_test;
22     using namespace boost::spirit;
23     using namespace boost::spirit::ascii;
24 
25     {
26         boost::optional<int> opt;
27         BOOST_TEST(test("", -int_, opt));
28 
29         opt = 10;
30         BOOST_TEST(test("10", -int_, opt));
31     }
32 
33     {
34         int opt = 10;
35         BOOST_TEST(test("10", -int_, opt));
36     }
37 
38     {
39         boost::optional<int> opt;
40         BOOST_TEST(test_delimited("", -int_, opt, space));
41 
42         opt = 10;
43         BOOST_TEST(test_delimited("10 ", -int_, opt, space));
44     }
45 
46     {
47         int opt = 10;
48         BOOST_TEST(test_delimited("10 ", -int_, opt, space));
49     }
50 
51     {   // test action
52         using namespace boost::phoenix;
53         namespace phoenix = boost::phoenix;
54 
55         boost::optional<int> n ;
56         BOOST_TEST(test("", (-int_)[_1 = phoenix::ref(n)]));
57 
58         n = 1234;
59         BOOST_TEST(test("1234", (-int_)[_1 = phoenix::ref(n)]));
60     }
61 
62     {   // test action
63         using namespace boost::phoenix;
64         namespace phoenix = boost::phoenix;
65 
66         int n = 1234;
67         BOOST_TEST(test("1234", (-int_)[_1 = phoenix::ref(n)]));
68     }
69 
70     {   // test action
71         using namespace boost::phoenix;
72         namespace phoenix = boost::phoenix;
73 
74         boost::optional<int> n;
75         BOOST_TEST(test_delimited("", (-int_)[_1 = phoenix::ref(n)], space));
76 
77         n = 1234;
78         BOOST_TEST(test_delimited("1234 ", (-int_)[_1 = phoenix::ref(n)], space));
79     }
80 
81     {   // test action
82         using namespace boost::phoenix;
83         namespace phoenix = boost::phoenix;
84 
85         int n = 1234;
86         BOOST_TEST(test_delimited("1234 ", (-int_)[_1 = phoenix::ref(n)], space));
87     }
88 
89     return boost::report_errors();
90 }
91