]>
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_auxiliary.hpp>
7 #include <boost/spirit/include/karma_char.hpp>
8 #include <boost/spirit/include/karma_string.hpp>
9 #include <boost/spirit/include/karma_operator.hpp>
10 #include <boost/spirit/include/karma_directive.hpp>
11 #include <boost/spirit/include/karma_generate.hpp>
12 #include <boost/spirit/include/karma_nonterminal.hpp>
14 #include <boost/core/lightweight_test.hpp>
15 #include <boost/core/lightweight_test_trait.hpp>
19 namespace fusion
= boost::fusion
;
23 make_vector(T
const& t1
, T
const& t2
)
33 using spirit_test::test
;
34 using boost::spirit::karma::symbols
;
37 symbols
<char, std::string
> sym
;
46 BOOST_TEST_TRAIT_TRUE((
47 boost::spirit::traits::is_generator
<
48 symbols
<char, std::string
> >));
50 BOOST_TEST((test("Joel", sym
, 'j')));
51 BOOST_TEST((test("Hartmut", sym
, 'h')));
52 BOOST_TEST((test("Tom", sym
, 't')));
53 BOOST_TEST((test("Kim", sym
, 'k')));
54 BOOST_TEST((!test("", sym
, 'x')));
57 symbols
<char, std::string
> sym2
;
59 BOOST_TEST((test("Joel", sym2
, 'j')));
60 BOOST_TEST((test("Hartmut", sym2
, 'h')));
61 BOOST_TEST((test("Tom", sym2
, 't')));
62 BOOST_TEST((test("Kim", sym2
, 'k')));
63 BOOST_TEST((!test("", sym2
, 'x')));
65 // make sure it plays well with other generators
66 BOOST_TEST((test("Joelyo", sym
<< "yo", 'j')));
73 BOOST_TEST((!test("", sym
, 'j')));
74 BOOST_TEST((!test("", sym
, 'h')));
77 { // lower/upper handling
78 using namespace boost::spirit::ascii
;
79 using boost::spirit::karma::lower
;
80 using boost::spirit::karma::upper
;
82 symbols
<char, std::string
> sym
;
90 BOOST_TEST((test("joel", lower
[sym
], 'j')));
91 BOOST_TEST((test("hartmut", lower
[sym
], 'h')));
92 BOOST_TEST((test("tom", lower
[sym
], 't')));
93 BOOST_TEST((test("kim", lower
[sym
], 'k')));
95 BOOST_TEST((test("JOEL", upper
[sym
], 'j')));
96 BOOST_TEST((test("HARTMUT", upper
[sym
], 'h')));
97 BOOST_TEST((test("TOM", upper
[sym
], 't')));
98 BOOST_TEST((test("KIM", upper
[sym
], 'k')));
100 // make sure it plays well with other generators
101 BOOST_TEST((test("joelyo", lower
[sym
] << "yo", 'j')));
102 BOOST_TEST((test("JOELyo", upper
[sym
] << "yo", 'j')));
105 return boost::report_errors();