Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r60184 - in trunk/libs/spirit/test: . qi
From: joel_at_[hidden]
Date: 2010-03-05 08:30:36


Author: djowel
Date: 2010-03-05 08:30:35 EST (Fri, 05 Mar 2010)
New Revision: 60184
URL: http://svn.boost.org/trac/boost/changeset/60184

Log:
encoding directive
Added:
   trunk/libs/spirit/test/qi/encoding.cpp (contents, props changed)
Text files modified:
   trunk/libs/spirit/test/Jamfile | 3 ++-
   1 files changed, 2 insertions(+), 1 deletions(-)

Modified: trunk/libs/spirit/test/Jamfile
==============================================================================
--- trunk/libs/spirit/test/Jamfile (original)
+++ trunk/libs/spirit/test/Jamfile 2010-03-05 08:30:35 EST (Fri, 05 Mar 2010)
@@ -38,6 +38,7 @@
     [ run qi/char_class.cpp : : : : ]
     #[ run qi/debug.cpp : : : : ]
     [ run qi/difference.cpp : : : : ]
+ [ run qi/encoding.cpp : : : : ]
     [ run qi/end.cpp : : : : ]
     [ run qi/eps.cpp : : : : ]
     [ run qi/expect.cpp : : : : ]
@@ -144,7 +145,7 @@
     [ compile support/multi_pass_regression001.cpp : : support_multi_pass_regression001 ]
     [ compile support/multi_pass_regression002.cpp : : support_multi_pass_regression002 ]
     [ compile support/multi_pass_regression003.cpp : : support_multi_pass_regression003 ]
-
+
 
     # regression tests
     [ run qi/clear_test.cpp : : : : ]

