]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/metaparse/test/transform_error.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / metaparse / test / transform_error.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)
5
6 #include <boost/metaparse/transform_error.hpp>
7 #include <boost/metaparse/start.hpp>
8 #include <boost/metaparse/string.hpp>
9 #include <boost/metaparse/reject.hpp>
10 #include <boost/metaparse/lit_c.hpp>
11 #include <boost/metaparse/get_position.hpp>
12
13 #include <boost/mpl/assert.hpp>
14
15 #include <boost/type_traits.hpp>
16
17 #include "test_case.hpp"
18
19 using boost::metaparse::reject;
20 using boost::metaparse::get_position;
21
22 namespace
23 {
24 struct new_message
25 {
26 typedef new_message type;
27 };
28
29 struct change_message
30 {
31 typedef change_message type;
32
33 template <class E>
34 struct apply : reject<new_message, get_position<E> > {};
35 };
36 }
37
38 BOOST_METAPARSE_TEST_CASE(transform_error)
39 {
40 using boost::metaparse::transform_error;
41 using boost::metaparse::start;
42 using boost::metaparse::string;
43 using boost::metaparse::lit_c;
44
45 using boost::is_same;
46
47 typedef string<'H','e','l','l','o'> s;
48
49 // test_transform_error_does_not_change_accept
50 BOOST_MPL_ASSERT((
51 is_same<
52 lit_c<'H'>::apply<s, start>::type,
53 transform_error<lit_c<'H'>, change_message>::apply<s, start>::type
54 >
55 ));
56
57 // test_transform_is_called
58 BOOST_MPL_ASSERT((
59 is_same<
60 reject<new_message, start>,
61 transform_error<lit_c<'x'>, change_message>::apply<s, start>::type
62 >
63 ));
64 }
65