forked from boostorg/regex
Started to improve docs.
Added more tests. Added code to speed up traits class construction and usage. Tweeked extern template code. [SVN r25002]
This commit is contained in:
@@ -14,6 +14,7 @@ test_anchors.cpp
|
||||
test_asserts.cpp
|
||||
test_backrefs.cpp
|
||||
test_deprecated.cpp
|
||||
test_emacs.cpp
|
||||
test_escapes.cpp
|
||||
test_grep.cpp
|
||||
test_locale.cpp
|
||||
@@ -163,3 +164,4 @@ test-suite regex
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2004
|
||||
* Dr John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to 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)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* LOCATION: see http://www.boost.org for most recent version.
|
||||
* FILE object_cache_test.cpp
|
||||
* VERSION see <boost/version.hpp>
|
||||
* DESCRIPTION: Test code for a generic object cache.
|
||||
*/
|
||||
#include <boost/regex/pending/object_cache.hpp>
|
||||
#include <boost/test/included/test_exec_monitor.hpp>
|
||||
|
||||
class test_object
|
||||
{
|
||||
public:
|
||||
test_object(int i)
|
||||
: m_value(i)
|
||||
{
|
||||
++s_count;
|
||||
}
|
||||
int value()const
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
static int count()
|
||||
{
|
||||
return s_count;
|
||||
}
|
||||
private:
|
||||
int m_value;
|
||||
static int s_count;
|
||||
};
|
||||
|
||||
int test_object::s_count = 0;
|
||||
|
||||
static const int max_cache_size = 5;
|
||||
|
||||
int test_main(int /*argc*/, char * /*argv*/[])
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < 20; ++i)
|
||||
{
|
||||
boost::shared_ptr<test_object> p = boost::object_cache<int, test_object>::get(i, max_cache_size);
|
||||
BOOST_TEST(p->value() == i);
|
||||
p = boost::object_cache<int, test_object>::get(i, max_cache_size);
|
||||
BOOST_TEST(p->value() == i);
|
||||
if(i)
|
||||
{
|
||||
p = boost::object_cache<int, test_object>::get(i-1, max_cache_size);
|
||||
BOOST_TEST(p->value() == i-1);
|
||||
}
|
||||
}
|
||||
int current_count = test_object::count();
|
||||
for(int j = 0; j < 10; ++j)
|
||||
{
|
||||
for(i = 20 - max_cache_size; i < 20; ++i)
|
||||
{
|
||||
boost::shared_ptr<test_object> p = boost::object_cache<int, test_object>::get(i, max_cache_size);
|
||||
BOOST_TEST(p->value() == i);
|
||||
p = boost::object_cache<int, test_object>::get(i, max_cache_size);
|
||||
BOOST_TEST(p->value() == i);
|
||||
}
|
||||
}
|
||||
BOOST_TEST(current_count == test_object::count());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,9 @@ int cpp_main(int /*argc*/, char * /*argv*/[])
|
||||
test_options();
|
||||
test_options2();
|
||||
test_en_locale();
|
||||
test_emacs();
|
||||
test_operators();
|
||||
test_overloads();
|
||||
return error_count;
|
||||
}
|
||||
|
||||
|
||||
@@ -208,5 +208,8 @@ void test_conditionals();
|
||||
void test_options();
|
||||
void test_options2();
|
||||
void test_en_locale();
|
||||
void test_emacs();
|
||||
void test_operators();
|
||||
void test_overloads();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 2004
|
||||
* Dr John Maddock
|
||||
*
|
||||
* Use, modification and distribution are subject to 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)
|
||||
*
|
||||
*/
|
||||
|
||||
#include "test.hpp"
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(disable:4127)
|
||||
#endif
|
||||
|
||||
void test_emacs()
|
||||
{
|
||||
using namespace boost::regex_constants;
|
||||
// now try operator + :
|
||||
TEST_REGEX_SEARCH("ab+", emacs, "a", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("ab+", emacs, "ab", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab+", emacs, "sssabbbbbbsss", match_default, make_array(3, 10, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab+c+", emacs, "abbb", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("ab+c+", emacs, "accc", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("ab+c+", emacs, "abbcc", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_INVALID_REGEX("\\<+", emacs);
|
||||
TEST_INVALID_REGEX("\\>+", emacs);
|
||||
TEST_REGEX_SEARCH("\n+", emacs, "\n\n", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\+", emacs, "+", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\+", emacs, "++", match_default, make_array(0, 1, -2, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\++", emacs, "++", match_default, make_array(0, 2, -2, -2));
|
||||
|
||||
// now try operator ?
|
||||
TEST_REGEX_SEARCH("a?", emacs, "b", match_default, make_array(0, 0, -2, 1, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab?", emacs, "a", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab?", emacs, "ab", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab?", emacs, "sssabbbbbbsss", match_default, make_array(3, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab?c?", emacs, "a", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab?c?", emacs, "abbb", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab?c?", emacs, "accc", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab?c?", emacs, "abcc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_INVALID_REGEX("\\<?", emacs);
|
||||
TEST_INVALID_REGEX("\\>?", emacs);
|
||||
TEST_REGEX_SEARCH("\n?", emacs, "\n\n", match_default, make_array(0, 1, -2, 1, 2, -2, 2, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\?", emacs, "?", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\?", emacs, "?", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\??", emacs, "??", match_default, make_array(0, 1, -2, 1, 2, -2, 2, 2, -2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("a*?", emacs, "aa", match_default, make_array(0, 0, -2, 0, 1, -2, 1, 1, -2, 1, 2, -2, 2, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("^a*?$", emacs, "aa", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("^.*?$", emacs, "aa", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("^\\(a\\)*?$", emacs, "aa", match_default, make_array(0, 2, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("^[ab]*?$", emacs, "aa", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a??", emacs, "aa", match_default, make_array(0, 0, -2, 0, 1, -2, 1, 1, -2, 1, 2, -2, 2, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a+?", emacs, "aa", match_default, make_array(0, 1, -2, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\{1,3\\}?", emacs, "aaa", match_default, make_array(0, 1, -2, 1, 2, -2, 2, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\w+?w", emacs, "...ccccccwcccccw", match_default, make_array(3, 10, -2, 10, 16, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\W+\\w+?w", emacs, "...ccccccwcccccw", match_default, make_array(0, 10, -2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\|\\w+?", emacs, "abd", match_default, make_array(0, 1, -2, 1, 2, -2, 2, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\|\\w+?", emacs, "abcd", match_default, make_array(0, 3, -2, 3, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("<\\ss*tag[^>]*>\\(.*?\\)<\\ss*/tag\\ss*>", emacs, " <tag>here is some text</tag> <tag></tag>", match_default, make_array(1, 29, 6, 23, -2, 30, 41, 35, 35, -2, -2));
|
||||
TEST_REGEX_SEARCH("<\\ss*tag[^>]*>\\(.*?\\)<\\ss*/tag\\ss*>", emacs, " < tag attr=\"something\">here is some text< /tag > <tag></tag>", match_default, make_array(1, 49, 24, 41, -2, 50, 61, 55, 55, -2, -2));
|
||||
TEST_INVALID_REGEX("a\\{1,3\\}\\{1\\}", emacs);
|
||||
TEST_INVALID_REGEX("a**", emacs);
|
||||
TEST_INVALID_REGEX("a++", emacs);
|
||||
|
||||
TEST_REGEX_SEARCH("\\<abcd", emacs, " abcd", match_default, make_array(2, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\<ab", emacs, "cab", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("\\<ab", emacs, "\nab", match_default, make_array(1, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\<tag", emacs, "::tag", match_default, make_array(2, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\<abcd", emacs, "abcd", match_default|match_not_bow, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("\\<abcd", emacs, " abcd", match_default|match_not_bow, make_array(2, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\<", emacs, "ab ", match_default|match_not_bow, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH(".\\<.", emacs, "ab", match_default|match_not_bow, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH(".\\<.", emacs, " b", match_default|match_not_bow, make_array(0, 2, -2, -2));
|
||||
// word end:
|
||||
TEST_REGEX_SEARCH("abc\\>", emacs, "abc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\>", emacs, "abcd", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\>", emacs, "abc\n", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\>", emacs, "abc::", match_default, make_array(0,3, -2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\(?:\\>..\\|$\\)", emacs, "abc::", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\>", emacs, " ", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH(".\\>.", emacs, " ", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\>", emacs, "abc", match_default|match_not_eow, make_array(-2, -2));
|
||||
// word boundary:
|
||||
TEST_REGEX_SEARCH("\\babcd", emacs, " abcd", match_default, make_array(2, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\bab", emacs, "cab", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("\\bab", emacs, "\nab", match_default, make_array(1, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\btag", emacs, "::tag", match_default, make_array(2, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\b", emacs, "abc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\b", emacs, "abcd", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\b", emacs, "abc\n", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\b", emacs, "abc::", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\babcd", emacs, "abcd", match_default|match_not_bow, make_array(-2, -2));
|
||||
// within word:
|
||||
TEST_REGEX_SEARCH("\\B", emacs, "ab", match_default, make_array(1, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\Bb", emacs, "ab", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\B", emacs, "ab", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\B", emacs, "a", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("a\\B", emacs, "a ", match_default, make_array(-2, -2));
|
||||
// buffer operators:
|
||||
TEST_REGEX_SEARCH("\\`abc", emacs, "abc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\`abc", emacs, "\nabc", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("\\`abc", emacs, " abc", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\'", emacs, "abc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\'", emacs, "abc\n", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\'", emacs, "abc ", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("a\\|b", emacs, "a", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\|b", emacs, "b", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\|b\\|c", emacs, "c", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\|\\(b\\)\\|.", emacs, "b", match_default, make_array(0, 1, 0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\(a\\)\\|b\\|.", emacs, "a", match_default, make_array(0, 1, 0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\(b\\|c\\)", emacs, "ab", match_default, make_array(0, 2, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\(b\\|c\\)", emacs, "ac", match_default, make_array(0, 2, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\(b\\|c\\)", emacs, "ad", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("\\(a\\|b\\|c\\)", emacs, "c", match_default, make_array(0, 1, 0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\(a\\|\\(b\\)\\|.\\)", emacs, "b", match_default, make_array(0, 1, 0, 1, 0, 1, -2, -2));
|
||||
TEST_INVALID_REGEX("\\|c", emacs);
|
||||
TEST_INVALID_REGEX("c\\|", emacs);
|
||||
TEST_INVALID_REGEX("\\(\\|\\)", emacs);
|
||||
TEST_INVALID_REGEX("\\(a\\|\\)", emacs);
|
||||
TEST_INVALID_REGEX("\\(\\|a\\)", emacs);
|
||||
|
||||
TEST_REGEX_SEARCH("\\(?:abc\\)+", emacs, "xxabcabcxx", match_default, make_array(2, 8, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\(?:a+\\)\\(b+\\)", emacs, "xaaabbbx", match_default, make_array(1, 7, 4, 7, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\(a+\\)\\(?:b+\\)", emacs, "xaaabbba", match_default, make_array(1, 7, 1, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\(?:\\(a+\\)b+\\)", emacs, "xaaabbba", match_default, make_array(1, 7, 1, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\(?:a+\\(b+\\)\\)", emacs, "xaaabbba", match_default, make_array(1, 7, 4, 7, -2, -2));
|
||||
TEST_REGEX_SEARCH("a+\\(?#b+\\)b+", emacs, "xaaabbba", match_default, make_array(1, 7, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\(a\\)\\(?:b\\|$\\)", emacs, "ab", match_default, make_array(0, 2, 0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\(a\\)\\(?:b\\|$\\)", emacs, "a", match_default, make_array(0, 1, 0, 1, -2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("\\ss+", emacs, "a b", match_default, make_array(1, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\Ss+", emacs, " ab ", match_default, make_array(1, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\sw+", emacs, " ab ", match_default, make_array(1, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\Sw+", emacs, "a b", match_default, make_array(1, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\s_+", emacs, " $&*+-_<> ", match_default, make_array(1, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\S_+", emacs, "$&*+-_<>b", match_default, make_array(8, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\s.+", emacs, " .,;!? ", match_default, make_array(1, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\S.+", emacs, ".,;!?b", match_default, make_array(5, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\s(+", emacs, "([{ ", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\S(+", emacs, "([{ ", match_default, make_array(3, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\s)+", emacs, ")]} ", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\S)+", emacs, ")]} ", match_default, make_array(3, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\s\"+", emacs, "\"'` ", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\S\"+", emacs, "\"'` ", match_default, make_array(3, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\s'+", emacs, "',# ", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\S'+", emacs, "',# ", match_default, make_array(3, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\s<+", emacs, "; ", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\S<+", emacs, "; ", match_default, make_array(1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\s>+", emacs, "\n\f ", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\S>+", emacs, "\n\f ", match_default, make_array(2, 3, -2, -2));
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
//
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if (defined(BOOST_MSVC) || defined(__ICL)) && (_MSC_VER >= 1300)
|
||||
#if (defined(BOOST_MSVC) || defined(__ICL)) && (_MSC_VER >= 1300) && (_MSC_VER < 1400)
|
||||
# define TEST_MFC
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
|
||||
#include "test.hpp"
|
||||
|
||||
template <class T1, class T2>
|
||||
void test_less(const T1& t1, const T2& t2)
|
||||
{
|
||||
if(!(t1 < t2))
|
||||
{
|
||||
BOOST_REGEX_TEST_ERROR("Failed < comparison", char);
|
||||
}
|
||||
if(!(t1 <= t2))
|
||||
{
|
||||
BOOST_REGEX_TEST_ERROR("Failed <= comparison", char);
|
||||
}
|
||||
if(!(t1 != t2))
|
||||
{
|
||||
BOOST_REGEX_TEST_ERROR("Failed != comparison", char);
|
||||
}
|
||||
if(t1 == t2)
|
||||
{
|
||||
BOOST_REGEX_TEST_ERROR("Failed == comparison", char);
|
||||
}
|
||||
if(t1 >= t2)
|
||||
{
|
||||
BOOST_REGEX_TEST_ERROR("Failed >= comparison", char);
|
||||
}
|
||||
if(t1 > t2)
|
||||
{
|
||||
BOOST_REGEX_TEST_ERROR("Failed > comparison", char);
|
||||
}
|
||||
}
|
||||
|
||||
template <class T1, class T2>
|
||||
void test_greater(const T1& t1, const T2& t2)
|
||||
{
|
||||
if(t1 < t2)
|
||||
{
|
||||
BOOST_REGEX_TEST_ERROR("Failed < comparison", char);
|
||||
}
|
||||
if(t1 <= t2)
|
||||
{
|
||||
BOOST_REGEX_TEST_ERROR("Failed <= comparison", char);
|
||||
}
|
||||
if(!(t1 != t2))
|
||||
{
|
||||
BOOST_REGEX_TEST_ERROR("Failed != comparison", char);
|
||||
}
|
||||
if(t1 == t2)
|
||||
{
|
||||
BOOST_REGEX_TEST_ERROR("Failed == comparison", char);
|
||||
}
|
||||
if(!(t1 >= t2))
|
||||
{
|
||||
BOOST_REGEX_TEST_ERROR("Failed >= comparison", char);
|
||||
}
|
||||
if(!(t1 > t2))
|
||||
{
|
||||
BOOST_REGEX_TEST_ERROR("Failed > comparison", char);
|
||||
}
|
||||
}
|
||||
|
||||
template <class T1, class T2>
|
||||
void test_equal(const T1& t1, const T2& t2)
|
||||
{
|
||||
if(t1 < t2)
|
||||
{
|
||||
BOOST_REGEX_TEST_ERROR("Failed < comparison", char);
|
||||
}
|
||||
if(!(t1 <= t2))
|
||||
{
|
||||
BOOST_REGEX_TEST_ERROR("Failed <= comparison", char);
|
||||
}
|
||||
if(t1 != t2)
|
||||
{
|
||||
BOOST_REGEX_TEST_ERROR("Failed != comparison", char);
|
||||
}
|
||||
if(!(t1 == t2))
|
||||
{
|
||||
BOOST_REGEX_TEST_ERROR("Failed == comparison", char);
|
||||
}
|
||||
if(!(t1 >= t2))
|
||||
{
|
||||
BOOST_REGEX_TEST_ERROR("Failed >= comparison", char);
|
||||
}
|
||||
if(t1 > t2)
|
||||
{
|
||||
BOOST_REGEX_TEST_ERROR("Failed > comparison", char);
|
||||
}
|
||||
}
|
||||
|
||||
template <class T1, class T2, class T3>
|
||||
void test_plus(const T1& t1, const T2& t2, const T3& t3)
|
||||
{
|
||||
if(t1 + t2 != t3)
|
||||
{
|
||||
BOOST_REGEX_TEST_ERROR("Failed addition", char);
|
||||
}
|
||||
if(t3 != t1 + t2)
|
||||
{
|
||||
BOOST_REGEX_TEST_ERROR("Failed addition", char);
|
||||
}
|
||||
}
|
||||
|
||||
void test_operators()
|
||||
{
|
||||
test_info<char>::set_typename("sub_match operators");
|
||||
|
||||
std::string s1("a");
|
||||
std::string s2("b");
|
||||
boost::sub_match<std::string::const_iterator> sub1, sub2;
|
||||
sub1.first = s1.begin();
|
||||
sub1.second = s1.end();
|
||||
sub1.matched = true;
|
||||
sub2.first = s2.begin();
|
||||
sub2.second = s2.end();
|
||||
sub2.matched = true;
|
||||
|
||||
test_less(sub1, sub2);
|
||||
test_less(sub1, s2.c_str());
|
||||
test_less(s1.c_str(), sub2);
|
||||
test_less(sub1, *s2.c_str());
|
||||
test_less(*s1.c_str(), sub2);
|
||||
test_less(sub1, s2);
|
||||
//test_less(s1, sub2);
|
||||
test_greater(sub2, sub1);
|
||||
test_greater(sub2, s1.c_str());
|
||||
test_greater(s2.c_str(), sub1);
|
||||
test_greater(sub2, *s1.c_str());
|
||||
test_greater(*s2.c_str(), sub1);
|
||||
test_greater(sub2, s1);
|
||||
//test_greater(s2, sub1);
|
||||
test_equal(sub1, sub1);
|
||||
test_equal(sub1, s1.c_str());
|
||||
test_equal(s1.c_str(), sub1);
|
||||
test_equal(sub1, *s1.c_str());
|
||||
test_equal(*s1.c_str(), sub1);
|
||||
test_equal(sub1, s1);
|
||||
//test_equal(s1, sub1);
|
||||
test_plus(sub2, sub1, "ba");
|
||||
test_plus(sub2, s1.c_str(), "ba");
|
||||
test_plus(s2.c_str(), sub1, "ba");
|
||||
test_plus(sub2, *s1.c_str(), "ba");
|
||||
test_plus(*s2.c_str(), sub1, "ba");
|
||||
test_plus(sub2, s1, "ba");
|
||||
//test_plus(s2, sub1, "ba");
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
|
||||
#include "test.hpp"
|
||||
|
||||
#define BOOST_REGEX_TEST(x)\
|
||||
if(!(x)){ BOOST_REGEX_TEST_ERROR("Error in: " BOOST_STRINGIZE(x), char); }
|
||||
|
||||
void test_overloads()
|
||||
{
|
||||
test_info<char>::set_typename("sub_match operators");
|
||||
|
||||
// test all the available overloads with *one* simple
|
||||
// expression, doing all these tests with all the test
|
||||
// cases would just take to long...
|
||||
|
||||
boost::regex e("abc");
|
||||
std::string s("abc");
|
||||
const std::string& cs = s;
|
||||
boost::smatch sm;
|
||||
boost::cmatch cm;
|
||||
// regex_match:
|
||||
BOOST_REGEX_TEST(boost::regex_match(cs.begin(), cs.end(), sm, e))
|
||||
BOOST_REGEX_TEST(boost::regex_match(cs.begin(), cs.end(), sm, e, boost::regex_constants::match_default))
|
||||
BOOST_REGEX_TEST(boost::regex_match(cs.begin(), cs.end(), e))
|
||||
BOOST_REGEX_TEST(boost::regex_match(cs.begin(), cs.end(), e, boost::regex_constants::match_default))
|
||||
BOOST_REGEX_TEST(boost::regex_match(s.c_str(), cm, e))
|
||||
BOOST_REGEX_TEST(boost::regex_match(s.c_str(), cm, e, boost::regex_constants::match_default))
|
||||
BOOST_REGEX_TEST(boost::regex_match(s.c_str(), e))
|
||||
BOOST_REGEX_TEST(boost::regex_match(s.c_str(), e, boost::regex_constants::match_default))
|
||||
BOOST_REGEX_TEST(boost::regex_match(s, sm, e))
|
||||
BOOST_REGEX_TEST(boost::regex_match(s, sm, e, boost::regex_constants::match_default))
|
||||
BOOST_REGEX_TEST(boost::regex_match(s, e))
|
||||
BOOST_REGEX_TEST(boost::regex_match(s, e, boost::regex_constants::match_default))
|
||||
// regex_search:
|
||||
BOOST_REGEX_TEST(boost::regex_search(cs.begin(), cs.end(), sm, e))
|
||||
BOOST_REGEX_TEST(boost::regex_search(cs.begin(), cs.end(), sm, e, boost::regex_constants::match_default))
|
||||
BOOST_REGEX_TEST(boost::regex_search(cs.begin(), cs.end(), e))
|
||||
BOOST_REGEX_TEST(boost::regex_search(cs.begin(), cs.end(), e, boost::regex_constants::match_default))
|
||||
BOOST_REGEX_TEST(boost::regex_search(s.c_str(), cm, e))
|
||||
BOOST_REGEX_TEST(boost::regex_search(s.c_str(), cm, e, boost::regex_constants::match_default))
|
||||
BOOST_REGEX_TEST(boost::regex_search(s.c_str(), e))
|
||||
BOOST_REGEX_TEST(boost::regex_search(s.c_str(), e, boost::regex_constants::match_default))
|
||||
BOOST_REGEX_TEST(boost::regex_search(s, sm, e))
|
||||
BOOST_REGEX_TEST(boost::regex_search(s, sm, e, boost::regex_constants::match_default))
|
||||
BOOST_REGEX_TEST(boost::regex_search(s, e))
|
||||
BOOST_REGEX_TEST(boost::regex_search(s, e, boost::regex_constants::match_default))
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/regex/static_mutex.hpp>
|
||||
#include <boost/regex/pending/static_mutex.hpp>
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <boost/timer.hpp>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user