Fixed remaining zero-width assertion issues.

Added separate file instantiation of ICU support templates.
Ensured code is STLport debug mode clean.


[SVN r30980]
This commit is contained in:
John Maddock
2005-09-14 12:20:41 +00:00
parent 90f4367b8d
commit 40b7a4902f
26 changed files with 358 additions and 112 deletions

View File

@ -41,13 +41,16 @@ void test_forward_lookahead_asserts()
TEST_REGEX_SEARCH("^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).{4,8}$", perl, "abC3", match_default, make_array(0, 4, -2, -2));
TEST_REGEX_SEARCH("^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).{4,8}$", perl, "ABCD3", match_default, make_array(-2, -2));
// bug report test cases:
TEST_REGEX_SEARCH("(?=.{1,10}$).*.", perl, "AAAAA", match_default, make_array(0, 5, -2, -2));
// lookbehind assertions, added 2004-04-30
TEST_REGEX_SEARCH("/\\*.*(?<=\\*)/", perl, "/**/", match_default, make_array(0, 4, -2, -2));
TEST_REGEX_SEARCH("/\\*.*(?<=\\*)/", perl, "/*****/ ", match_default, make_array(0, 7, -2, -2));
TEST_REGEX_SEARCH("(?<=['\"]).*?(?=['\"])", perl, " 'ac' ", match_default, make_array(2, 4, -2, -2));
TEST_REGEX_SEARCH("(?<=['\"]).*?(?=['\"])", perl, " \"ac\" ", match_default, make_array(2, 4, -2, -2));
TEST_REGEX_SEARCH("(?<=['\"]).*?(?<!\\\\)(?=['\"])", perl, " \"ac\" ", match_default, make_array(2, 4, -2, -2));
TEST_REGEX_SEARCH("(?<=['\"]).*?(?<!\\\\)(?=['\"])", perl, " \"ac\\\"\" ", match_default, make_array(2, 6, -2, -2));
TEST_REGEX_SEARCH("(?<=['\"]).*?(?<!\\\\)(?=['\"])", perl, " \"ac\\\" \" ", match_default, make_array(2, 7, -2, -2));
// lookbehind, with nested lookahead! :
TEST_REGEX_SEARCH("/\\*.*(?<=(?=[[:punct:]])\\*)/", perl, "/**/", match_default, make_array(0, 4, -2, -2));
TEST_REGEX_SEARCH("/\\*.*(?<=(?![[:alnum:]])\\*)/", perl, "/**/", match_default, make_array(0, 4, -2, -2));

View File

@ -15,6 +15,8 @@
#pragma warning(disable:4127)
#endif
void test_emacs2();
void test_emacs()
{
using namespace boost::regex_constants;
@ -132,6 +134,13 @@ void test_emacs()
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_emacs2();
}
void test_emacs2()
{
using namespace boost::regex_constants;
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));

View File

@ -53,5 +53,15 @@ void test_grep()
TEST_REGEX_SEARCH("a|\\Ab", perl, "b ab", match_default, make_array(0, 1, -2, 2, 3, -2, -2));
TEST_REGEX_SEARCH("a|^b", perl, "b ab\nb", match_default, make_array(0, 1, -2, 2, 3, -2, 5, 6, -2, -2));
TEST_REGEX_SEARCH("a|\\<b", perl, "b ab\nb", match_default, make_array(0, 1, -2, 2, 3, -2, 5, 6, -2, -2));
TEST_REGEX_SEARCH("\\Aabc", perl, "abcabc", match_default, make_array(0, 3, -2, -2));
TEST_REGEX_SEARCH("^abc", perl, "abcabc", match_default, make_array(0, 3, -2, -2));
TEST_REGEX_SEARCH("\\<abc", perl, "abcabc", match_default, make_array(0, 3, -2, -2));
TEST_REGEX_SEARCH("\\babc", perl, "abcabc", match_default, make_array(0, 3, -2, -2));
TEST_REGEX_SEARCH("(?<=\\Aabc)?abc", perl, "abcabc", match_default, make_array(0, 3, -2, 3, 6, -2, -2));
TEST_REGEX_SEARCH("(?<=^abc)?abc", perl, "abcabc", match_default, make_array(0, 3, -2, 3, 6, -2, -2));
TEST_REGEX_SEARCH("(?<=\\<abc)?abc", perl, "abcabc", match_default, make_array(0, 3, -2, 3, 6, -2, -2));
TEST_REGEX_SEARCH("(?<=\\babc)?abc", perl, "abcabc", match_default, make_array(0, 3, -2, 3, 6, -2, -2));
TEST_REGEX_SEARCH("(?<=^).{2}|(?<=^.{3}).{2}", perl, "123456789", match_default, make_array(0, 2, -2, 3, 5, -2, -2));
}

