1 /*=============================================================================
2 Copyright (c) 2001-2010 Joel de Guzman
3 Copyright (c) 2001-2010 Hartmut Kaiser
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 <boost/detail/lightweight_test.hpp>
9 #include <boost/spirit/include/qi_char.hpp>
10 #include <boost/spirit/include/qi_auxiliary.hpp>
11 #include <boost/spirit/include/qi_operator.hpp>
12 #include <boost/spirit/include/support_argument.hpp>
13 #include <boost/spirit/include/phoenix_core.hpp>
14 #include <boost/spirit/include/phoenix_operator.hpp>
15
16 #include <iostream>
17 #include "test.hpp"
18
19 int
main()20 main()
21 {
22 using spirit_test::test;
23 namespace qi = boost::spirit::qi;
24 namespace ascii = boost::spirit::ascii;
25 namespace wide = boost::spirit::standard_wide;
26
27 using qi::eol;
28 using qi::eoi;
29 using ascii::space;
30
31 { // eol
32 BOOST_TEST(test("\r", eol));
33 BOOST_TEST(test("\r\n", eol));
34 BOOST_TEST(test("\n", eol));
35 BOOST_TEST(!test("\b", eol));
36
37 BOOST_TEST(!test("\r", !eol, false));
38 BOOST_TEST(!test("\r\n", !eol, false));
39 BOOST_TEST(!test("\n", !eol, false));
40 BOOST_TEST(test("\b", !eol, false));
41
42 BOOST_TEST(test(" \r", eol, ascii::char_(' ')));
43 BOOST_TEST(test(" \r\n", eol, ascii::char_(' ')));
44 BOOST_TEST(test(" \n", eol, ascii::char_(' ')));
45 BOOST_TEST(!test(" \b", eol, ascii::char_(' ')));
46
47 BOOST_TEST(test(L"\r", eol));
48 BOOST_TEST(test(L"\r\n", eol));
49 BOOST_TEST(test(L"\n", eol));
50 BOOST_TEST(!test(L"\b", eol));
51
52 BOOST_TEST(test(L" \r", eol, wide::char_(L' ')));
53 BOOST_TEST(test(L" \r\n", eol, wide::char_(L' ')));
54 BOOST_TEST(test(L" \n", eol, wide::char_(L' ')));
55 BOOST_TEST(!test(L" \b", eol, wide::char_(L' ')));
56 }
57
58 { // eoi
59 BOOST_TEST(test("", eoi));
60 BOOST_TEST(!test("a", eoi));
61 BOOST_TEST(test("a", !eoi, false));
62 BOOST_TEST(!test("", !eoi));
63
64 BOOST_TEST(test(" ", eoi, space));
65 BOOST_TEST(!test(" a", eoi, space));
66 BOOST_TEST(test(" a", !eoi, space, false));
67 BOOST_TEST(!test(" ", !eoi, space));
68 }
69
70 return boost::report_errors();
71 }
72