Update of /cvsroot/boost/boost/libs/xpressive/test
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv23448/libs/xpressive/test
Modified Files:
test_non_char.cpp
Log Message:
hooray, non-char data works\!
Index: test_non_char.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/xpressive/test/test_non_char.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- test_non_char.cpp 22 Oct 2006 03:28:00 -0000 1.4
+++ test_non_char.cpp 30 May 2007 19:40:15 -0000 1.5
@@ -6,13 +6,13 @@
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <algorithm>
+#include <boost/xpressive/xpressive.hpp>
#include <boost/xpressive/traits/null_regex_traits.hpp>
#include "./test.hpp"
///////////////////////////////////////////////////////////////////////////////
-// test_main
-// read the tests from the input file and execute them
-void test_main()
+// test_static
+void test_static()
{
static int const data[] = {0, 1, 2, 3, 4, 5, 6};
null_regex_traits<int> nul;
@@ -31,12 +31,65 @@
}
///////////////////////////////////////////////////////////////////////////////
+// UChar
+struct UChar
+{
+ UChar(unsigned int code = 0)
+ : code_(code)
+ {}
+
+ operator unsigned int () const
+ {
+ return this->code_;
+ }
+
+private:
+ unsigned int code_;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// UChar_traits
+struct UChar_traits
+ : null_regex_traits<UChar>
+{};
+
+///////////////////////////////////////////////////////////////////////////////
+// test_dynamic
+void test_dynamic()
+{
+ typedef std::vector<UChar>::const_iterator uchar_iterator;
+ typedef basic_regex<uchar_iterator> uregex;
+ typedef match_results<uchar_iterator> umatch;
+ typedef regex_compiler<uchar_iterator, UChar_traits> uregex_compiler;
+
+ std::string pattern_("b.*r"), str_("foobarboo");
+ std::vector<UChar> pattern(pattern_.begin(), pattern_.end());
+ std::vector<UChar> str(str_.begin(), str_.end());
+
+ UChar_traits tr;
+ uregex_compiler compiler(tr);
+ uregex urx = compiler.compile(pattern);
+ umatch what;
+
+ if(!regex_search(str, what, urx))
+ {
+ BOOST_ERROR("regex_search on UChar failed");
+ }
+ else
+ {
+ BOOST_CHECK_EQUAL(3, what.position());
+ BOOST_CHECK_EQUAL(3, what.length());
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////
// init_unit_test_suite
//
test_suite* init_unit_test_suite( int argc, char* argv[] )
{
test_suite *test = BOOST_TEST_SUITE("test_non_char");
- test->add(BOOST_TEST_CASE(&test_main));
+ test->add(BOOST_TEST_CASE(&test_static));
+ test->add(BOOST_TEST_CASE(&test_dynamic));
return test;
}
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs