]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/test/karma/optional.cpp
1 // Copyright (c) 2001-2011 Hartmut Kaiser
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)
6 #include <boost/spirit/include/karma_optional.hpp>
8 #include <boost/spirit/include/karma_char.hpp>
9 #include <boost/spirit/include/karma_int.hpp>
10 #include <boost/spirit/include/karma_action.hpp>
11 #include <boost/phoenix/core.hpp>
12 #include <boost/phoenix/operator.hpp>
19 using namespace spirit_test
;
20 using namespace boost::spirit
;
21 using namespace boost::spirit::ascii
;
24 boost::optional
<int> opt
;
25 BOOST_TEST(test("", -int_
, opt
));
28 BOOST_TEST(test("10", -int_
, opt
));
33 BOOST_TEST(test("10", -int_
, opt
));
37 boost::optional
<int> opt
;
38 BOOST_TEST(test_delimited("", -int_
, opt
, space
));
41 BOOST_TEST(test_delimited("10 ", -int_
, opt
, space
));
46 BOOST_TEST(test_delimited("10 ", -int_
, opt
, space
));
50 using namespace boost::phoenix
;
51 namespace phoenix
= boost::phoenix
;
53 boost::optional
<int> n
;
54 BOOST_TEST(test("", (-int_
)[_1
= phoenix::ref(n
)]));
57 BOOST_TEST(test("1234", (-int_
)[_1
= phoenix::ref(n
)]));
61 using namespace boost::phoenix
;
62 namespace phoenix
= boost::phoenix
;
65 BOOST_TEST(test("1234", (-int_
)[_1
= phoenix::ref(n
)]));
69 using namespace boost::phoenix
;
70 namespace phoenix
= boost::phoenix
;
72 boost::optional
<int> n
;
73 BOOST_TEST(test_delimited("", (-int_
)[_1
= phoenix::ref(n
)], space
));
76 BOOST_TEST(test_delimited("1234 ", (-int_
)[_1
= phoenix::ref(n
)], space
));
80 using namespace boost::phoenix
;
81 namespace phoenix
= boost::phoenix
;
84 BOOST_TEST(test_delimited("1234 ", (-int_
)[_1
= phoenix::ref(n
)], space
));
87 return boost::report_errors();