Added: trunk/libs/spirit/test/qi/encoding.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/qi/encoding.cpp 2010-03-05 08:30:35 EST (Fri, 05 Mar 2010)
@@ -0,0 +1,208 @@
+/*=============================================================================
+ Copyright (c) 2001-2010 Joel de Guzman
+ http://spirit.sourceforge.net/
+
+ 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)
+=============================================================================*/
+
+// this file intentionally contains non-ascii characters
+// boostinspect:noascii
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/spirit/include/qi_char.hpp>
+#include <boost/spirit/include/qi_string.hpp>
+#include <boost/spirit/include/qi_directive.hpp>
+#include <boost/spirit/include/qi_action.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;
+ using spirit_test::test_attr;
+ using boost::spirit::qi::lit;
+ using boost::spirit::qi::no_case;
+ using boost::spirit::qi::char_;
+ boost::spirit::iso8859_1::encoding_type iso8859_1;
+
+// needed for VC7.1 only
+#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
+#pragma setlocale("french")
+#endif
+
+ {
+ BOOST_TEST(test("Á", iso8859_1[no_case['á']]));
+ BOOST_TEST(test("Á", iso8859_1[no_case[char_('á')]]));
+ }
+
+ {
+ BOOST_TEST(test("É", iso8859_1[no_case[char_("å-ï")]]));
+ BOOST_TEST(!test("ÿ", iso8859_1[no_case[char_("å-ï")]]));
+ }
+
+ {
+ BOOST_TEST(test("Áá", iso8859_1[no_case["áÁ"]]));
+ BOOST_TEST(test("Áá", iso8859_1[no_case[lit("áÁ")]]));
+ }
+
+
+#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
+#pragma setlocale("")
+#endif
+
+
+
+ //~ {
+ //~ using namespace boost::spirit::ascii;
+ //~ BOOST_TEST(test("X", no_case['x']));
+ //~ BOOST_TEST(test("X", no_case['X']));
+ //~ BOOST_TEST(test("x", no_case['X']));
+ //~ BOOST_TEST(test("x", no_case['x']));
+ //~ BOOST_TEST(!test("z", no_case['X']));
+ //~ BOOST_TEST(!test("z", no_case['x']));
+ //~ }
+
+//~ // needed for VC7.1 only
+//~ #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
+//~ #pragma setlocale("french")
+//~ #endif
+ //~ {
+ //~ using namespace boost::spirit::iso8859_1;
+ //~ BOOST_TEST(test("Á", no_case[char_('á')]));
+ //~ }
+
+ //~ {
+ //~ using namespace boost::spirit::iso8859_1;
+ //~ BOOST_TEST(test("X", no_case[char_("a-z")]));
+ //~ BOOST_TEST(!test("1", no_case[char_("a-z")]));
+
+ //~ BOOST_TEST(test("É", no_case[char_("å-ï")]));
+ //~ BOOST_TEST(!test("ÿ", no_case[char_("å-ï")]));
+ //~ }
+//~ #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
+//~ #pragma setlocale("")
+//~ #endif
+
+ //~ {
+ //~ using namespace boost::spirit::ascii;
+ //~ BOOST_TEST(test("Bochi Bochi", no_case[lit("bochi bochi")]));
+ //~ BOOST_TEST(test("BOCHI BOCHI", no_case[lit("bochi bochi")]));
+ //~ BOOST_TEST(!test("Vavoo", no_case[lit("bochi bochi")]));
+ //~ }
+
+//~ #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
+//~ #pragma setlocale("french")
+//~ #endif
+ //~ {
+ //~ using namespace boost::spirit::iso8859_1;
+ //~ BOOST_TEST(test("Áá", no_case[lit("áÁ")]));
+ //~ BOOST_TEST(test("áá", no_case[no_case[lit("áÁ")]]));
+ //~ }
+//~ #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
+//~ #pragma setlocale("")
+//~ #endif
+
+ //~ {
+ //~ // should work!
+ //~ using namespace boost::spirit::ascii;
+ //~ BOOST_TEST(test("x", no_case[no_case[char_]]));
+ //~ BOOST_TEST(test("x", no_case[no_case[char_('x')]]));
+ //~ BOOST_TEST(test("yabadabadoo", no_case[no_case[lit("Yabadabadoo")]]));
+ //~ }
+
+ //~ {
+ //~ using namespace boost::spirit::ascii;
+ //~ BOOST_TEST(test("X", no_case[alnum]));
+ //~ BOOST_TEST(test("6", no_case[alnum]));
+ //~ BOOST_TEST(!test(":", no_case[alnum]));
+
+ //~ BOOST_TEST(test("X", no_case[lower]));
+ //~ BOOST_TEST(test("x", no_case[lower]));
+ //~ BOOST_TEST(test("X", no_case[upper]));
+ //~ BOOST_TEST(test("x", no_case[upper]));
+ //~ BOOST_TEST(!test(":", no_case[lower]));
+ //~ BOOST_TEST(!test(":", no_case[upper]));
+ //~ }
+
+ //~ {
+ //~ using namespace boost::spirit::iso8859_1;
+ //~ BOOST_TEST(test("X", no_case[alnum]));
+ //~ BOOST_TEST(test("6", no_case[alnum]));
+ //~ BOOST_TEST(!test(":", no_case[alnum]));
+
+ //~ BOOST_TEST(test("X", no_case[lower]));
+ //~ BOOST_TEST(test("x", no_case[lower]));
+ //~ BOOST_TEST(test("X", no_case[upper]));
+ //~ BOOST_TEST(test("x", no_case[upper]));
+ //~ BOOST_TEST(!test(":", no_case[lower]));
+ //~ BOOST_TEST(!test(":", no_case[upper]));
+ //~ }
+
+ //~ {
+ //~ using namespace boost::spirit::standard;
+ //~ BOOST_TEST(test("X", no_case[alnum]));
+ //~ BOOST_TEST(test("6", no_case[alnum]));
+ //~ BOOST_TEST(!test(":", no_case[alnum]));
+
+ //~ BOOST_TEST(test("X", no_case[lower]));
+ //~ BOOST_TEST(test("x", no_case[lower]));
+ //~ BOOST_TEST(test("X", no_case[upper]));
+ //~ BOOST_TEST(test("x", no_case[upper]));
+ //~ BOOST_TEST(!test(":", no_case[lower]));
+ //~ BOOST_TEST(!test(":", no_case[upper]));
+ //~ }
+
+ //~ {
+ //~ // chsets
+ //~ namespace standard = boost::spirit::standard;
+ //~ namespace standard_wide = boost::spirit::standard_wide;
+
+ //~ BOOST_TEST(test("x", standard::no_case[standard::char_("a-z")]));
+ //~ BOOST_TEST(test("X", standard::no_case[standard::char_("a-z")]));
+ //~ BOOST_TEST(test(L"X", standard_wide::no_case[standard_wide::char_(L"a-z")]));
+ //~ BOOST_TEST(test(L"X", standard_wide::no_case[standard_wide::char_(L"X")]));
+ //~ }
+
+ //~ {
+ //~ using namespace boost::spirit::standard;
+ //~ std::string s("bochi bochi");
+ //~ BOOST_TEST(test("Bochi Bochi", no_case[lit(s.c_str())]));
+ //~ BOOST_TEST(test("Bochi Bochi", no_case[lit(s)]));
+ //~ BOOST_TEST(test("Bochi Bochi", no_case[s.c_str()]));
+ //~ BOOST_TEST(test("Bochi Bochi", no_case[s]));
+ //~ }
+
+ //~ { // lazy no_case chars
+
+ //~ using namespace boost::spirit::ascii;
+
+ //~ using boost::phoenix::val;
+ //~ using boost::phoenix::ref;
+ //~ using boost::spirit::_1;
+
+ //~ BOOST_TEST((test("X", no_case[val('x')])));
+ //~ BOOST_TEST((test("h", no_case[char_(val('a'), val('n'))])));
+ //~ BOOST_TEST(test("0", no_case[char_(val("a-z0-9"))]));
+
+ //~ char ch; // make sure lazy chars have an attribute
+ //~ BOOST_TEST(test("x", no_case[char_(val('x'))][ref(ch) = _1]));
+ //~ BOOST_TEST(ch == 'x');
+ //~ }
+
+ //~ { // lazy no_case lits
+
+ //~ using namespace boost::spirit::ascii;
+ //~ using boost::phoenix::val;
+
+ //~ BOOST_TEST(test("Bochi Bochi", no_case[val("bochi bochi")]));
+ //~ BOOST_TEST(test("BOCHI BOCHI", no_case[val("bochi bochi")]));
+ //~ BOOST_TEST(!test("Vavoo", no_case[val("bochi bochi")]));
+ //~ }
+
+ return boost::report_errors();
+}


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk