]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/test/x3/bool.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / spirit / test / x3 / bool.cpp
1 /*=============================================================================
2 Copyright (c) 2001-2011 Hartmut Kaiser
3 Copyright (c) 2011 Bryce Lelbach
4
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 ==============================================================================*/
8 #include "bool.hpp"
9
10 int main()
11 {
12 using spirit_test::test_attr;
13 using spirit_test::test;
14 using boost::spirit::x3::bool_;
15
16 {
17 BOOST_TEST(test("true", bool_));
18 BOOST_TEST(test("false", bool_));
19 BOOST_TEST(!test("fasle", bool_));
20 }
21
22 {
23 using boost::spirit::x3::true_;
24 using boost::spirit::x3::false_;
25
26 BOOST_TEST(test("true", true_));
27 BOOST_TEST(!test("true", false_));
28 BOOST_TEST(test("false", false_));
29 BOOST_TEST(!test("false", true_));
30 }
31
32 {
33 using boost::spirit::x3::true_;
34 using boost::spirit::x3::false_;
35 using boost::spirit::x3::no_case;
36
37 BOOST_TEST(test("True", no_case[bool_]));
38 BOOST_TEST(test("False", no_case[bool_]));
39 BOOST_TEST(test("True", no_case[true_]));
40 BOOST_TEST(test("False", no_case[false_]));
41 }
42
43 {
44 bool b = false;
45 BOOST_TEST(test_attr("true", bool_, b) && b);
46 BOOST_TEST(test_attr("false", bool_, b) && !b);
47 BOOST_TEST(!test_attr("fasle", bool_, b));
48 }
49
50 {
51 typedef boost::spirit::x3::bool_parser<bool, boost::spirit::char_encoding::standard, backwards_bool_policies>
52 backwards_bool_type;
53 backwards_bool_type const backwards_bool = backwards_bool_type();
54
55 BOOST_TEST(test("true", backwards_bool));
56 BOOST_TEST(test("eurt", backwards_bool));
57 BOOST_TEST(!test("false", backwards_bool));
58 BOOST_TEST(!test("fasle", backwards_bool));
59
60 bool b = false;
61 BOOST_TEST(test_attr("true", backwards_bool, b) && b);
62 BOOST_TEST(test_attr("eurt", backwards_bool, b) && !b);
63 BOOST_TEST(!test_attr("false", backwards_bool, b));
64 BOOST_TEST(!test_attr("fasle", backwards_bool, b));
65 }
66
67 {
68 typedef boost::spirit::x3::bool_parser<test_bool_type, boost::spirit::char_encoding::standard>
69 bool_test_type;
70 bool_test_type const test_bool = bool_test_type();
71
72 BOOST_TEST(test("true", test_bool));
73 BOOST_TEST(test("false", test_bool));
74 BOOST_TEST(!test("fasle", test_bool));
75
76 test_bool_type b = false;
77 BOOST_TEST(test_attr("true", test_bool, b) && b.b);
78 BOOST_TEST(test_attr("false", test_bool, b) && !b.b);
79 BOOST_TEST(!test_attr("fasle", test_bool, b));
80 }
81
82 return boost::report_errors();
83 }