summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/spirit/test/qi/end.cpp
blob: 46fde1d6c23661a9aeafd9dea909d0a5b32543fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*=============================================================================
    Copyright (c) 2001-2010 Joel de Guzman
    Copyright (c) 2001-2010 Hartmut Kaiser

    Distributed under the Boost Software License, Version 1.0. (See accompanying
    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include <boost/detail/lightweight_test.hpp>
#include <boost/spirit/include/qi_char.hpp>
#include <boost/spirit/include/qi_auxiliary.hpp>
#include <boost/spirit/include/qi_operator.hpp>
#include <boost/spirit/include/support_argument.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>

#include <iostream>
#include "test.hpp"

int
main()
{
    using spirit_test::test;
    namespace qi = boost::spirit::qi;
    namespace ascii = boost::spirit::ascii;
    namespace wide = boost::spirit::standard_wide;

    using qi::eol;
    using qi::eoi;
    using ascii::space;

    {   // eol
        BOOST_TEST(test("\r", eol));
        BOOST_TEST(test("\r\n", eol));
        BOOST_TEST(test("\n", eol));
        BOOST_TEST(!test("\b", eol));

        BOOST_TEST(!test("\r", !eol, false));
        BOOST_TEST(!test("\r\n", !eol, false));
        BOOST_TEST(!test("\n", !eol, false));
        BOOST_TEST(test("\b", !eol, false));

        BOOST_TEST(test("   \r", eol, ascii::char_(' ')));
        BOOST_TEST(test("   \r\n", eol, ascii::char_(' ')));
        BOOST_TEST(test("   \n", eol, ascii::char_(' ')));
        BOOST_TEST(!test("   \b", eol, ascii::char_(' ')));

        BOOST_TEST(test(L"\r", eol));
        BOOST_TEST(test(L"\r\n", eol));
        BOOST_TEST(test(L"\n", eol));
        BOOST_TEST(!test(L"\b", eol));

        BOOST_TEST(test(L"   \r", eol, wide::char_(L' ')));
        BOOST_TEST(test(L"   \r\n", eol, wide::char_(L' ')));
        BOOST_TEST(test(L"   \n", eol, wide::char_(L' ')));
        BOOST_TEST(!test(L"   \b", eol, wide::char_(L' ')));
    }

    {   // eoi
        BOOST_TEST(test("", eoi));
        BOOST_TEST(!test("a", eoi));
        BOOST_TEST(test("a", !eoi, false));
        BOOST_TEST(!test("", !eoi));

        BOOST_TEST(test("   ", eoi, space));
        BOOST_TEST(!test("   a", eoi, space));
        BOOST_TEST(test("   a", !eoi, space, false));
        BOOST_TEST(!test("   ", !eoi, space));
    }

    return boost::report_errors();
}