]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/metaparse/test/optional.cpp
1 // Copyright Abel Sinkovics (abel@sinkovics.hu) 2015.
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
6 #include <boost/metaparse/optional.hpp>
7 #include <boost/metaparse/string.hpp>
8 #include <boost/metaparse/lit_c.hpp>
9 #include <boost/metaparse/get_result.hpp>
10 #include <boost/metaparse/start.hpp>
12 #include <boost/mpl/assert.hpp>
13 #include <boost/mpl/equal_to.hpp>
14 #include <boost/mpl/char.hpp>
16 #include <boost/type_traits/is_same.hpp>
18 #include "test_case.hpp"
20 BOOST_METAPARSE_TEST_CASE(optional
)
22 using boost::metaparse::optional
;
23 using boost::metaparse::lit_c
;
24 using boost::metaparse::string
;
25 using boost::metaparse::get_result
;
26 using boost::metaparse::start
;
28 using boost::mpl::equal_to
;
32 typedef optional
<lit_c
<'x'>, double> optional_x
;
34 // test_optional_parser_succeeds
37 boost::mpl::char_
<'x'>,
38 get_result
<optional_x::apply
<string
<'x'>, start
> >::type
42 // test_optional_parser_fails
44 is_same
<double, get_result
<optional_x::apply
<string
<'y'>, start
> >::type
>
47 // test_optional_parser_default_value
51 get_result
<optional
<lit_c
<'x'> >::apply
<string
<'y'>, start
> >::type