• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //  Copyright (c) 2011 Bryce Lelbach
2 //
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)
5 
6 #include <boost/detail/lightweight_test.hpp>
7 #include <boost/spirit/include/qi.hpp>
8 
9 #include "test.hpp"
10 
main()11 int main()
12 {
13     using spirit_test::test;
14     using boost::spirit::qi::rule;
15     using boost::spirit::qi::parse;
16     using boost::spirit::qi::int_;
17     using boost::spirit::qi::uint_;
18     using boost::spirit::qi::short_;
19     using boost::spirit::qi::ushort_;
20     using boost::spirit::qi::long_;
21     using boost::spirit::qi::ulong_;
22     using boost::spirit::qi::float_;
23     using boost::spirit::qi::double_;
24     using boost::spirit::qi::long_double;
25     using boost::spirit::qi::bool_;
26 
27 #ifdef BOOST_HAS_LONG_LONG
28     using boost::spirit::qi::long_long;
29     using boost::spirit::qi::ulong_long;
30 #endif
31 
32     BOOST_TEST(test("-123", short_(0) | short_(-123)));
33     BOOST_TEST(test("-123", short_(-123) | short_(0)));
34 
35     BOOST_TEST(test("123", ushort_(0) | ushort_(123)));
36     BOOST_TEST(test("123", ushort_(123) | ushort_(0)));
37 
38     BOOST_TEST(test("-123456", int_(0) | int_(-123456)));
39     BOOST_TEST(test("-123456", int_(-123456) | int_(0)));
40 
41     BOOST_TEST(test("123456", uint_(0) | uint_(123456)));
42     BOOST_TEST(test("123456", uint_(123456) | uint_(0)));
43 
44     BOOST_TEST(test("-123456789", long_(0) | long_(-123456789L)));
45     BOOST_TEST(test("-123456789", long_(-123456789L) | long_(0)));
46 
47     BOOST_TEST(test("123456789", ulong_(0) | ulong_(123456789UL)));
48     BOOST_TEST(test("123456789", ulong_(123456789UL) | ulong_(0)));
49 
50 #ifdef BOOST_HAS_LONG_LONG
51     BOOST_TEST(test("-1234567890123456789",
52         long_long(0) | long_long(-1234567890123456789LL)));
53     BOOST_TEST(test("-1234567890123456789",
54         long_long(-1234567890123456789LL) | long_long(0)));
55 
56     BOOST_TEST(test("1234567890123456789",
57         ulong_long(0) | ulong_long(1234567890123456789ULL)));
58     BOOST_TEST(test("1234567890123456789",
59         ulong_long(1234567890123456789ULL) | ulong_long(0)));
60 #endif
61 
62     BOOST_TEST(test("1.23", float_(0) | float_(1.23f)));
63     BOOST_TEST(test("1.23", float_(1.23f) | float_(0)));
64 
65     BOOST_TEST(test("123.456", double_(0) | double_(123.456)));
66     BOOST_TEST(test("123.456", double_(123.456) | double_(0)));
67 
68     BOOST_TEST(test("123456.789", long_double(0) | long_double(123456.789l)));
69     BOOST_TEST(test("123456.789", long_double(123456.789l) | long_double(0)));
70 
71     BOOST_TEST(test("true", bool_(false) | bool_(true)));
72     BOOST_TEST(test("true", bool_(true) | bool_(false)));
73 
74     return boost::report_errors();
75 }
76 
77