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 
9 #include "bool.hpp"
10 
main()11 int main()
12 {
13     using spirit_test::test_attr;
14     using spirit_test::test;
15     using boost::spirit::qi::bool_;
16 
17     {
18         BOOST_TEST(test("true", bool_));
19         BOOST_TEST(test("false", bool_));
20         BOOST_TEST(!test("fasle", bool_));
21     }
22 
23     {
24         using boost::spirit::qi::true_;
25         using boost::spirit::qi::false_;
26 
27         BOOST_TEST(test("true", true_));
28         BOOST_TEST(!test("true", false_));
29         BOOST_TEST(test("false", false_));
30         BOOST_TEST(!test("false", true_));
31     }
32 
33     {
34         using boost::spirit::qi::true_;
35         using boost::spirit::qi::false_;
36         using boost::spirit::qi::no_case;
37 
38         BOOST_TEST(test("True", no_case[bool_]));
39         BOOST_TEST(test("False", no_case[bool_]));
40         BOOST_TEST(test("True", no_case[true_]));
41         BOOST_TEST(test("False", no_case[false_]));
42     }
43 
44     {
45         bool b = false;
46         BOOST_TEST(test_attr("true", bool_, b) && b);
47         BOOST_TEST(test_attr("false", bool_, b) && !b);
48         BOOST_TEST(!test_attr("fasle", bool_, b));
49     }
50 
51     {
52         typedef boost::spirit::qi::bool_parser<bool, backwards_bool_policies>
53             backwards_bool_type;
54         backwards_bool_type const backwards_bool = backwards_bool_type();
55 
56         BOOST_TEST(test("true", backwards_bool));
57         BOOST_TEST(test("eurt", backwards_bool));
58         BOOST_TEST(!test("false", backwards_bool));
59         BOOST_TEST(!test("fasle", backwards_bool));
60 
61         bool b = false;
62         BOOST_TEST(test_attr("true", backwards_bool, b) && b);
63         BOOST_TEST(test_attr("eurt", backwards_bool, b) && !b);
64         BOOST_TEST(!test_attr("false", backwards_bool, b));
65         BOOST_TEST(!test_attr("fasle", backwards_bool, b));
66     }
67 
68     {
69         typedef boost::spirit::qi::bool_parser<test_bool_type>
70             bool_test_type;
71         bool_test_type const test_bool = bool_test_type();
72 
73         BOOST_TEST(test("true", test_bool));
74         BOOST_TEST(test("false", test_bool));
75         BOOST_TEST(!test("fasle", test_bool));
76 
77         test_bool_type b = false;
78         BOOST_TEST(test_attr("true", test_bool, b) && b.b);
79         BOOST_TEST(test_attr("false", test_bool, b) && !b.b);
80         BOOST_TEST(!test_attr("fasle", test_bool, b));
81     }
82 
83     return boost::report_errors();
84 }
85