• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //  Copyright (c) 2001-2010 Hartmut Kaiser
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/config/warning_disable.hpp>
7 #include <boost/detail/lightweight_test.hpp>
8 #include <boost/detail/workaround.hpp>
9 
10 #include <boost/spirit/include/karma_char.hpp>
11 #include <boost/spirit/include/karma_string.hpp>
12 #include <boost/spirit/include/karma_generate.hpp>
13 #include <boost/spirit/include/karma_directive.hpp>
14 
15 #include "test.hpp"
16 
17 using namespace spirit_test;
18 
19 ///////////////////////////////////////////////////////////////////////////////
20 int
main()21 main()
22 {
23     using namespace boost::spirit;
24 
25     { // test extended ASCII characters
26         using namespace boost::spirit::iso8859_1;
27 
28         BOOST_TEST(test("\xE4", lower['\xC4']));
29         BOOST_TEST(test("\xE4", lower['\xE4']));
30 
31         BOOST_TEST(test("\xC4", upper['\xC4']));
32         BOOST_TEST(test("\xC4", upper['\xE4']));
33     }
34 
35     {
36         using namespace boost::spirit::ascii;
37 
38         BOOST_TEST(test("a1- ", lower["a1- "]));
39         BOOST_TEST(test("a1- ", lower["a1- "]));
40         BOOST_TEST(test("a1- ", lower["a1- "]));
41         BOOST_TEST(test("a1- ", lower["A1- "]));
42 
43         BOOST_TEST(test("a1- ", lower[string], "a1- "));
44         BOOST_TEST(test("a1- ", lower[string], "A1- "));
45         BOOST_TEST(test("a1- ", lower[lit("a1- ")]));
46         BOOST_TEST(test("a1- ", lower[lit("A1- ")]));
47         BOOST_TEST(test("a1- ", lower[string("a1- ")]));
48         BOOST_TEST(test("a1- ", lower[string("A1- ")]));
49 
50         BOOST_TEST(test("a1- ", lower[lower["a1- "]]));
51         BOOST_TEST(test("a1- ", lower[lower["a1- "]]));
52         BOOST_TEST(test("a1- ", lower[lower["a1- "]]));
53         BOOST_TEST(test("a1- ", lower[lower["A1- "]]));
54 
55         BOOST_TEST(test("a1- ", lower[lower[string]], "a1- "));
56         BOOST_TEST(test("a1- ", lower[lower[string]], "A1- "));
57         BOOST_TEST(test("a1- ", lower[lower[lit("a1- ")]]));
58         BOOST_TEST(test("a1- ", lower[lower[lit("A1- ")]]));
59         BOOST_TEST(test("a1- ", lower[lower[string("a1- ")]]));
60         BOOST_TEST(test("a1- ", lower[lower[string("A1- ")]]));
61 
62         BOOST_TEST(test("A1- ", upper[lower["a1- "]]));
63         BOOST_TEST(test("A1- ", upper[lower["a1- "]]));
64         BOOST_TEST(test("A1- ", upper[lower["a1- "]]));
65         BOOST_TEST(test("A1- ", upper[lower["A1- "]]));
66 
67         BOOST_TEST(test("A1- ", upper[lower[string]], "a1- "));
68         BOOST_TEST(test("A1- ", upper[lower[string]], "A1- "));
69         BOOST_TEST(test("A1- ", upper[lower[lit("a1- ")]]));
70         BOOST_TEST(test("A1- ", upper[lower[lit("A1- ")]]));
71         BOOST_TEST(test("A1- ", upper[lower[string("a1- ")]]));
72         BOOST_TEST(test("A1- ", upper[lower[string("A1- ")]]));
73 
74         BOOST_TEST(test("A1- ", upper["a1- "]));
75         BOOST_TEST(test("A1- ", upper["a1- "]));
76         BOOST_TEST(test("A1- ", upper["a1- "]));
77         BOOST_TEST(test("A1- ", upper["A1- "]));
78 
79         BOOST_TEST(test("A1- ", upper[string], "a1- "));
80         BOOST_TEST(test("A1- ", upper[string], "A1- "));
81         BOOST_TEST(test("A1- ", upper[lit("a1- ")]));
82         BOOST_TEST(test("A1- ", upper[lit("A1- ")]));
83 
84         BOOST_TEST(test("a1- ", lower[upper["a1- "]]));
85         BOOST_TEST(test("a1- ", lower[upper["a1- "]]));
86         BOOST_TEST(test("a1- ", lower[upper["a1- "]]));
87         BOOST_TEST(test("a1- ", lower[upper["A1- "]]));
88 
89         BOOST_TEST(test("a1- ", lower[upper[string]], "a1- "));
90         BOOST_TEST(test("a1- ", lower[upper[string]], "A1- "));
91         BOOST_TEST(test("a1- ", lower[upper[lit("a1- ")]]));
92         BOOST_TEST(test("a1- ", lower[upper[lit("A1- ")]]));
93         BOOST_TEST(test("a1- ", lower[upper[string("a1- ")]]));
94         BOOST_TEST(test("a1- ", lower[upper[string("A1- ")]]));
95 
96         BOOST_TEST(test("A1- ", upper[upper["a1- "]]));
97         BOOST_TEST(test("A1- ", upper[upper["a1- "]]));
98         BOOST_TEST(test("A1- ", upper[upper["a1- "]]));
99         BOOST_TEST(test("A1- ", upper[upper["A1- "]]));
100 
101         BOOST_TEST(test("A1- ", upper[upper[string]], "a1- "));
102         BOOST_TEST(test("A1- ", upper[upper[string]], "A1- "));
103         BOOST_TEST(test("A1- ", upper[upper[lit("a1- ")]]));
104         BOOST_TEST(test("A1- ", upper[upper[lit("A1- ")]]));
105         BOOST_TEST(test("A1- ", upper[upper[string("a1- ")]]));
106         BOOST_TEST(test("A1- ", upper[upper[string("A1- ")]]));
107     }
108 
109     return boost::report_errors();
110 }
111