]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/test/karma/symbols1.cpp
1 // Copyright (c) 2001-2011 Hartmut Kaiser
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)
6 #include <boost/spirit/include/karma_symbols.hpp>
8 #include <boost/spirit/include/karma_auxiliary.hpp>
9 #include <boost/spirit/include/karma_char.hpp>
10 #include <boost/spirit/include/karma_string.hpp>
11 #include <boost/spirit/include/karma_operator.hpp>
12 #include <boost/spirit/include/karma_directive.hpp>
13 #include <boost/spirit/include/karma_generate.hpp>
14 #include <boost/spirit/include/karma_nonterminal.hpp>
16 #include <boost/core/lightweight_test_trait.hpp>
20 namespace fusion
= boost::fusion
;
24 make_vector(T
const& t1
, T
const& t2
)
34 using spirit_test::test
;
35 using boost::spirit::karma::symbols
;
38 symbols
<char, std::string
> sym
;
47 BOOST_TEST_TRAIT_TRUE((
48 boost::spirit::traits::is_generator
<
49 symbols
<char, std::string
> >));
51 BOOST_TEST((test("Joel", sym
, 'j')));
52 BOOST_TEST((test("Hartmut", sym
, 'h')));
53 BOOST_TEST((test("Tom", sym
, 't')));
54 BOOST_TEST((test("Kim", sym
, 'k')));
55 BOOST_TEST((!test("", sym
, 'x')));
58 symbols
<char, std::string
> sym2
;
60 BOOST_TEST((test("Joel", sym2
, 'j')));
61 BOOST_TEST((test("Hartmut", sym2
, 'h')));
62 BOOST_TEST((test("Tom", sym2
, 't')));
63 BOOST_TEST((test("Kim", sym2
, 'k')));
64 BOOST_TEST((!test("", sym2
, 'x')));
66 // make sure it plays well with other generators
67 BOOST_TEST((test("Joelyo", sym
<< "yo", 'j')));
74 BOOST_TEST((!test("", sym
, 'j')));
75 BOOST_TEST((!test("", sym
, 'h')));
78 { // lower/upper handling
79 using namespace boost::spirit::ascii
;
80 using boost::spirit::karma::lower
;
81 using boost::spirit::karma::upper
;
83 symbols
<char, std::string
> sym
;
91 BOOST_TEST((test("joel", lower
[sym
], 'j')));
92 BOOST_TEST((test("hartmut", lower
[sym
], 'h')));
93 BOOST_TEST((test("tom", lower
[sym
], 't')));
94 BOOST_TEST((test("kim", lower
[sym
], 'k')));
96 BOOST_TEST((test("JOEL", upper
[sym
], 'j')));
97 BOOST_TEST((test("HARTMUT", upper
[sym
], 'h')));
98 BOOST_TEST((test("TOM", upper
[sym
], 't')));
99 BOOST_TEST((test("KIM", upper
[sym
], 'k')));
101 // make sure it plays well with other generators
102 BOOST_TEST((test("joelyo", lower
[sym
] << "yo", 'j')));
103 BOOST_TEST((test("JOELyo", upper
[sym
] << "yo", 'j')));
106 return boost::report_errors();