Fix gcc warnings from ICU wrappers.

Add optional support for marked sub-expression location information.
Add support for ${n} in format replacement text.
Fixes #2556.
Fixes #2269.
Fixes #2514.

[SVN r50370]
This commit is contained in:
John Maddock
2008-12-23 11:46:00 +00:00
parent c997a1fcc6
commit b4152cd74d
94 changed files with 1344 additions and 1068 deletions

View File

@ -471,6 +471,38 @@ void test(boost::basic_regex<charT, traits>& r, const test_regex_search_tag&)
test_regex_token_iterator(r);
test_regex_grep(r);
test_regex_match(r);
//
// Verify sub-expression locations:
//
if((syntax_options & boost::regbase::save_subexpression_location) == 0)
{
bool have_except = false;
try
{
r.subexpression(1);
}
catch(const std::out_of_range&)
{
have_except = true;
}
if(!have_except)
{
BOOST_REGEX_TEST_ERROR("Expected std::out_of_range error was not found.", charT);
}
}
r.assign(expression, syntax_options | boost::regbase::save_subexpression_location);
for(std::size_t i = 1; i < r.mark_count(); ++i)
{
std::pair<const charT*, const charT*> p = r.subexpression(i);
if(*p.first != '(')
{
BOOST_REGEX_TEST_ERROR("Starting location of sub-expression " << i << " iterator was invalid.", charT);
}
if(*p.second != ')')
{
BOOST_REGEX_TEST_ERROR("Ending location of sub-expression " << i << " iterator was invalid.", charT);
}
}
}
catch(const boost::bad_expression& e)
{

View File

@ -116,5 +116,15 @@ void test_replace()
TEST_REGEX_REPLACE("x", literal|icase, "xx", match_default|format_all, "a", "aa");
// literals:
TEST_REGEX_REPLACE("(a(c)?)|(b)", perl, "acab", match_default|format_literal, "\\&$", "\\&$\\&$\\&$");
// Bracketed sub expressions:
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default, "$", "...$,,,");
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default, "${", "...${,,,");
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default, "${2", "...${2,,,");
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default, "${23", "...${23,,,");
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default, "${d}", "...${d},,,");
TEST_REGEX_REPLACE("(a+)", perl, "...aaa,,,", match_default, "/${1}/", ".../aaa/,,,");
TEST_REGEX_REPLACE("(a+)", perl, "...aaa,,,", match_default, "/${10}/", "...//,,,");
TEST_REGEX_REPLACE("((((((((((a+))))))))))", perl, "...aaa,,,", match_default, "/${10}/", ".../aaa/,,,");
TEST_REGEX_REPLACE("(a+)", perl, "...aaa,,,", match_default, "/${1}0/", ".../aaa0/,,,");
}