View File

@ -209,7 +209,10 @@ void test_icu(const wchar_t&, const test_regex_search_tag& )
#if !defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(__IBMCPP__)
r.assign(expression.begin(), expression.end(), syntax_options);
#else
r.assign(&*expression.begin(), expression.size(), syntax_options);
if(expression.size())
r.assign(&*expression.begin(), expression.size(), syntax_options);
else
r.assign(static_cast<UChar32 const*>(0), expression.size(), syntax_options);
#endif
if(r.status())
{
@ -379,7 +382,11 @@ void test_icu(const wchar_t&, const test_invalid_regex_tag&)
#if !defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(__IBMCPP__)
if(0 == r.assign(expression.begin(), expression.end(), syntax_options | boost::regex_constants::no_except).status())
#else
if(0 == r.assign(&*expression.begin(), expression.size(), syntax_options | boost::regex_constants::no_except).status())
if(expression.size())
r.assign(&*expression.begin(), expression.size(), syntax_options | boost::regex_constants::no_except);
else
r.assign(static_cast<UChar32 const*>(0), static_cast<boost::u32regex::size_type>(0), syntax_options | boost::regex_constants::no_except);
if(0 == r.status())
#endif
{
BOOST_REGEX_TEST_ERROR("Expression compiled when it should not have done so.", wchar_t);
@ -397,7 +404,10 @@ void test_icu(const wchar_t&, const test_invalid_regex_tag&)
#if !defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(__IBMCPP__)
r.assign(expression.begin(), expression.end(), syntax_options);
#else
r.assign(&*expression.begin(), expression.size(), syntax_options);
if(expression.size())
r.assign(&*expression.begin(), expression.size(), syntax_options);
else
r.assign(static_cast<UChar32 const*>(0), static_cast<boost::u32regex::size_type>(0), syntax_options);
#endif
#ifdef BOOST_NO_EXCEPTIONS
if(r.status())
@ -492,7 +502,10 @@ void test_icu(const wchar_t&, const test_regex_replace_tag&)
#if !defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(__IBMCPP__)
r.assign(expression.begin(), expression.end(), syntax_options);
#else
r.assign(&*expression.begin(), expression.size(), syntax_options);
if(expression.size())
r.assign(&*expression.begin(), expression.size(), syntax_options);
else
r.assign(static_cast<UChar32 const*>(0), static_cast<boost::u32regex::size_type>(0), syntax_options);
#endif
if(r.status())
{
@ -552,10 +565,13 @@ void test_icu(const wchar_t&, const test_regex_replace_tag&)
// Now with UnicodeString:
//
UnicodeString expression16u, text16u, format16u, result16u, found16u;
expression16u.setTo(&*expression16.begin(), expression16.size());
text16u.setTo(&*text16.begin(), text16.size());
if(expression16.size())
expression16u.setTo(&*expression16.begin(), expression16.size());
if(text16.size())
text16u.setTo(&*text16.begin(), text16.size());
format16u.setTo(&*format16.begin(), format16.size()-1);
result16u.setTo(&*result16.begin(), result16.size());
if(result16.size())
result16u.setTo(&*result16.begin(), result16.size());
r = boost::make_u32regex(expression16.begin(), expression16.end(), syntax_options);
found16u = boost::u32regex_replace(text16u, r, format16u, opts);
if(result16u != found16u)
@ -589,10 +605,13 @@ void test_icu(const wchar_t&, const test_regex_replace_tag&)
// Now with std::string and UTF-8:
//
std::string expression8s, text8s, format8s, result8s, found8s;
expression8s.assign(&*expression8.begin(), expression8.size());
text8s.assign(&*text8.begin(), text8.size());
if(expression8.size())
expression8s.assign(&*expression8.begin(), expression8.size());
if(text8.size())
text8s.assign(&*text8.begin(), text8.size());
format8s.assign(&*format8.begin(), format8.size()-1);
result8s.assign(&*result8.begin(), result8.size());
if(result8.size())
result8s.assign(&*result8.begin(), result8.size());
r = boost::make_u32regex(expression8.begin(), expression8.end(), syntax_options);
found8s = boost::u32regex_replace(text8s, r, format8s, opts);
if(result8s != found8s)

View File

@ -15,6 +15,8 @@
#pragma warning(disable:4127)
#endif
void test_options3();
void test_independent_subs()
{
using namespace boost::regex_constants;
@ -258,6 +260,13 @@ void test_options2()
TEST_REGEX_SEARCH("(?<=a(?i)b)(\\w\\w)c", perl, "ABxxc", match_default, make_array(-2, -2));
TEST_REGEX_SEARCH("(?<=a(?i)b)(\\w\\w)c", perl, "abxxC", match_default, make_array(-2, -2));
TEST_REGEX_SEARCH("(?<=^.{4})(?:bar|cat)", perl, "fooocat", match_default, make_array(4, 7, -2, -2));
TEST_REGEX_SEARCH("(?<=^.{4})(?:bar|cat)", perl, "foocat", match_default, make_array(-2, -2));
TEST_REGEX_SEARCH("(?<=^a{4})(?:bar|cat)", perl, "aaaacat", match_default, make_array(4, 7, -2, -2));
TEST_REGEX_SEARCH("(?<=^a{4})(?:bar|cat)", perl, "aaacat", match_default, make_array(-2, -2));
TEST_REGEX_SEARCH("(?<=^[[:alpha:]]{4})(?:bar|cat)", perl, "aaaacat", match_default, make_array(4, 7, -2, -2));
TEST_REGEX_SEARCH("(?<=^[[:alpha:]]{4})(?:bar|cat)", perl, "aaacat", match_default, make_array(-2, -2));
TEST_REGEX_SEARCH("(?<=ab(?i)x(?-i)y|(?i)z|b)ZZ", perl, "abxyZZ", match_default, make_array(4, 6, -2, -2));
TEST_REGEX_SEARCH("(?<=ab(?i)x(?-i)y|(?i)z|b)ZZ", perl, "abXyZZ", match_default, make_array(4, 6, -2, -2));
TEST_REGEX_SEARCH("(?:ab(?i)x(?-i)y|(?i)z|b)ZZ", perl, "ZZZ", match_default, make_array(0, 3, -2, -2));
@ -315,6 +324,12 @@ void test_options2()
TEST_REGEX_SEARCH("(?s).", perl, "\n", match_default|match_not_dot_newline, make_array(0, 1, -2, -2));
TEST_REGEX_SEARCH("(?-s).", perl, "\n", match_default, make_array(-2, -2));
TEST_REGEX_SEARCH("(?-s).", perl, "\n", match_default|match_not_dot_newline, make_array(-2, -2));
test_options3();
}
void test_options3()
{
using namespace boost::regex_constants;
TEST_REGEX_SEARCH(".+", perl, " \n ", match_default, make_array(0, 5, -2, -2));
TEST_REGEX_SEARCH(".+", perl, " \n ", match_default|match_not_dot_newline, make_array(0, 2, -2, 3, 5, -2, -2));

View File

@ -15,6 +15,8 @@
#pragma warning(disable:4127)
#endif
void test_simple_repeats2();
void test_simple_repeats()
{
using namespace boost::regex_constants;
@ -111,6 +113,11 @@ void test_simple_repeats()
TEST_REGEX_SEARCH("^a{0,1}?$", perl, "aaaaa", match_default, make_array(-2, -2));
TEST_REGEX_SEARCH("^(?:a){0,1}?$", perl, "aaaaa", match_default, make_array(-2, -2));
TEST_REGEX_SEARCH("^a(?:bc)?", perl, "abcbc", match_any|match_all, make_array(-2, -2));
}
void test_simple_repeats2()
{
using namespace boost::regex_constants;
TEST_INVALID_REGEX("a{}", perl);
TEST_INVALID_REGEX("a{", perl);