forked from boostorg/regex
Added tests for locales.
[SVN r24113]
This commit is contained in:
@ -429,9 +429,11 @@ re_syntax_base* basic_regex_creator<charT, traits>::append_set(
|
||||
return 0;
|
||||
}
|
||||
charT* p = static_cast<charT*>(this->m_pdata->m_data.extend(sizeof(charT) * (s1.size() + s2.size() + 2) ) );
|
||||
std::memcpy(p, &*s1.begin(), sizeof(charT) * (s1.size() + 1));
|
||||
std::copy(s1.begin(), s1.end(), p);
|
||||
p[s1.size()] = charT(0);
|
||||
p += s1.size() + 1;
|
||||
std::memcpy(p, &*s2.begin(), sizeof(charT) * (s2.size() + 1));
|
||||
std::copy(s2.begin(), s2.end(), p);
|
||||
p[s2.size()] = charT(0);
|
||||
}
|
||||
//
|
||||
// now process the equivalence classes:
|
||||
@ -451,7 +453,8 @@ re_syntax_base* basic_regex_creator<charT, traits>::append_set(
|
||||
if(s.empty())
|
||||
return 0; // invalid or unsupported equivalence class
|
||||
charT* p = static_cast<charT*>(this->m_pdata->m_data.extend(sizeof(charT) * (s.size()+1) ) );
|
||||
std::memcpy(p, &*s.begin(), sizeof(charT) * (s.size() + 1));
|
||||
std::copy(s.begin(), s.end(), p);
|
||||
p[s.size()] = charT(0);
|
||||
++first;
|
||||
}
|
||||
//
|
||||
@ -691,9 +694,12 @@ void basic_regex_creator<charT, traits>::create_startmaps(re_syntax_base* state)
|
||||
// Oops error:
|
||||
if(0 == this->m_pdata->m_status) // update the error code if not already set
|
||||
this->m_pdata->m_status = boost::regex_constants::error_brack;
|
||||
std::string message = this->m_pdata->m_ptraits->error_string(boost::regex_constants::error_brack);
|
||||
boost::regex_error e(message, boost::regex_constants::error_brack, 0);
|
||||
e.raise();
|
||||
if(0 == (this->flags() & regex_constants::no_except))
|
||||
{
|
||||
std::string message = this->m_pdata->m_ptraits->error_string(boost::regex_constants::error_brack);
|
||||
boost::regex_error e(message, boost::regex_constants::error_brack, 0);
|
||||
e.raise();
|
||||
}
|
||||
}
|
||||
// fall through:
|
||||
default:
|
||||
|
@ -81,17 +81,17 @@ basic_regex_parser<charT, traits>::basic_regex_parser(regex_data<charT, traits>*
|
||||
template <class charT, class traits>
|
||||
void basic_regex_parser<charT, traits>::parse(const charT* p1, const charT* p2, unsigned flags)
|
||||
{
|
||||
// pass flags on to base class:
|
||||
this->init(flags);
|
||||
// set up pointers:
|
||||
m_position = m_base = p1;
|
||||
m_end = p2;
|
||||
// empty strings are errors:
|
||||
if(p1 == p2)
|
||||
{
|
||||
fail(regex_constants::error_empty, 0);
|
||||
return;
|
||||
}
|
||||
// pass flags on to base class:
|
||||
this->init(flags);
|
||||
// set up pointers:
|
||||
m_position = m_base = p1;
|
||||
m_end = p2;
|
||||
// select which parser to use:
|
||||
switch(flags & regbase::main_option_type)
|
||||
{
|
||||
@ -134,8 +134,13 @@ void basic_regex_parser<charT, traits>::fail(regex_constants::error_type error_c
|
||||
// get the error message:
|
||||
std::string message = this->m_pdata->m_ptraits->error_string(error_code);
|
||||
// and raise the exception, this will do nothing if exceptions are disabled:
|
||||
boost::regex_error e(message, error_code, position);
|
||||
e.raise();
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
if(0 == (this->flags() & regex_constants::no_except))
|
||||
{
|
||||
boost::regex_error e(message, error_code, position);
|
||||
e.raise();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class charT, class traits>
|
||||
|
@ -158,7 +158,9 @@ struct cpp_regex_traits_base
|
||||
|
||||
std::locale m_locale;
|
||||
std::ctype<charT> const* m_pctype;
|
||||
#ifndef BOOST_NO_STD_MESSAGES
|
||||
std::messages<charT> const* m_pmessages;
|
||||
#endif
|
||||
std::collate<charT> const* m_pcollate;
|
||||
};
|
||||
|
||||
@ -168,7 +170,9 @@ std::locale cpp_regex_traits_base<charT>::imbue(const std::locale& l)
|
||||
std::locale result(m_locale);
|
||||
m_locale = l;
|
||||
m_pctype = &BOOST_USE_FACET(std::ctype<charT>, l);
|
||||
#ifndef BOOST_NO_STD_MESSAGES
|
||||
m_pmessages = &BOOST_USE_FACET(std::messages<charT>, l);
|
||||
#endif
|
||||
m_pcollate = &BOOST_USE_FACET(std::collate<charT>, l);
|
||||
return result;
|
||||
}
|
||||
@ -215,6 +219,7 @@ cpp_regex_traits_char_layer<charT>::cpp_regex_traits_char_layer(const std::local
|
||||
{
|
||||
// we need to start by initialising our syntax map so we know which
|
||||
// character is used for which purpose:
|
||||
#ifndef BOOST_NO_STD_MESSAGES
|
||||
#ifndef __IBMCPP__
|
||||
typename std::messages<charT>::catalog cat = static_cast<std::messages<char>::catalog>(-1);
|
||||
#else
|
||||
@ -257,6 +262,7 @@ cpp_regex_traits_char_layer<charT>::cpp_regex_traits_char_layer(const std::local
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif
|
||||
for(regex_constants::syntax_type i = 1; i < regex_constants::syntax_max; ++i)
|
||||
{
|
||||
const char* ptr = get_default_syntax(i);
|
||||
@ -266,7 +272,9 @@ cpp_regex_traits_char_layer<charT>::cpp_regex_traits_char_layer(const std::local
|
||||
++ptr;
|
||||
}
|
||||
}
|
||||
#ifndef BOOST_NO_STD_MESSAGES
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class charT>
|
||||
@ -425,39 +433,48 @@ typename cpp_regex_traits_implementation<charT>::string_type
|
||||
{
|
||||
string_type result;
|
||||
//
|
||||
// What we do here depends upon the format of the sort key returned by
|
||||
// sort key returned by this->transform:
|
||||
// swallowing all exceptions here is a bad idea
|
||||
// however at least one std lib will always throw
|
||||
// std::bad_alloc for certain arguments...
|
||||
//
|
||||
switch(m_collate_type)
|
||||
{
|
||||
case sort_C:
|
||||
case sort_unknown:
|
||||
// the best we can do is translate to lower case, then get a regular sort key:
|
||||
try{
|
||||
//
|
||||
// What we do here depends upon the format of the sort key returned by
|
||||
// sort key returned by this->transform:
|
||||
//
|
||||
switch(m_collate_type)
|
||||
{
|
||||
result.assign(p1, p2);
|
||||
this->m_pctype->tolower(&*result.begin(), &*result.begin() + result.size());
|
||||
result = this->m_pcollate->transform(&*result.begin(), &*result.begin() + result.size());
|
||||
break;
|
||||
}
|
||||
case sort_fixed:
|
||||
{
|
||||
// get a regular sort key, and then truncate it:
|
||||
result.assign(this->m_pcollate->transform(p1, p2));
|
||||
result.erase(this->m_collate_delim);
|
||||
break;
|
||||
}
|
||||
case sort_delim:
|
||||
// get a regular sort key, and then truncate everything after the delim:
|
||||
result.assign(this->m_pcollate->transform(p1, p2));
|
||||
std::size_t i;
|
||||
for(i = 0; i < result.size(); ++i)
|
||||
case sort_C:
|
||||
case sort_unknown:
|
||||
// the best we can do is translate to lower case, then get a regular sort key:
|
||||
{
|
||||
if(result[i] == m_collate_delim)
|
||||
break;
|
||||
result.assign(p1, p2);
|
||||
this->m_pctype->tolower(&*result.begin(), &*result.begin() + result.size());
|
||||
result = this->m_pcollate->transform(&*result.begin(), &*result.begin() + result.size());
|
||||
break;
|
||||
}
|
||||
result.erase(i);
|
||||
break;
|
||||
}
|
||||
case sort_fixed:
|
||||
{
|
||||
// get a regular sort key, and then truncate it:
|
||||
result.assign(this->m_pcollate->transform(p1, p2));
|
||||
result.erase(this->m_collate_delim);
|
||||
break;
|
||||
}
|
||||
case sort_delim:
|
||||
// get a regular sort key, and then truncate everything after the delim:
|
||||
result.assign(this->m_pcollate->transform(p1, p2));
|
||||
std::size_t i;
|
||||
for(i = 0; i < result.size(); ++i)
|
||||
{
|
||||
if(result[i] == m_collate_delim)
|
||||
break;
|
||||
}
|
||||
result.erase(i);
|
||||
break;
|
||||
}
|
||||
}catch(...){}
|
||||
while(result.size() && (charT(0) == *result.rbegin()))
|
||||
result.erase(result.size() - 1);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -509,6 +526,7 @@ template <class charT>
|
||||
cpp_regex_traits_implementation<charT>::cpp_regex_traits_implementation(const std::locale& l)
|
||||
: cpp_regex_traits_char_layer<charT>(l), m_is(&m_sbuf)
|
||||
{
|
||||
#ifndef BOOST_NO_STD_MESSAGES
|
||||
#ifndef __IBMCPP__
|
||||
typename std::messages<charT>::catalog cat = static_cast<std::messages<char>::catalog>(-1);
|
||||
#else
|
||||
@ -582,6 +600,7 @@ cpp_regex_traits_implementation<charT>::cpp_regex_traits_implementation(const st
|
||||
this->m_custom_class_names[s] = masks[j];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//
|
||||
// get the collation format used by m_pcollate:
|
||||
//
|
||||
@ -688,7 +707,23 @@ public:
|
||||
}
|
||||
string_type transform(const charT* p1, const charT* p2) const
|
||||
{
|
||||
return m_pimpl->m_pcollate->transform(p1, p2);
|
||||
//
|
||||
// swallowing all exceptions here is a bad idea
|
||||
// however at least one std lib will always throw
|
||||
// std::bad_alloc for certain arguments...
|
||||
//
|
||||
string_type result;
|
||||
try{
|
||||
result = m_pimpl->m_pcollate->transform(p1, p2);
|
||||
//
|
||||
// some implementations append unnecessary trailing \0's:
|
||||
while(result.size() && (charT(0) == *result.rbegin()))
|
||||
result.erase(result.size() - 1);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
}
|
||||
return result;
|
||||
}
|
||||
string_type transform_primary(const charT* p1, const charT* p2) const
|
||||
{
|
||||
|
@ -47,13 +47,14 @@ namespace boost{
|
||||
|
||||
c_regex_traits<char>::string_type BOOST_REGEX_CALL c_regex_traits<char>::transform(const char* p1, const char* p2)
|
||||
{
|
||||
std::size_t s = 10;
|
||||
std::string result(s, ' ');
|
||||
std::string result(10, ' ');
|
||||
std::size_t s = result.size();
|
||||
std::size_t r;
|
||||
std::string src(p1, p2);
|
||||
while(s < (r = std::strxfrm(&*result.begin(), src.c_str(), result.size())))
|
||||
while(s < (r = std::strxfrm(&*result.begin(), src.c_str(), s)))
|
||||
{
|
||||
result.append(r - s + 3, ' ');
|
||||
s = result.size();
|
||||
}
|
||||
result.erase(r);
|
||||
return result;
|
||||
|
@ -33,6 +33,7 @@ void cpp_regex_traits_char_layer<char>::init()
|
||||
// we need to start by initialising our syntax map so we know which
|
||||
// character is used for which purpose:
|
||||
std::memset(m_char_map, 0, sizeof(m_char_map));
|
||||
#ifndef BOOST_NO_STD_MESSAGES
|
||||
#ifndef __IBMCPP__
|
||||
std::messages<char>::catalog cat = static_cast<std::messages<char>::catalog>(-1);
|
||||
#else
|
||||
@ -75,6 +76,7 @@ void cpp_regex_traits_char_layer<char>::init()
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif
|
||||
for(regex_constants::syntax_type i = 1; i < regex_constants::syntax_max; ++i)
|
||||
{
|
||||
const char* ptr = get_default_syntax(i);
|
||||
@ -84,7 +86,9 @@ void cpp_regex_traits_char_layer<char>::init()
|
||||
++ptr;
|
||||
}
|
||||
}
|
||||
#ifndef BOOST_NO_STD_MESSAGES
|
||||
}
|
||||
#endif
|
||||
//
|
||||
// finish off by calculating our escape types:
|
||||
//
|
||||
|
@ -43,9 +43,10 @@ c_regex_traits<wchar_t>::string_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::t
|
||||
std::size_t s = 10;
|
||||
std::wstring src(p1, p2);
|
||||
std::wstring result(s, L' ');
|
||||
while(s < (r = std::wcsxfrm(&*result.begin(), src.c_str(), result.size())))
|
||||
while(s < (r = std::wcsxfrm(&*result.begin(), src.c_str(), s)))
|
||||
{
|
||||
result.append(r - s + 3, L' ');
|
||||
s = result.size();
|
||||
}
|
||||
result.erase(r);
|
||||
return result;
|
||||
|
28
test/Jamfile
28
test/Jamfile
@ -6,6 +6,25 @@ subproject libs/regex/test ;
|
||||
import testing ;
|
||||
subinclude libs/regex/test/captures ;
|
||||
|
||||
R_SOURCE =
|
||||
basic_tests.cpp
|
||||
main.cpp
|
||||
test_alt.cpp
|
||||
test_anchors.cpp
|
||||
test_asserts.cpp
|
||||
test_backrefs.cpp
|
||||
test_deprecated.cpp
|
||||
test_escapes.cpp
|
||||
test_grep.cpp
|
||||
test_locale.cpp
|
||||
test_non_greedy_repeats.cpp
|
||||
test_perl_ex.cpp
|
||||
test_replace.cpp
|
||||
test_sets.cpp
|
||||
test_simple_repeats.cpp
|
||||
test_tricky_cases.cpp
|
||||
;
|
||||
|
||||
#
|
||||
# this template defines the options common to
|
||||
# all regex tests:
|
||||
@ -22,9 +41,7 @@ template test
|
||||
#
|
||||
template regression
|
||||
: <template>test # sources
|
||||
regress/main.cpp
|
||||
regress/basic_tests.cpp
|
||||
regress/test_deprecated.cpp
|
||||
regress/$(R_SOURCE)
|
||||
<lib>../../test/build/boost_prg_exec_monitor
|
||||
;
|
||||
|
||||
@ -56,9 +73,7 @@ template test-dll
|
||||
#
|
||||
template regression-dll
|
||||
: <template>test-dll # sources
|
||||
regress/main.cpp
|
||||
regress/basic_tests.cpp
|
||||
regress/test_deprecated.cpp
|
||||
regress/$(R_SOURCE)
|
||||
<lib>../../test/build/boost_prg_exec_monitor
|
||||
;
|
||||
|
||||
@ -146,3 +161,4 @@ test-suite regex
|
||||
|
||||
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -43,6 +43,7 @@ private:
|
||||
string_type format_string;
|
||||
string_type result_string;
|
||||
bool need_to_print;
|
||||
std::string expression_type_name;
|
||||
};
|
||||
static data_type& data()
|
||||
{
|
||||
@ -74,6 +75,10 @@ public:
|
||||
dat.result_string = result_string;
|
||||
dat.need_to_print = true;
|
||||
}
|
||||
static void set_typename(const std::string& n)
|
||||
{
|
||||
data().expression_type_name = n;
|
||||
}
|
||||
|
||||
static const string_type& expression()
|
||||
{
|
||||
@ -119,6 +124,10 @@ public:
|
||||
{
|
||||
data().need_to_print = false;
|
||||
}
|
||||
static std::string& expression_typename()
|
||||
{
|
||||
return data().expression_type_name;
|
||||
}
|
||||
};
|
||||
|
||||
template <class charT>
|
||||
@ -139,7 +148,27 @@ extern int error_count;
|
||||
#define BOOST_REGEX_TEST_ERROR(msg, charT)\
|
||||
++error_count;\
|
||||
std::cerr << test_info<charT>();\
|
||||
std::cerr << " " << __FILE__ << ":" << __LINE__ << ":" << msg << std::endl
|
||||
std::cerr << " " << __FILE__ << ":" << __LINE__ << ":" << msg \
|
||||
<< " (While testing " << test_info<charT>::expression_typename() << ")" << std::endl
|
||||
|
||||
class errors_as_warnings
|
||||
{
|
||||
public:
|
||||
errors_as_warnings()
|
||||
{
|
||||
m_saved_error_count = error_count;
|
||||
}
|
||||
~errors_as_warnings()
|
||||
{
|
||||
if(m_saved_error_count != error_count)
|
||||
{
|
||||
std::cerr << "the above " << (error_count - m_saved_error_count) << " errors are treated as warnings only." << std::endl;
|
||||
error_count = m_saved_error_count;
|
||||
}
|
||||
}
|
||||
private:
|
||||
int m_saved_error_count;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "test.hpp"
|
||||
#include "test_locale.hpp"
|
||||
#include <stdarg.h>
|
||||
|
||||
int error_count = 0;
|
||||
@ -47,6 +48,7 @@ int cpp_main(int argc, char * argv[])
|
||||
test_conditionals();
|
||||
test_options();
|
||||
test_options2();
|
||||
test_en_locale();
|
||||
return error_count;
|
||||
}
|
||||
|
||||
|
@ -2,10 +2,12 @@
|
||||
|
||||
#ifndef BOOST_REGEX_REGRESS_TEST_HPP
|
||||
#define BOOST_REGEX_REGRESS_TEST_HPP
|
||||
#include <typeinfo>
|
||||
#include "test_not_regex.hpp"
|
||||
#include "test_regex_search.hpp"
|
||||
#include "test_regex_replace.hpp"
|
||||
#include "test_deprecated.hpp"
|
||||
#include "test_locale.hpp"
|
||||
|
||||
|
||||
//
|
||||
@ -16,19 +18,33 @@ template <class charT, class tagT>
|
||||
void test(const charT& c, const tagT& tag)
|
||||
{
|
||||
#ifndef BOOST_NO_STD_LOCALE
|
||||
test_info<charT>::set_typename(typeid(boost::basic_regex<charT, boost::cpp_regex_traits<charT> >).name());
|
||||
boost::basic_regex<charT, boost::cpp_regex_traits<charT> > e1;
|
||||
test(e1, tag);
|
||||
if(test_locale::cpp_locale_state() == test_locale::test_with_locale)
|
||||
e1.imbue(test_locale::cpp_locale());
|
||||
if(test_locale::cpp_locale_state() != test_locale::no_test)
|
||||
test(e1, tag);
|
||||
#endif
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, < 0x560)
|
||||
test_info<charT>::set_typename(typeid(boost::basic_regex<charT, boost::c_regex_traits<charT> >).name());
|
||||
boost::basic_regex<charT, boost::c_regex_traits<charT> > e2;
|
||||
test(e2, tag);
|
||||
if(test_locale::c_locale_state() != test_locale::no_test)
|
||||
test(e2, tag);
|
||||
#endif
|
||||
#if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32)
|
||||
test_info<charT>::set_typename(typeid(boost::basic_regex<charT, boost::w32_regex_traits<charT> >).name());
|
||||
boost::basic_regex<charT, boost::w32_regex_traits<charT> > e3;
|
||||
test(e3, tag);
|
||||
if(test_locale::win_locale_state() == test_locale::test_with_locale)
|
||||
e3.imbue(test_locale::win_locale());
|
||||
if(test_locale::win_locale_state() != test_locale::no_test)
|
||||
test(e3, tag);
|
||||
#endif
|
||||
// test old depecated code:
|
||||
test_deprecated(c, tag);
|
||||
test_info<charT>::set_typename("Deprecated interfaces");
|
||||
if((test_locale::win_locale_state() == test_locale::test_no_locale)
|
||||
&& (test_locale::c_locale_state() == test_locale::test_no_locale)
|
||||
&&(test_locale::cpp_locale_state() == test_locale::test_no_locale))
|
||||
test_deprecated(c, tag);
|
||||
}
|
||||
|
||||
//
|
||||
@ -161,5 +177,6 @@ void test_nosubs();
|
||||
void test_conditionals();
|
||||
void test_options();
|
||||
void test_options2();
|
||||
void test_en_locale();
|
||||
|
||||
#endif
|
||||
|
42
test/regress/test_alt.cpp
Normal file
42
test/regress/test_alt.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
*
|
||||
* 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"
|
||||
|
||||
void test_alt()
|
||||
{
|
||||
using namespace boost::regex_constants;
|
||||
// now test the alternation operator |
|
||||
TEST_REGEX_SEARCH("a|b", perl, "a", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a|b", perl, "b", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a|b|c", perl, "c", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a|(b)|.", perl, "b", match_default, make_array(0, 1, 0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("(a)|b|.", perl, "a", match_default, make_array(0, 1, 0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|c)", perl, "ab", match_default, make_array(0, 2, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|c)", perl, "ac", match_default, make_array(0, 2, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|c)", perl, "ad", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(a|b|c)", perl, "c", match_default, make_array(0, 1, 0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("(a|(b)|.)", perl, "b", match_default, make_array(0, 1, 0, 1, 0, 1, -2, -2));
|
||||
TEST_INVALID_REGEX("|c", perl);
|
||||
TEST_INVALID_REGEX("c|", perl);
|
||||
TEST_INVALID_REGEX("(|)", perl);
|
||||
TEST_INVALID_REGEX("(a|)", perl);
|
||||
TEST_INVALID_REGEX("(|a)", perl);
|
||||
TEST_REGEX_SEARCH("a\\|", perl, "a|", match_default, make_array(0, 2, -2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("a|", basic, "a|", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\|", basic, "a|", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("|", basic, "|", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a|", basic|bk_vbar, "a|", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\|b", basic|bk_vbar, "a", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\|b", basic|bk_vbar, "b", match_default, make_array(0, 1, -2, -2));
|
||||
}
|
||||
|
63
test/regress/test_anchors.cpp
Normal file
63
test/regress/test_anchors.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
*
|
||||
* 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"
|
||||
|
||||
void test_anchors()
|
||||
{
|
||||
// line anchors:
|
||||
using namespace boost::regex_constants;
|
||||
TEST_REGEX_SEARCH("^ab", extended, "ab", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("^ab", extended, "xxabxx", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("^ab", extended, "xx\nabzz", match_default, make_array(3, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab$", extended, "ab", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab$", extended, "abxx", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("ab$", extended, "ab\nzz", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("^ab", extended, "\n\n a", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("^ab", basic, "ab", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("^ab", basic, "xxabxx", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("^ab", basic, "xx\nabzz", match_default, make_array(3, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab$", basic, "ab", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab$", basic, "abxx", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("ab$", basic, "ab\nzz", match_default, make_array(0, 2, -2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("^ab", extended, "ab", match_default | match_not_bol | match_not_eol, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("^ab", extended, "xxabxx", match_default | match_not_bol | match_not_eol, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("^ab", extended, "xx\nabzz", match_default | match_not_bol | match_not_eol, make_array(3, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab$", extended, "ab", match_default | match_not_bol | match_not_eol, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("ab$", extended, "abxx", match_default | match_not_bol | match_not_eol, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("ab$", extended, "ab\nzz", match_default | match_not_bol | match_not_eol, make_array(0, 2, -2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("^ab", extended, "ab", match_default | match_single_line, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("^ab", extended, "xxabxx", match_default | match_single_line, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("^ab", extended, "xx\nabzz", match_default | match_single_line, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("ab$", extended, "ab", match_default | match_single_line, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab$", extended, "abxx", match_default | match_single_line, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("ab$", extended, "ab\nzz", match_default | match_single_line, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("^ab", extended, "ab", match_default | match_not_bol | match_not_eol | match_single_line, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("^ab", extended, "xxabxx", match_default | match_not_bol | match_not_eol | match_single_line, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("^ab", extended, "xx\nabzz", match_default | match_not_bol | match_not_eol | match_single_line, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("ab$", extended, "ab", match_default | match_not_bol | match_not_eol | match_single_line, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("ab$", extended, "abxx", match_default | match_not_bol | match_not_eol | match_single_line, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("ab$", extended, "ab\nzz", match_default | match_not_bol | match_not_eol | match_single_line, make_array(-2, -2));
|
||||
//
|
||||
// changes to newline handling with 2.11:
|
||||
//
|
||||
TEST_REGEX_SEARCH("^.", extended, " \n \r\n ", match_default, make_array(0, 1, -2, 3, 4, -2, 7, 8, -2, -2));
|
||||
TEST_REGEX_SEARCH(".$", extended, " \n \r\n ", match_default, make_array(1, 2, -2, 4, 5, -2, 8, 9, -2, -2));
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, < 0x560)
|
||||
TEST_REGEX_SEARCH_W(L"^.", extended, L"\x2028 \x2028", match_default, make_array(0, 1, -2, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH_W(L".$", extended, L" \x2028 \x2028", match_default, make_array(0, 1, -2, 2, 3, -2, 3, 4, -2, -2));
|
||||
#endif
|
||||
}
|
||||
|
65
test/regress/test_asserts.cpp
Normal file
65
test/regress/test_asserts.cpp
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
*
|
||||
* 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"
|
||||
|
||||
void test_forward_lookahead_asserts()
|
||||
{
|
||||
//
|
||||
// forward lookahead asserts added 21/01/02
|
||||
//
|
||||
using namespace boost::regex_constants;
|
||||
TEST_REGEX_SEARCH("((?:(?!a|b)\\w)+)(\\w+)", perl, " xxxabaxxx ", match_default, make_array(2, 11, 2, 5, 5, 11, -2, -2));
|
||||
TEST_REGEX_SEARCH("/\\*(?:(?!\\*/).)*\\*/", perl, " /**/ ", match_default, make_array(2, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("/\\*(?:(?!\\*/).)*\\*/", perl, " /***/ ", match_default, make_array(2, 7, -2, -2));
|
||||
TEST_REGEX_SEARCH("/\\*(?:(?!\\*/).)*\\*/", perl, " /********/ ", match_default, make_array(2, 12, -2, -2));
|
||||
TEST_REGEX_SEARCH("/\\*(?:(?!\\*/).)*\\*/", perl, " /* comment */ ", match_default, make_array(2, 15, -2, -2));
|
||||
TEST_REGEX_SEARCH("<\\s*a[^>]*>((?:(?!<\\s*/\\s*a\\s*>).)*)<\\s*/\\s*a\\s*>", perl, " <a href=\"here\">here</a> ", match_default, make_array(1, 24, 16, 20, -2, -2));
|
||||
TEST_REGEX_SEARCH("<\\s*a[^>]*>((?:(?!<\\s*/\\s*a\\s*>).)*)<\\s*/\\s*a\\s*>", perl, " <a href=\"here\">here< / a > ", match_default, make_array(1, 28, 16, 20, -2, -2));
|
||||
TEST_REGEX_SEARCH("<\\s*a[^>]*>((?:(?!<\\s*/\\s*a\\s*>).)*)(?=<\\s*/\\s*a\\s*>)", perl, " <a href=\"here\">here</a> ", match_default, make_array(1, 20, 16, 20, -2, -2));
|
||||
TEST_REGEX_SEARCH("<\\s*a[^>]*>((?:(?!<\\s*/\\s*a\\s*>).)*)(?=<\\s*/\\s*a\\s*>)", perl, " <a href=\"here\">here< / a > ", match_default, make_array(1, 20, 16, 20, -2, -2));
|
||||
TEST_REGEX_SEARCH("^(?!^(?:PRN|AUX|CLOCK\\$|NUL|CON|COM\\d|LPT\\d|\\..*)(?:\\..+)?$)[^\\x00-\\x1f\\\\?*:\"|/]+$", perl, "command.com", match_default, make_array(0, 11, -2, -2));
|
||||
TEST_REGEX_SEARCH("^(?!^(?:PRN|AUX|CLOCK\\$|NUL|CON|COM\\d|LPT\\d|\\..*)(?:\\..+)?$)[^\\x00-\\x1f\\\\?*:\"|/]+$", perl, "PRN", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("^(?!^(?:PRN|AUX|CLOCK\\$|NUL|CON|COM\\d|LPT\\d|\\..*)(?:\\..+)?$)[^\\x00-\\x1f\\\\?*:\"|/]+$", perl, "COM2", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("^(?=.*\\d).{4,8}$", perl, "abc3", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("^(?=.*\\d).{4,8}$", perl, "abc3def4", match_default, make_array(0, 8, -2, -2));
|
||||
TEST_REGEX_SEARCH("^(?=.*\\d).{4,8}$", perl, "ab2", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("^(?=.*\\d).{4,8}$", perl, "abcdefg", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).{4,8}$", perl, "abc3", match_default, make_array(-2, -2));
|
||||
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));
|
||||
|
||||
// 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));
|
||||
// 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));
|
||||
TEST_REGEX_SEARCH("/\\*.*(?<=(?>\\*))/", perl, "/**/", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("/\\*.*(?<=(?:\\*))/", perl, "/**/", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("/\\*.*(?<=(\\*))/", perl, "/**/", match_default, make_array(0, 4, 2, 3, -2, -2));
|
||||
// lookbehind with invalid content:
|
||||
TEST_INVALID_REGEX("(/)\\*.*(?<=\\1)/", perl);
|
||||
TEST_INVALID_REGEX("/\\*.*(?<=\\*+)/", perl);
|
||||
TEST_INVALID_REGEX("/\\*.*(?<=\\X)/", perl);
|
||||
TEST_INVALID_REGEX("/\\*.*(?<=[[.ae.]])/", perl);
|
||||
|
||||
TEST_INVALID_REGEX("(?<=[abc]", perl);
|
||||
TEST_INVALID_REGEX("(?<=", perl);
|
||||
TEST_INVALID_REGEX("(?<", perl);
|
||||
TEST_INVALID_REGEX("(?<*", perl);
|
||||
TEST_INVALID_REGEX("(?", perl);
|
||||
}
|
||||
|
39
test/regress/test_backrefs.cpp
Normal file
39
test/regress/test_backrefs.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
*
|
||||
* 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"
|
||||
|
||||
void test_backrefs()
|
||||
{
|
||||
using namespace boost::regex_constants;
|
||||
TEST_INVALID_REGEX("a(b)\\2c", perl);
|
||||
TEST_INVALID_REGEX("a(b\\1)c", perl);
|
||||
TEST_REGEX_SEARCH("a(b*)c\\1d", perl, "abbcbbd", match_default, make_array(0, 7, 1, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b*)c\\1d", perl, "abbcbd", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("a(b*)c\\1d", perl, "abbcbbbd", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("^(.)\\1", perl, "abc", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("a([bc])\\1d", perl, "abcdabbd", match_default, make_array(4, 8, 5, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\([bc]\\)\\1d", basic, "abcdabbd", match_default, make_array(4, 8, 5, 6, -2, -2));
|
||||
// strictly speaking this is at best ambiguous, at worst wrong, this is what most
|
||||
// re implimentations will match though.
|
||||
TEST_REGEX_SEARCH("a(([bc])\\2)*d", perl, "abbccd", match_default, make_array(0, 6, 3, 5, 3, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(([bc])\\2)*d", perl, "abbcbd", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("a((b)*\\2)*d", perl, "abbbd", match_default, make_array(0, 5, 1, 4, 2, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("(ab*)[ab]*\\1", perl, "ababaaa", match_default, make_array(0, 4, 0, 2, -2, 4, 7, 4, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("(a)\\1bcd", perl, "aabcd", match_default, make_array(0, 5, 0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("(a)\\1bc*d", perl, "aabcd", match_default, make_array(0, 5, 0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("(a)\\1bc*d", perl, "aabd", match_default, make_array(0, 4, 0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("(a)\\1bc*d", perl, "aabcccd", match_default, make_array(0, 7, 0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("(a)\\1bc*[ce]d", perl, "aabcccd", match_default, make_array(0, 7, 0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("^(a)\\1b(c)*cd$", perl, "aabcccd", match_default, make_array(0, 7, 0, 1, 4, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("(ab*)[ab]*\\1", extended, "ababaaa", match_default, make_array(0, 7, 0, 1, -2, -2));
|
||||
}
|
||||
|
141
test/regress/test_escapes.cpp
Normal file
141
test/regress/test_escapes.cpp
Normal file
@ -0,0 +1,141 @@
|
||||
/*
|
||||
*
|
||||
* 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"
|
||||
|
||||
void test_character_escapes()
|
||||
{
|
||||
using namespace boost::regex_constants;
|
||||
// characters by code
|
||||
TEST_REGEX_SEARCH("\\0101", perl, "A", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\00", perl, "\0", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\0", perl, "\0", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\0172", perl, "z", match_default, make_array(0, 1, -2, -2));
|
||||
// extra escape sequences:
|
||||
TEST_REGEX_SEARCH("\\a", perl, "\a", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\f", perl, "\f", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\n", perl, "\n", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\r", perl, "\r", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\v", perl, "\v", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\t", perl, "\t", match_default, make_array(0, 1, -2, -2));
|
||||
|
||||
// updated tests for version 2:
|
||||
TEST_REGEX_SEARCH("\\x41", perl, "A", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\xff", perl, "\xff", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\xFF", perl, "\xff", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\c@", perl, "\0", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\cA", perl, "\x1", match_default, make_array(0, 1, -2, -2));
|
||||
//TEST_REGEX_SEARCH("\\cz", perl, "\x3A", match_default, make_array(0, 1, -2, -2));
|
||||
//TEST_INVALID_REGEX("\\c=", extended);
|
||||
//TEST_INVALID_REGEX("\\c?", extended);
|
||||
TEST_REGEX_SEARCH("=:", perl, "=:", match_default, make_array(0, 2, -2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("\\e", perl, "\x1B", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\x1b", perl, "\x1B", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\x{1b}", perl, "\x1B", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_INVALID_REGEX("\\x{}", perl);
|
||||
TEST_INVALID_REGEX("\\x{", perl);
|
||||
TEST_INVALID_REGEX("\\", perl);
|
||||
TEST_INVALID_REGEX("\\c", perl);
|
||||
TEST_INVALID_REGEX("\\x}", perl);
|
||||
TEST_INVALID_REGEX("\\x", perl);
|
||||
TEST_INVALID_REGEX("\\x{yy", perl);
|
||||
TEST_INVALID_REGEX("\\x{1b", perl);
|
||||
// \Q...\E sequences:
|
||||
TEST_INVALID_REGEX("\\Qabc\\", perl);
|
||||
TEST_REGEX_SEARCH("\\Qabc\\E", perl, "abcd", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\Qabc\\Ed", perl, "abcde", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\Q+*?\\\\E", perl, "+*?\\", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\Q+*?\\\\Eb", perl, "a+*?\\b", match_default, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\C+", perl, "abcde", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\X+", perl, "abcde", match_default, make_array(0, 5, -2, -2));
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, < 0x560)
|
||||
TEST_REGEX_SEARCH_W(L"\\X", perl, L"a\x0300\x0301", match_default, make_array(0, 3, -2, -2));
|
||||
#endif
|
||||
// unknown escape sequences match themselves:
|
||||
TEST_REGEX_SEARCH("\\~", perl, "~", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\~", basic, "~", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\~", extended, "~", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\j", extended, "j", match_default, make_array(0, 1, -2, -2));
|
||||
}
|
||||
|
||||
void test_assertion_escapes()
|
||||
{
|
||||
using namespace boost::regex_constants;
|
||||
// word start:
|
||||
TEST_REGEX_SEARCH("\\<abcd", perl, " abcd", match_default, make_array(2, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\<ab", perl, "cab", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("\\<ab", perl, "\nab", match_default, make_array(1, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\<tag", perl, "::tag", match_default, make_array(2, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\<abcd", perl, "abcd", match_default|match_not_bow, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("\\<abcd", perl, " abcd", match_default|match_not_bow, make_array(2, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\<", perl, "ab ", match_default|match_not_bow, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH(".\\<.", perl, "ab", match_default|match_not_bow, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH(".\\<.", perl, " b", match_default|match_not_bow, make_array(0, 2, -2, -2));
|
||||
// word end:
|
||||
TEST_REGEX_SEARCH("abc\\>", perl, "abc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\>", perl, "abcd", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\>", perl, "abc\n", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\>", perl, "abc::", match_default, make_array(0,3, -2, -2));
|
||||
TEST_REGEX_SEARCH("abc(?:\\>..|$)", perl, "abc::", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\>", perl, " ", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH(".\\>.", perl, " ", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\>", perl, "abc", match_default|match_not_eow, make_array(-2, -2));
|
||||
// word boundary:
|
||||
TEST_REGEX_SEARCH("\\babcd", perl, " abcd", match_default, make_array(2, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\bab", perl, "cab", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("\\bab", perl, "\nab", match_default, make_array(1, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\btag", perl, "::tag", match_default, make_array(2, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\b", perl, "abc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\b", perl, "abcd", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\b", perl, "abc\n", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\b", perl, "abc::", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\babcd", perl, "abcd", match_default|match_not_bow, make_array(-2, -2));
|
||||
// within word:
|
||||
TEST_REGEX_SEARCH("\\B", perl, "ab", match_default, make_array(1, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\Bb", perl, "ab", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\B", perl, "ab", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\B", perl, "a", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("a\\B", perl, "a ", match_default, make_array(-2, -2));
|
||||
// buffer operators:
|
||||
TEST_REGEX_SEARCH("\\`abc", perl, "abc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\`abc", perl, "\nabc", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("\\`abc", perl, " abc", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\'", perl, "abc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\'", perl, "abc\n", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\'", perl, "abc ", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("abc(?:\\'|$)", perl, "abc", match_default, make_array(0, 3, -2, -2));
|
||||
|
||||
// word start:
|
||||
TEST_REGEX_SEARCH("[[:<:]]abcd", perl, " abcd", match_default, make_array(2, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[:<:]]ab", perl, "cab", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("[[:<:]]ab", perl, "\nab", match_default, make_array(1, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[:<:]]tag", perl, "::tag", match_default, make_array(2, 5, -2, -2));
|
||||
// word end
|
||||
TEST_REGEX_SEARCH("abc[[:>:]]", perl, "abc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("abc[[:>:]]", perl, "abcd", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("abc[[:>:]]", perl, "abc\n", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("abc[[:>:]]", perl, "abc::", match_default, make_array(0, 3, -2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("\\Aabc", perl, "abc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\Aabc", perl, "aabc", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\z", perl, "abc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\z", perl, "abcd", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\Z", perl, "abc\n\n", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\Z", perl, "abc\n\n", match_default|match_not_eob, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("abc\\Z", perl, "abc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\Gabc", perl, "abc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\Gabc", perl, "dabcd", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("a\\Gbc", perl, "abc", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("a\\Aab", perl, "abc", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("abc(?:\\Z|$)", perl, "abc\n\n", match_default, make_array(0, 3, -2, -2));
|
||||
}
|
||||
|
50
test/regress/test_grep.cpp
Normal file
50
test/regress/test_grep.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
*
|
||||
* 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"
|
||||
|
||||
void test_grep()
|
||||
{
|
||||
//
|
||||
// now test grep,
|
||||
// basically check all our restart types - line, word, etc
|
||||
// checking each one for null and non-null matches.
|
||||
//
|
||||
using namespace boost::regex_constants;
|
||||
TEST_REGEX_SEARCH("a", perl|nosubs, " a a a aa", match_default, make_array(1, 2, -2, 3, 4, -2, 5, 6, -2, 7, 8, -2, 8, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("a+b+", perl|nosubs, "aabaabbb ab", match_default, make_array(0, 3, -2, 3, 8, -2, 9, 11, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b*|c|e)d", perl|nosubs, "adabbdacd", match_default, make_array(0, 2, -2, 2, 6, -2, 6, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("a", perl|nosubs, "\na\na\na\naa", match_default, make_array(1, 2, -2, 3, 4, -2, 5, 6, -2, 7, 8, -2, 8, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("^", perl|nosubs, " \n\n \n\n\n", match_default, make_array(0, 0, -2, 4, 4, -2, 5, 5, -2, 8, 8, -2, 9, 9, -2, 10, 10, -2, -2));
|
||||
TEST_REGEX_SEARCH("^ab", perl|nosubs, "ab \nab ab\n", match_default, make_array(0, 2, -2, 5, 7, -2, -2));
|
||||
TEST_REGEX_SEARCH("^[^\\n]*\n", perl|nosubs, " \n \n\n \n", match_default, make_array(0, 4, -2, 4, 7, -2, 7, 8, -2, 8, 11, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\<abc", perl|nosubs, "abcabc abc\n\nabc", match_default, make_array(0, 3, -2, 7, 10, -2, 12, 15, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\<", perl|nosubs, " ab a aaa ", match_default, make_array(2, 2, -2, 5, 5, -2, 7, 7, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\<\\w+\\W+", perl|nosubs, " aa aa a ", match_default, make_array(1, 5, -2, 5, 9, -2, 9, 11, -2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("\\Aabc", perl|nosubs, "abc abc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\G\\w+\\W+", perl|nosubs, "abc abc a cbbb ", match_default, make_array(0, 5, -2, 5, 9, -2, 9, 11, -2, 11, 18, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\Ga+b+", perl|nosubs, "aaababb abb", match_default, make_array(0, 4, -2, 4, 7, -2, -2));
|
||||
TEST_REGEX_SEARCH("abc", perl|nosubs, "abc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("abc", perl|nosubs, " abc abcabc", match_default, make_array(1, 4, -2, 5, 8, -2, 8, 11, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\n\\n", perl|nosubs, " \n\n\n \n \n\n\n\n ", match_default, make_array(1, 3, -2, 18, 20, -2, 20, 22, -2, -2));
|
||||
TEST_REGEX_SEARCH("$", perl|nosubs, " \n\n \n\n\n", match_default, make_array(3, 3, -2, 4, 4, -2, 7, 7, -2, 8, 8, -2, 9, 9, -2, 10, 10, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\b", perl|nosubs, " abb a abbb ", match_default, make_array(2, 2, -2, 5, 5, -2, 6, 6, -2, 7, 7, -2, 8, 8, -2, 12, 12, -2, -2));
|
||||
TEST_REGEX_SEARCH("A", perl|icase|nosubs, " a a a aa", match_default, make_array(1, 2, -2, 3, 4, -2, 5, 6, -2, 7, 8, -2, 8, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("A+B+", perl|icase|nosubs, "aabaabbb ab", match_default, make_array(0, 3, -2, 3, 8, -2, 9, 11, -2, -2));
|
||||
TEST_REGEX_SEARCH("A(B*|c|e)D", perl|icase|nosubs, "adabbdacd", match_default, make_array(0, 2, -2, 2, 6, -2, 6, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("A", perl|icase|nosubs, "\na\na\na\naa", match_default, make_array(1, 2, -2, 3, 4, -2, 5, 6, -2, 7, 8, -2, 8, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("^aB", perl|icase|nosubs, "Ab \nab Ab\n", match_default, make_array(0, 2, -2, 5, 7, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\<abc", perl|icase|nosubs, "Abcabc aBc\n\nabc", match_default, make_array(0, 3, -2, 7, 10, -2, 12, 15, -2, -2));
|
||||
TEST_REGEX_SEARCH("ABC", perl|icase|nosubs, "abc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("abc", perl|icase|nosubs, " ABC ABCABC ", match_default, make_array(1, 4, -2, 5, 8, -2, 8, 11, -2, -2));
|
||||
}
|
||||
|
101
test/regress/test_locale.cpp
Normal file
101
test/regress/test_locale.cpp
Normal file
@ -0,0 +1,101 @@
|
||||
/*
|
||||
*
|
||||
* 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"
|
||||
#include <clocale>
|
||||
#ifndef BOOST_DISABLE_WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
test_locale::test_locale(const char* c_name, boost::uint32_t lcid)
|
||||
{
|
||||
// back up C locale and then set it's new name:
|
||||
m_old_c_locale = std::setlocale(LC_ALL, 0);
|
||||
m_old_c_state = s_c_locale;
|
||||
if(std::setlocale(LC_ALL, c_name))
|
||||
{
|
||||
s_c_locale = test_with_locale;
|
||||
}
|
||||
else
|
||||
s_c_locale = no_test;
|
||||
|
||||
// back up the C++ locale and create the new one:
|
||||
m_old_cpp_locale = s_cpp_locale_inst;
|
||||
m_old_cpp_state = s_cpp_locale;
|
||||
try{
|
||||
s_cpp_locale_inst = std::locale(c_name);
|
||||
s_cpp_locale = test_with_locale;
|
||||
}catch(std::runtime_error const &)
|
||||
{
|
||||
s_cpp_locale = no_test;
|
||||
}
|
||||
|
||||
// back up win locale and create the new one:
|
||||
m_old_win_locale = s_win_locale_inst;
|
||||
m_old_win_state = s_win_locale;
|
||||
s_win_locale_inst = lcid;
|
||||
if(::IsValidLocale(lcid, LCID_INSTALLED))
|
||||
s_win_locale = test_with_locale;
|
||||
else
|
||||
s_win_locale = no_test;
|
||||
}
|
||||
|
||||
test_locale::~test_locale()
|
||||
{
|
||||
// restore to previous state:
|
||||
std::setlocale(LC_ALL, m_old_c_locale.c_str());
|
||||
s_c_locale = m_old_c_state;
|
||||
s_cpp_locale_inst = m_old_cpp_locale;
|
||||
s_cpp_locale = m_old_cpp_state;
|
||||
s_win_locale_inst = m_old_win_locale;
|
||||
s_win_locale = m_old_win_state;
|
||||
}
|
||||
|
||||
int test_locale::s_c_locale = test_no_locale;
|
||||
int test_locale::s_cpp_locale = test_no_locale;
|
||||
int test_locale::s_win_locale = test_no_locale;
|
||||
std::locale test_locale::s_cpp_locale_inst;
|
||||
boost::uint32_t test_locale::s_win_locale_inst = 0;
|
||||
|
||||
|
||||
void test_en_locale(const char* name, boost::uint32_t lcid)
|
||||
{
|
||||
using namespace boost::regex_constants;
|
||||
errors_as_warnings w;
|
||||
test_locale l(name, lcid);
|
||||
TEST_REGEX_SEARCH("[[:lower:]]+", perl, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", match_default, make_array(1, 32, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[:upper:]]+", perl, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", match_default, make_array(1, 31, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[:punct:]]+", perl, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", match_default, make_array(0, 31, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[:print:]]+", perl, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", match_default, make_array(0, 94, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[:graph:]]+", perl, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", match_default, make_array(0, 94, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[:word:]]+", perl, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", match_default, make_array(0, 61, -2, -2));
|
||||
// collation sensitive ranges:
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, < 0x600)
|
||||
// these tests are disabled for Borland C++: a bug in std::collate<wchar_t>
|
||||
// causes these tests to crash (pointer overrun in std::collate<wchar_t>::do_transform).
|
||||
TEST_REGEX_SEARCH("[a-z]+", perl|collate, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", match_default, make_array(0, 28, -2, -2));
|
||||
TEST_REGEX_SEARCH("[a-z]+", perl|collate, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", match_default, make_array(1, 28, -2, -2));
|
||||
// and equivalence classes:
|
||||
TEST_REGEX_SEARCH("[[=a=]]+", perl, "aA<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", match_default, make_array(0, 14, -2, -2));
|
||||
// case mapping:
|
||||
TEST_REGEX_SEARCH("[A-Z]+", perl|icase|collate, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", match_default, make_array(0, 28, -2, -2));
|
||||
TEST_REGEX_SEARCH("[a-z]+", perl|icase|collate, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", match_default, make_array(1, 28, -2, -2));
|
||||
TEST_REGEX_SEARCH("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", perl|icase, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", match_default, make_array(1, 30, -2, -2));
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_en_locale()
|
||||
{
|
||||
test_en_locale("en_US", 0x09 | 0x01 << 10);
|
||||
test_en_locale("en_UK", 0x09 | 0x02 << 10);
|
||||
test_en_locale("en", 0x09);
|
||||
}
|
||||
|
62
test/regress/test_locale.hpp
Normal file
62
test/regress/test_locale.hpp
Normal file
@ -0,0 +1,62 @@
|
||||
|
||||
|
||||
#ifndef BOOST_REGEX_REGRESS_TEST_LOCALE_HPP
|
||||
#define BOOST_REGEX_REGRESS_TEST_LOCALE_HPP
|
||||
//
|
||||
// defines class test_locale that handles the locale used for testing:
|
||||
//
|
||||
class test_locale
|
||||
{
|
||||
public:
|
||||
enum{
|
||||
no_test,
|
||||
test_no_locale,
|
||||
test_with_locale
|
||||
};
|
||||
|
||||
test_locale(const char* c_name, boost::uint32_t lcid);
|
||||
~test_locale();
|
||||
|
||||
static int c_locale_state()
|
||||
{
|
||||
return s_c_locale;
|
||||
}
|
||||
static int cpp_locale_state()
|
||||
{
|
||||
return s_cpp_locale;
|
||||
}
|
||||
static int win_locale_state()
|
||||
{
|
||||
return s_win_locale;
|
||||
}
|
||||
|
||||
static std::locale cpp_locale()
|
||||
{
|
||||
return s_cpp_locale_inst;
|
||||
}
|
||||
static boost::uint32_t win_locale()
|
||||
{
|
||||
return s_win_locale_inst;
|
||||
}
|
||||
|
||||
private:
|
||||
// the actions to take for each locale type:
|
||||
static int s_c_locale;
|
||||
static int s_cpp_locale;
|
||||
static int s_win_locale;
|
||||
// current locales:
|
||||
static std::locale s_cpp_locale_inst;
|
||||
static boost::uint32_t s_win_locale_inst;
|
||||
|
||||
// backed up versions of the previous locales and their action state:
|
||||
std::string m_old_c_locale;
|
||||
int m_old_c_state;
|
||||
std::locale m_old_cpp_locale;
|
||||
int m_old_cpp_state;
|
||||
boost::uint32_t m_old_win_locale;
|
||||
int m_old_win_state;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
38
test/regress/test_non_greedy_repeats.cpp
Normal file
38
test/regress/test_non_greedy_repeats.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
*
|
||||
* 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"
|
||||
|
||||
void test_non_greedy_repeats()
|
||||
{
|
||||
//
|
||||
// non-greedy repeats added 21/04/00
|
||||
//
|
||||
using namespace boost::regex_constants;
|
||||
TEST_REGEX_SEARCH("a*?", perl, "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*?$", perl, "aa", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("^.*?$", perl, "aa", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("^(a)*?$", perl, "aa", match_default, make_array(0, 2, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("^[ab]*?$", perl, "aa", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a??", perl, "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+?", perl, "aa", match_default, make_array(0, 1, -2, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a{1,3}?", perl, "aaa", match_default, make_array(0, 1, -2, 1, 2, -2, 2, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\w+?w", perl, "...ccccccwcccccw", match_default, make_array(3, 10, -2, 10, 16, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\W+\\w+?w", perl, "...ccccccwcccccw", match_default, make_array(0, 10, -2, -2));
|
||||
TEST_REGEX_SEARCH("abc|\\w+?", perl, "abd", match_default, make_array(0, 1, -2, 1, 2, -2, 2, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("abc|\\w+?", perl, "abcd", match_default, make_array(0, 3, -2, 3, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("<\\s*tag[^>]*>(.*?)<\\s*/tag\\s*>", perl, " <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("<\\s*tag[^>]*>(.*?)<\\s*/tag\\s*>", perl, " < 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}", perl);
|
||||
TEST_INVALID_REGEX("a**", perl);
|
||||
TEST_INVALID_REGEX("a++", perl);
|
||||
}
|
||||
|
@ -30,6 +30,23 @@ void test(boost::basic_regex<charT, traits>& r, const test_invalid_regex_tag&)
|
||||
{
|
||||
const std::basic_string<charT>& expression = test_info<charT>::expression();
|
||||
boost::regex_constants::syntax_option_type syntax_options = test_info<charT>::syntax_options();
|
||||
//
|
||||
// try it with exceptions disabled first:
|
||||
//
|
||||
try
|
||||
{
|
||||
if(0 == r.assign(expression, syntax_options | boost::regex_constants::no_except).status())
|
||||
{
|
||||
BOOST_REGEX_TEST_ERROR("Expression compiled when it should not have done so.", charT);
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
BOOST_REGEX_TEST_ERROR("Unexpected exception thrown.", charT);
|
||||
}
|
||||
//
|
||||
// now try again with exceptions:
|
||||
//
|
||||
bool have_catch = false;
|
||||
try{
|
||||
r.assign(expression, syntax_options);
|
||||
|
618
test/regress/test_perl_ex.cpp
Normal file
618
test/regress/test_perl_ex.cpp
Normal file
@ -0,0 +1,618 @@
|
||||
/*
|
||||
*
|
||||
* 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"
|
||||
|
||||
void test_independent_subs()
|
||||
{
|
||||
using namespace boost::regex_constants;
|
||||
TEST_REGEX_SEARCH("(?>^abc)", perl, "abc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?>^abc)", perl, "def\nabc", match_default, make_array(4, 7, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?>^abc)", perl, "defabc", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(?>.*/)foo", perl, "/this/is/a/very/long/line/in/deed/with/very/many/slashes/in/it/you/see/", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(?>.*/)foo", perl, "/this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo", match_default, make_array(0, 67, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?>(\\.\\d\\d[1-9]?))\\d+", perl, "1.230003938", match_default, make_array(1, 11, 1, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?>(\\.\\d\\d[1-9]?))\\d+", perl, "1.875000282", match_default, make_array(1, 11, 1, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?>(\\.\\d\\d[1-9]?))\\d+", perl, "1.235", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("^((?>\\w+)|(?>\\s+))*$", perl, "now is the time for all good men to come to the aid of the party", match_default, make_array(0, 64, 59, 64, -2, -2));
|
||||
TEST_REGEX_SEARCH("^((?>\\w+)|(?>\\s+))*$", perl, "this is not a line with only words and spaces!", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("((?>\\d+))(\\w)", perl, "12345a", match_default, make_array(0, 6, 0, 5, 5, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("((?>\\d+))(\\w)", perl, "12345+", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("((?>\\d+))(\\d)", perl, "12345", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(?>a+)b", perl, "aaab", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("((?>a+)b)", perl, "aaab", match_default, make_array(0, 4, 0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?>(a+))b", perl, "aaab", match_default, make_array(0, 4, 0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?>b)+", perl, "aaabbbccc", match_default, make_array(3, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?>a+|b+|c+)*c", perl, "aaabbbbccccd", match_default, make_array(0, 8, -2, 8, 9, -2, 9, 10, -2, 10, 11, -2, -2));
|
||||
TEST_REGEX_SEARCH("((?>[^()]+)|\\([^()]*\\))+", perl, "((abc(ade)ufh()()x", match_default, make_array(2, 18, 17, 18, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\(((?>[^()]+)|\\([^()]+\\))+\\)", perl, "(abc)", match_default, make_array(0, 5, 1, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\(((?>[^()]+)|\\([^()]+\\))+\\)", perl, "(abc(def)xyz)", match_default, make_array(0, 13, 9, 12, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\(((?>[^()]+)|\\([^()]+\\))+\\)", perl, "((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("(?>a*)*", perl, "a", match_default, make_array(0, 1, -2, 1, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?>a*)*", perl, "aa", match_default, make_array(0, 2, -2, 2, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?>a*)*", perl, "aaaa", match_default, make_array(0, 4, -2, 4, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?>a*)*", perl, "a", match_default, make_array(0, 1, -2, 1, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?>a*)*", perl, "aaabcde", match_default, make_array(0, 3, -2, 3, 3, -2, 4, 4, -2, 5, 5, -2, 6, 6, -2, 7, 7, -2, -2));
|
||||
TEST_REGEX_SEARCH("((?>a*))*", perl, "aaaaa", match_default, make_array(0, 5, 5, 5, -2, 5, 5, 5, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("((?>a*))*", perl, "aabbaa", match_default, make_array(0, 2, 2, 2, -2, 2, 2, 2, 2, -2, 3, 3, 3, 3, -2, 4, 6, 6, 6, -2, 6, 6, 6, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("((?>a*?))*", perl, "aaaaa", match_default, make_array(0, 0, 0, 0, -2, 1, 1, 1, 1, -2, 2, 2, 2, 2, -2, 3, 3, 3, 3, -2, 4, 4, 4, 4, -2, 5, 5, 5, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("((?>a*?))*", perl, "aabbaa", match_default, make_array(0, 0, 0, 0, -2, 1, 1, 1, 1, -2, 2, 2, 2, 2, -2, 3, 3, 3, 3, -2, 4, 4, 4, 4, -2, 5, 5, 5, 5, -2, 6, 6, 6, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("word (?>(?:(?!otherword)[a-zA-Z0-9]+ ){0,30})otherword", perl, "word cat dog elephant mussel cow horse canary baboon snake shark otherword", match_default, make_array(0, 74, -2, -2));
|
||||
TEST_REGEX_SEARCH("word (?>(?:(?!otherword)[a-zA-Z0-9]+ ){0,30})otherword", perl, "word cat dog elephant mussel cow horse canary baboon snake shark", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("word (?>[a-zA-Z0-9]+ ){0,30}otherword", perl, "word cat dog elephant mussel cow horse canary baboon snake shark the quick brown fox and the lazy dog and several other words getting close to thirty by now I hope", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("word (?>[a-zA-Z0-9]+ ){0,30}otherword", perl, "word cat dog elephant mussel cow horse canary baboon snake shark the quick brown fox and the lazy dog and several other words getting close to thirty by now I really really hope otherword", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("((?>Z)+|A)+", perl, "ZABCDEFG", match_default, make_array(0, 2, 1, 2, -2, -2));
|
||||
TEST_INVALID_REGEX("((?>)+|A)+", perl);
|
||||
}
|
||||
|
||||
void test_conditionals()
|
||||
{
|
||||
using namespace boost::regex_constants;
|
||||
TEST_REGEX_SEARCH("(?:(a)|b)(?(1)A|B)", perl, "aA", match_default, make_array(0, 2, 0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?:(a)|b)(?(1)A|B)", perl, "bB", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?:(a)|b)(?(1)A|B)", perl, "aB", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(?:(a)|b)(?(1)A|B)", perl, "bA", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("^(a)?(?(1)a|b)+$", perl, "aa", match_default, make_array(0, 2, 0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("^(a)?(?(1)a|b)+$", perl, "b", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("^(a)?(?(1)a|b)+$", perl, "bb", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("^(a)?(?(1)a|b)+$", perl, "ab", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("^(?(?=abc)\\w{3}:|\\d\\d)$", perl, "abc:", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("^(?(?=abc)\\w{3}:|\\d\\d)$", perl, "12", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("^(?(?=abc)\\w{3}:|\\d\\d)$", perl, "123", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("^(?(?=abc)\\w{3}:|\\d\\d)$", perl, "xyz", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("^(?(?!abc)\\d\\d|\\w{3}:)$", perl, "abc:", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("^(?(?!abc)\\d\\d|\\w{3}:)$", perl, "12", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("^(?(?!abc)\\d\\d|\\w{3}:)$", perl, "123", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("^(?(?!abc)\\d\\d|\\w{3}:)$", perl, "xyz", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("(?(?<=foo)bar|cat)", perl, "foobar", match_default, make_array(3, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?(?<=foo)bar|cat)", perl, "cat", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?(?<=foo)bar|cat)", perl, "fcat", match_default, make_array(1, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?(?<=foo)bar|cat)", perl, "focat", match_default, make_array(2, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?(?<=foo)bar|cat)", perl, "foocat", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("(?(?<!foo)cat|bar)", perl, "foobar", match_default, make_array(3, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?(?<!foo)cat|bar)", perl, "cat", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?(?<!foo)cat|bar)", perl, "fcat", match_default, make_array(1, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?(?<!foo)cat|bar)", perl, "focat", match_default, make_array(2, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?(?<!foo)cat|bar)", perl, "foocat", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("(\\()?[^()]+(?(1)\\))", perl, "abcd", match_default, make_array(0, 4, -1, -1, -2, -2));
|
||||
TEST_REGEX_SEARCH("(\\()?[^()]+(?(1)\\))", perl, "(abcd)", match_default, make_array(0, 6, 0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("(\\()?[^()]+(?(1)\\))", perl, "the quick (abcd) fox", match_default, make_array(0, 10, -1, -1, -2, 10, 16, 10, 11, -2, 16, 20, -1, -1, -2, -2));
|
||||
TEST_REGEX_SEARCH("(\\()?[^()]+(?(1)\\))", perl, "(abcd", match_default, make_array(1, 5, -1, -1, -2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("^(?(2)a|(1)(2))+$", perl, "12", match_default, make_array(0, 2, 0, 1, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("^(?(2)a|(1)(2))+$", perl, "12a", match_default, make_array(0, 3, 0, 1, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("^(?(2)a|(1)(2))+$", perl, "12aa", match_default, make_array(0, 4, 0, 1, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("^(?(2)a|(1)(2))+$", perl, "1234", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_INVALID_REGEX("(a)(?(1)a|b|c)", perl);
|
||||
TEST_INVALID_REGEX("(?(?=a)a|b|c)", perl);
|
||||
TEST_INVALID_REGEX("(?(1a)", perl);
|
||||
TEST_INVALID_REGEX("(?:(a)|b)(?(", perl);
|
||||
TEST_INVALID_REGEX("(?:(a)|b)(?(1", perl);
|
||||
TEST_INVALID_REGEX("(?:(a)|b)(?(1)", perl);
|
||||
TEST_INVALID_REGEX("(?:(a)|b)(?(a", perl);
|
||||
TEST_INVALID_REGEX("(?:(a)|b)(?(?", perl);
|
||||
TEST_INVALID_REGEX("(?:(a)|b)(?(?:", perl);
|
||||
TEST_INVALID_REGEX("(?:(a)|b)(?(?<", perl);
|
||||
TEST_INVALID_REGEX("(?:(a)|b)(?(?<a", perl);
|
||||
}
|
||||
|
||||
void test_options()
|
||||
{
|
||||
// test the (?imsx) construct:
|
||||
using namespace boost::regex_constants;
|
||||
TEST_INVALID_REGEX("(?imsx", perl);
|
||||
TEST_INVALID_REGEX("(?g", perl);
|
||||
TEST_INVALID_REGEX("(?im-sx", perl);
|
||||
TEST_INVALID_REGEX("(?im-sx:", perl);
|
||||
TEST_INVALID_REGEX("(?-g)", perl);
|
||||
TEST_REGEX_SEARCH("(?-m)^abc", perl, "abc\nabc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?m)^abc", perl|no_mod_m, "abc\nabc", match_default, make_array(0, 3, -2, 4, 7, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?-m)^abc", perl, "abc\nabc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?m)^abc", perl|no_mod_m, "abc\nabc", match_default, make_array(0, 3, -2, 4, 7, -2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH(" ^ a (?# begins with a) b\\sc (?# then b c) $ (?# then end)", perl|mod_x, "ab c", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH(" ^ a (?# begins with a) b\\sc (?# then b c) $ (?# then end)", perl|mod_x, "abc", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH(" ^ a (?# begins with a) b\\sc (?# then b c) $ (?# then end)", perl|mod_x, "ab cde", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(?x) ^ a (?# begins with a) b\\sc (?# then b c) $ (?# then end)", perl, "ab c", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?x) ^ a (?# begins with a) b\\sc (?# then b c) $ (?# then end)", perl, "abc", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(?x) ^ a (?# begins with a) b\\sc (?# then b c) $ (?# then end)", perl, "ab cde", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("^ a\\ b[c ]d $", perl|mod_x, "a bcd", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("^ a\\ b[c ]d $", perl|mod_x, "a b d", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("^ a\\ b[c ]d $", perl|mod_x, "abcd", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("^ a\\ b[c ]d $", perl|mod_x, "ab d", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("^1234(?# test newlines\n inside)", perl|mod_x, "1234", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("^1234 #comment in extended re\n", perl|mod_x, "1234", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("#rhubarb\n abcd", perl|mod_x, "abcd", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("^1234 #comment in extended re\r\n", perl|mod_x, "1234", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("#rhubarb\r\n abcd", perl|mod_x, "abcd", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("^abcd#rhubarb", perl|mod_x, "abcd", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("^abcd#rhubarb", perl, "abcd#rhubarb", match_default, make_array(0, 12, -2, -2));
|
||||
TEST_REGEX_SEARCH("^a b\n\n c", perl|mod_x, "abc", match_default, make_array(0, 3, -2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("(?(?=[^a-z]+[a-z]) \\d{2}-[a-z]{3}-\\d{2} | \\d{2}-\\d{2}-\\d{2} ) ", perl|mod_x, "12-sep-98", match_default, make_array(0, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?(?=[^a-z]+[a-z]) \\d{2}-[a-z]{3}-\\d{2} | \\d{2}-\\d{2}-\\d{2} ) ", perl|mod_x, "12-09-98", match_default, make_array(0, 8, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?(?=[^a-z]+[a-z]) \\d{2}-[a-z]{3}-\\d{2} | \\d{2}-\\d{2}-\\d{2} ) ", perl|mod_x, "sep-12-98", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("^a (?#xxx) (?#yyy) {3}c", perl|mod_x, "aaac", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab", perl|mod_x, "ab", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH(" abc\\Q abc\\Eabc", perl|mod_x, "abc abcabc", match_default, make_array(0, 10, -2, -2));
|
||||
TEST_REGEX_SEARCH(" abc\\Q abc\\Eabc", perl|mod_x, "abcabcabc", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("abc#comment\n \\Q#not comment\n literal\\E", perl|mod_x, "abc#not comment\n literal", match_default, make_array(0, 27, -2, -2));
|
||||
TEST_REGEX_SEARCH("abc#comment\n \\Q#not comment\n literal", perl|mod_x, "abc#not comment\n literal", match_default, make_array(0, 27, -2, -2));
|
||||
TEST_REGEX_SEARCH("abc#comment\n \\Q#not comment\n literal\\E #more comment\n ", perl|mod_x, "abc#not comment\n literal", match_default, make_array(0, 27, -2, -2));
|
||||
TEST_REGEX_SEARCH("abc#comment\n \\Q#not comment\n literal\\E #more comment", perl|mod_x, "abc#not comment\n literal", match_default, make_array(0, 27, -2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("(a (?x)b c)d e", perl, "a bcd e", match_default, make_array(0, 7, 0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("(a (?x)b c)d e", perl, "a b cd e", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(a (?x)b c)d e", perl, "abcd e", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(a (?x)b c)d e", perl, "a bcde", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(a b(?x)c d (?-x)e f)", perl, "a bcde f", match_default, make_array(0, 8, 0, 8, -2, -2));
|
||||
TEST_REGEX_SEARCH("(a b(?x)c d (?-x)e f)", perl, "abcdef", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("a(?x: b c )d", perl, "XabcdY", match_default, make_array(1, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(?x: b c )d", perl, "Xa b c d Y", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("((?x)x y z | a b c)", perl, "XabcY", match_default, make_array(1, 4, 1, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("((?x)x y z | a b c)", perl, "AxyzB", match_default, make_array(1, 4, 1, 4, -2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("(a (?x)b c)d e", perl, "a bcd e", match_default, make_array(0, 7, 0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("(a (?x)b c)d e", perl, "a b cd e", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(a (?x)b c)d e", perl, "abcd e", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(a (?x)b c)d e", perl, "a bcde", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(a b(?x)c d (?-x)e f)", perl, "a bcde f", match_default, make_array(0, 8, 0, 8, -2, -2));
|
||||
TEST_REGEX_SEARCH("(a b(?x)c d (?-x)e f)", perl, "abcdef", match_default, make_array(-2, -2));
|
||||
}
|
||||
|
||||
void test_options2()
|
||||
{
|
||||
using namespace boost::regex_constants;
|
||||
TEST_INVALID_REGEX("(?i-", perl);
|
||||
TEST_INVALID_REGEX("(?i-s", perl);
|
||||
TEST_INVALID_REGEX("(?i-sd)", perl);
|
||||
TEST_REGEX_SEARCH("(a(?i)b)c", perl, "abc", match_default, make_array(0, 3, 0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("(a(?i)b)c", perl, "aBc", match_default, make_array(0, 3, 0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("(a(?i)b)c", perl, "abC", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(a(?i)b)c", perl, "aBC", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(a(?i)b)c", perl, "Abc", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(a(?i)b)c", perl, "ABc", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(a(?i)b)c", perl, "ABC", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(a(?i)b)c", perl, "AbC", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("(a(?i)B)c", perl, "abc", match_default, make_array(0, 3, 0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("(a(?i)B)c", perl, "aBc", match_default, make_array(0, 3, 0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("(a(?i)B)c", perl, "abC", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(a(?i)B)c", perl, "aBC", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(a(?i)B)c", perl, "Abc", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(a(?i)B)c", perl, "ABc", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(a(?i)B)c", perl, "ABC", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(a(?i)B)c", perl, "AbC", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("a(?i:b)c", perl, "abc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(?i:b)c", perl, "aBc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(?i:b)c", perl, "ABC", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("a(?i:b)c", perl, "abC", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("a(?i:b)c", perl, "aBC", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("a(?i:b)*c", perl, "aBc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(?i:b)*c", perl, "aBBc", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(?i:b)*c", perl, "aBC", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("a(?i:b)*c", perl, "aBBC", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("a(?=b(?i)c)\\w\\wd", perl, "abcd", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(?=b(?i)c)\\w\\wd", perl, "abCd", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(?=b(?i)c)\\w\\wd", perl, "aBCd", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("a(?=b(?i)c)\\w\\wd", perl, "abcD", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("(?s-i:more.*than).*million", perl|icase, "more than million", match_default, make_array(0, 17, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?s-i:more.*than).*million", perl|icase, "more than MILLION", match_default, make_array(0, 17, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?s-i:more.*than).*million", perl|icase, "more \n than Million", match_default, make_array(0, 19, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?s-i:more.*than).*million", perl|icase, "MORE THAN MILLION", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(?s-i:more.*than).*million", perl|icase|no_mod_s|no_mod_m, "more \n than \n million", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("(?:(?s-i)more.*than).*million", perl|icase, "more than million", match_default, make_array(0, 17, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?:(?s-i)more.*than).*million", perl|icase, "more than MILLION", match_default, make_array(0, 17, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?:(?s-i)more.*than).*million", perl|icase, "more \n than Million", match_default, make_array(0, 19, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?:(?s-i)more.*than).*million", perl|icase, "MORE THAN MILLION", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(?:(?s-i)more.*than).*million", perl|icase|no_mod_s|no_mod_m, "more \n than \n million", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("(?>a(?i)b+)+c", perl, "abc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?>a(?i)b+)+c", perl, "aBbc", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?>a(?i)b+)+c", perl, "aBBc", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?>a(?i)b+)+c", perl, "Abc", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(?>a(?i)b+)+c", perl, "abAb", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(?>a(?i)b+)+c", perl, "abbC", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("(?=a(?i)b)\\w\\wc", perl, "abc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?=a(?i)b)\\w\\wc", perl, "aBc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?=a(?i)b)\\w\\wc", perl, "Ab", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(?=a(?i)b)\\w\\wc", perl, "abC", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(?=a(?i)b)\\w\\wc", perl, "aBC", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("(?<=a(?i)b)(\\w\\w)c", perl, "abxxc", match_default, make_array(2, 5, 2, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?<=a(?i)b)(\\w\\w)c", perl, "aBxxc", match_default, make_array(2, 5, 2, 4, -2, -2));
|
||||
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("(?<=a(?i)b)(\\w\\w)c", perl, "abxxC", 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));
|
||||
TEST_REGEX_SEARCH("(?:ab(?i)x(?-i)y|(?i)z|b)ZZ", perl, "zZZ", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?:ab(?i)x(?-i)y|(?i)z|b)ZZ", perl, "bZZ", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?:ab(?i)x(?-i)y|(?i)z|b)ZZ", perl, "BZZ", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?:ab(?i)x(?-i)y|(?i)z|b)ZZ", perl, "ZZ", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(?:ab(?i)x(?-i)y|(?i)z|b)ZZ", perl, "abXYZZ", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(?:ab(?i)x(?-i)y|(?i)z|b)ZZ", perl, "zzz", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(?:ab(?i)x(?-i)y|(?i)z|b)ZZ", perl, "bzz", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("((?-i)[[:lower:]])[[:lower:]]", perl|icase, "ab", match_default, make_array(0, 2, 0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("((?-i)[[:lower:]])[[:lower:]]", perl|icase, "aB", match_default, make_array(0, 2, 0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("((?-i)[[:lower:]])[[:lower:]]", perl|icase, "Ab", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("((?-i)[[:lower:]])[[:lower:]]", perl|icase, "AB", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("a(?-i)b", perl|icase, "ab", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(?-i)b", perl|icase, "Ab", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(?-i)b", perl|icase, "aB", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("a(?-i)b", perl|icase, "AB", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("(?:(?-i)a)b", perl|icase, "ab", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("((?-i)a)b", perl|icase, "ab", match_default, make_array(0, 2, 0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?:(?-i)a)b", perl|icase, "aB", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("((?-i)a)b", perl|icase, "aB", match_default, make_array(0, 2, 0, 1, -2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("(?:(?-i)a)b", perl|icase, "Ab", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(?:(?-i)a)b", perl|icase, "aB", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("((?-i)a)b", perl|icase, "aB", match_default, make_array(0, 2, 0, 1, -2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("(?:(?-i)a)b", perl|icase, "Ab", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(?:(?-i)a)b", perl|icase, "AB", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(?-i:a)b", perl|icase, "ab", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("((?-i:a))b", perl|icase, "ab", match_default, make_array(0, 2, 0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?-i:a)b", perl|icase, "aB", match_default, make_array(0, 2, -2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("((?-i:a))b", perl|icase, "aB", match_default, make_array(0, 2, 0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?-i:a)b", perl|icase, "AB", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(?-i:a)b", perl|icase, "Ab", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(?-i:a)b", perl|icase, "aB", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("((?-i:a))b", perl|icase, "aB", match_default, make_array(0, 2, 0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?-i:a)b", perl|icase, "Ab", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(?-i:a)b", perl|icase, "AB", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("((?-i:a.))b", perl|icase, "AB", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("((?-i:a.))b", perl|icase, "A\nB", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("((?s-i:a.))b", perl|icase, "a\nB", match_default, make_array(0, 3, 0, 2, -2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH(".", perl, "\n", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH(".", perl, "\n", match_default|match_not_dot_newline, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH(".", perl|mod_s, "\n", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH(".", perl|mod_s, "\n", match_default|match_not_dot_newline, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH(".", perl|no_mod_s, "\n", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH(".", perl|no_mod_s, "\n", match_default|match_not_dot_newline, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(?s).", perl, "\n", match_default, make_array(0, 1, -2, -2));
|
||||
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_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));
|
||||
TEST_REGEX_SEARCH(".+", perl|mod_s, " \n ", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH(".+", perl|mod_s, " \n ", match_default|match_not_dot_newline, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH(".+", perl|no_mod_s, " \n ", match_default, make_array(0, 2, -2, 3, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH(".+", perl|no_mod_s, " \n ", match_default|match_not_dot_newline, make_array(0, 2, -2, 3, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?s).+", perl, " \n ", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?s).+", perl, " \n ", match_default|match_not_dot_newline, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?-s).+", perl, " \n ", match_default, make_array(0, 2, -2, 3, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?-s).+", perl, " \n ", match_default|match_not_dot_newline, make_array(0, 2, -2, 3, 5, -2, -2));
|
||||
|
||||
const char* big_expression =
|
||||
" (?: [\\040\\t] | \\(\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] | \\( (?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] )* \\) )*\n"
|
||||
"\\) )* # optional leading comment\n"
|
||||
"(?: (?:\n"
|
||||
"[^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff]+ # some number of atom characters...\n"
|
||||
"(?![^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff]) # ..not followed by something that could be part of an atom\n"
|
||||
"|\n"
|
||||
"\" (?: # opening quote...\n"
|
||||
"[^\\\\\\x80-\\xff\\n\\015\"] # Anything except backslash and quote\n"
|
||||
"| # or\n"
|
||||
"\\\\ [^\\x80-\\xff] # Escaped something (something != CR)\n"
|
||||
")* \" # closing quote\n"
|
||||
") # initial word\n"
|
||||
"(?: (?: [\\040\\t] | \\(\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] | \\( (?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] )* \\) )*\n"
|
||||
"\\) )* \\. (?: [\\040\\t] | \\(\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] | \\( (?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] )* \\) )*\n"
|
||||
"\\) )* (?:\n"
|
||||
"[^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff]+ # some number of atom characters...\n"
|
||||
"(?![^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff]) # ..not followed by something that could be part of an atom\n"
|
||||
"|\n"
|
||||
"\" (?: # opening quote...\n"
|
||||
"[^\\\\\\x80-\\xff\\n\\015\"] # Anything except backslash and quote\n"
|
||||
"| # or\n"
|
||||
"\\\\ [^\\x80-\\xff] # Escaped something (something != CR)\n"
|
||||
")* \" # closing quote\n"
|
||||
") )* # further okay, if led by a period\n"
|
||||
"(?: [\\040\\t] | \\(\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] | \\( (?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] )* \\) )*\n"
|
||||
"\\) )* @ (?: [\\040\\t] | \\(\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] | \\( (?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] )* \\) )*\n"
|
||||
"\\) )* (?:\n"
|
||||
"[^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff]+ # some number of atom characters...\n"
|
||||
"(?![^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff]) # ..not followed by something that could be part of an atom\n"
|
||||
"| \\[ # [\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015\\[\\]] | \\\\ [^\\x80-\\xff] )* # stuff\n"
|
||||
"\\] # ]\n"
|
||||
") # initial subdomain\n"
|
||||
"(?: #\n"
|
||||
"(?: [\\040\\t] | \\(\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] | \\( (?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] )* \\) )*\n"
|
||||
"\\) )* \\. # if led by a period...\n"
|
||||
"(?: [\\040\\t] | \\(\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] | \\( (?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] )* \\) )*\n"
|
||||
"\\) )* (?:\n"
|
||||
"[^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff]+ # some number of atom characters...\n"
|
||||
"(?![^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff]) # ..not followed by something that could be part of an atom\n"
|
||||
"| \\[ # [\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015\\[\\]] | \\\\ [^\\x80-\\xff] )* # stuff\n"
|
||||
"\\] # ]\n"
|
||||
") # ...further okay\n"
|
||||
")*\n"
|
||||
"# address\n"
|
||||
"| # or\n"
|
||||
"(?:\n"
|
||||
"[^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff]+ # some number of atom characters...\n"
|
||||
"(?![^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff]) # ..not followed by something that could be part of an atom\n"
|
||||
"|\n"
|
||||
"\" (?: # opening quote...\n"
|
||||
"[^\\\\\\x80-\\xff\\n\\015\"] # Anything except backslash and quote\n"
|
||||
"| # or\n"
|
||||
"\\\\ [^\\x80-\\xff] # Escaped something (something != CR)\n"
|
||||
")* \" # closing quote\n"
|
||||
") # one word, optionally followed by....\n"
|
||||
"(?:\n"
|
||||
"[^()<>@,;:\".\\\\\\[\\]\\x80-\\xff\\000-\\010\\012-\\037] | # atom and space parts, or...\n"
|
||||
"\\(\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] | \\( (?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] )* \\) )*\n"
|
||||
"\\) | # comments, or...\n"
|
||||
"\" (?: # opening quote...\n"
|
||||
"[^\\\\\\x80-\\xff\\n\\015\"] # Anything except backslash and quote\n"
|
||||
"| # or\n"
|
||||
"\\\\ [^\\x80-\\xff] # Escaped something (something != CR)\n"
|
||||
")* \" # closing quote\n"
|
||||
"# quoted strings\n"
|
||||
")*\n"
|
||||
"< (?: [\\040\\t] | \\(\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] | \\( (?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] )* \\) )*\n"
|
||||
"\\) )* # leading <\n"
|
||||
"(?: @ (?: [\\040\\t] | \\(\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] | \\( (?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] )* \\) )*\n"
|
||||
"\\) )* (?:\n"
|
||||
"[^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff]+ # some number of atom characters...\n"
|
||||
"(?![^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff]) # ..not followed by something that could be part of an atom\n"
|
||||
"| \\[ # [\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015\\[\\]] | \\\\ [^\\x80-\\xff] )* # stuff\n"
|
||||
"\\] # ]\n"
|
||||
") # initial subdomain\n"
|
||||
"(?: #\n"
|
||||
"(?: [\\040\\t] | \\(\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] | \\( (?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] )* \\) )*\n"
|
||||
"\\) )* \\. # if led by a period...\n"
|
||||
"(?: [\\040\\t] | \\(\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] | \\( (?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] )* \\) )*\n"
|
||||
"\\) )* (?:\n"
|
||||
"[^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff]+ # some number of atom characters...\n"
|
||||
"(?![^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff]) # ..not followed by something that could be part of an atom\n"
|
||||
"| \\[ # [\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015\\[\\]] | \\\\ [^\\x80-\\xff] )* # stuff\n"
|
||||
"\\] # ]\n"
|
||||
") # ...further okay\n"
|
||||
")*\n"
|
||||
"(?: (?: [\\040\\t] | \\(\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] | \\( (?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] )* \\) )*\n"
|
||||
"\\) )* , (?: [\\040\\t] | \\(\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] | \\( (?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] )* \\) )*\n"
|
||||
"\\) )* @ (?: [\\040\\t] | \\(\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] | \\( (?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] )* \\) )*\n"
|
||||
"\\) )* (?:\n"
|
||||
"[^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff]+ # some number of atom characters...\n"
|
||||
"(?![^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff]) # ..not followed by something that could be part of an atom\n"
|
||||
"| \\[ # [\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015\\[\\]] | \\\\ [^\\x80-\\xff] )* # stuff\n"
|
||||
"\\] # ]\n"
|
||||
") # initial subdomain\n"
|
||||
"(?: #\n"
|
||||
"(?: [\\040\\t] | \\(\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] | \\( (?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] )* \\) )*\n"
|
||||
"\\) )* \\. # if led by a period...\n"
|
||||
"(?: [\\040\\t] | \\(\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] | \\( (?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] )* \\) )*\n"
|
||||
"\\) )* (?:\n"
|
||||
"[^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff]+ # some number of atom characters...\n"
|
||||
"(?![^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff]) # ..not followed by something that could be part of an atom\n"
|
||||
"| \\[ # [\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015\\[\\]] | \\\\ [^\\x80-\\xff] )* # stuff\n"
|
||||
"\\] # ]\n"
|
||||
") # ...further okay\n"
|
||||
")*\n"
|
||||
")* # further okay, if led by comma\n"
|
||||
": # closing colon\n"
|
||||
"(?: [\\040\\t] | \\(\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] | \\( (?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] )* \\) )*\n"
|
||||
"\\) )* )? # optional route\n"
|
||||
"(?:\n"
|
||||
"[^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff]+ # some number of atom characters...\n"
|
||||
"(?![^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff]) # ..not followed by something that could be part of an atom\n"
|
||||
"|\n"
|
||||
"\" (?: # opening quote...\n"
|
||||
"[^\\\\\\x80-\\xff\\n\\015\"] # Anything except backslash and quote\n"
|
||||
"| # or\n"
|
||||
"\\\\ [^\\x80-\\xff] # Escaped something (something != CR)\n"
|
||||
")* \" # closing quote\n"
|
||||
") # initial word\n"
|
||||
"(?: (?: [\\040\\t] | \\(\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] | \\( (?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] )* \\) )*\n"
|
||||
"\\) )* \\. (?: [\\040\\t] | \\(\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] | \\( (?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] )* \\) )*\n"
|
||||
"\\) )* (?:\n"
|
||||
"[^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff]+ # some number of atom characters...\n"
|
||||
"(?![^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff]) # ..not followed by something that could be part of an atom\n"
|
||||
"|\n"
|
||||
"\" (?: # opening quote...\n"
|
||||
"[^\\\\\\x80-\\xff\\n\\015\"] # Anything except backslash and quote\n"
|
||||
"| # or\n"
|
||||
"\\\\ [^\\x80-\\xff] # Escaped something (something != CR)\n"
|
||||
")* \" # closing quote\n"
|
||||
") )* # further okay, if led by a period\n"
|
||||
"(?: [\\040\\t] | \\(\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] | \\( (?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] )* \\) )*\n"
|
||||
"\\) )* @ (?: [\\040\\t] | \\(\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] | \\( (?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] )* \\) )*\n"
|
||||
"\\) )* (?:\n"
|
||||
"[^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff]+ # some number of atom characters...\n"
|
||||
"(?![^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff]) # ..not followed by something that could be part of an atom\n"
|
||||
"| \\[ # [\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015\\[\\]] | \\\\ [^\\x80-\\xff] )* # stuff\n"
|
||||
"\\] # ]\n"
|
||||
") # initial subdomain\n"
|
||||
"(?: #\n"
|
||||
"(?: [\\040\\t] | \\(\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] | \\( (?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] )* \\) )*\n"
|
||||
"\\) )* \\. # if led by a period...\n"
|
||||
"(?: [\\040\\t] | \\(\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] | \\( (?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] )* \\) )*\n"
|
||||
"\\) )* (?:\n"
|
||||
"[^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff]+ # some number of atom characters...\n"
|
||||
"(?![^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff]) # ..not followed by something that could be part of an atom\n"
|
||||
"| \\[ # [\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015\\[\\]] | \\\\ [^\\x80-\\xff] )* # stuff\n"
|
||||
"\\] # ]\n"
|
||||
") # ...further okay\n"
|
||||
")*\n"
|
||||
"# address spec\n"
|
||||
"(?: [\\040\\t] | \\(\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] | \\( (?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] )* \\) )*\n"
|
||||
"\\) )* > # trailing >\n"
|
||||
"# name and address\n"
|
||||
") (?: [\\040\\t] | \\(\n"
|
||||
"(?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] | \\( (?: [^\\\\\\x80-\\xff\\n\\015()] | \\\\ [^\\x80-\\xff] )* \\) )*\n"
|
||||
"\\) )* # optional trailing comment\n"
|
||||
"\n";
|
||||
|
||||
do{
|
||||
test_info<char>::set_info(__FILE__, __LINE__,
|
||||
big_expression,
|
||||
perl|mod_x, "Alan Other <user@dom.ain>", match_default,
|
||||
make_array(0, 25, -2, -2));
|
||||
test(char(0), test_regex_search_tag());
|
||||
}while(0);
|
||||
#if !defined(BOOST_NO_WREGEX) && !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS) && !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
do{
|
||||
std::string st(big_expression);
|
||||
test_info<wchar_t>::set_info(__FILE__, __LINE__,
|
||||
std::wstring(st.begin(), st.end()),
|
||||
perl|mod_x, L"Alan Other <user@dom.ain>", match_default,
|
||||
make_array(0, 25, -2, -2));
|
||||
test(char(0), test_regex_search_tag());
|
||||
}while(0);
|
||||
#endif
|
||||
do{
|
||||
test_info<char>::set_info(__FILE__, __LINE__,
|
||||
big_expression,
|
||||
perl|mod_x, "<user@dom.ain>", match_default,
|
||||
make_array(1, 13, -2, -2));
|
||||
test(char(0), test_regex_search_tag());
|
||||
}while(0);
|
||||
#if !defined(BOOST_NO_WREGEX) && !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS) && !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
do{
|
||||
std::string st(big_expression);
|
||||
test_info<wchar_t>::set_info(__FILE__, __LINE__,
|
||||
std::wstring(st.begin(), st.end()),
|
||||
perl|mod_x, L"<user@dom.ain>", match_default,
|
||||
make_array(1, 13, -2, -2));
|
||||
test(char(0), test_regex_search_tag());
|
||||
}while(0);
|
||||
#endif
|
||||
do{
|
||||
test_info<char>::set_info(__FILE__, __LINE__,
|
||||
big_expression,
|
||||
perl|mod_x, "\"A. Other\" <user.1234@dom.ain> (a comment)", match_default,
|
||||
make_array(0, 42, -2, -2));
|
||||
test(char(0), test_regex_search_tag());
|
||||
}while(0);
|
||||
#if !defined(BOOST_NO_WREGEX) && !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS) && !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
do{
|
||||
std::string st(big_expression);
|
||||
test_info<wchar_t>::set_info(__FILE__, __LINE__,
|
||||
std::wstring(st.begin(), st.end()),
|
||||
perl|mod_x, L"\"A. Other\" <user.1234@dom.ain> (a comment)", match_default,
|
||||
make_array(0, 42, -2, -2));
|
||||
test(char(0), test_regex_search_tag());
|
||||
}while(0);
|
||||
#endif
|
||||
do{
|
||||
test_info<char>::set_info(__FILE__, __LINE__,
|
||||
big_expression,
|
||||
perl|mod_x, "A. Other <user.1234@dom.ain> (a comment)", match_default,
|
||||
make_array(2, 40, -2, -2));
|
||||
test(char(0), test_regex_search_tag());
|
||||
}while(0);
|
||||
#if !defined(BOOST_NO_WREGEX) && !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS) && !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
do{
|
||||
std::string st(big_expression);
|
||||
test_info<wchar_t>::set_info(__FILE__, __LINE__,
|
||||
std::wstring(st.begin(), st.end()),
|
||||
perl|mod_x, L"A. Other <user.1234@dom.ain> (a comment)", match_default,
|
||||
make_array(2, 40, -2, -2));
|
||||
test(char(0), test_regex_search_tag());
|
||||
}while(0);
|
||||
#endif
|
||||
do{
|
||||
test_info<char>::set_info(__FILE__, __LINE__,
|
||||
big_expression,
|
||||
perl|mod_x, "\"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"@x400-re.lay", match_default,
|
||||
make_array(0, 61, -2, -2));
|
||||
test(char(0), test_regex_search_tag());
|
||||
}while(0);
|
||||
#if !defined(BOOST_NO_WREGEX) && !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS) && !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
do{
|
||||
std::string st(big_expression);
|
||||
test_info<wchar_t>::set_info(__FILE__, __LINE__,
|
||||
std::wstring(st.begin(), st.end()),
|
||||
perl|mod_x, L"\"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"@x400-re.lay", match_default,
|
||||
make_array(0, 61, -2, -2));
|
||||
test(char(0), test_regex_search_tag());
|
||||
}while(0);
|
||||
#endif
|
||||
do{
|
||||
test_info<char>::set_info(__FILE__, __LINE__,
|
||||
big_expression,
|
||||
perl|mod_x, "A missing angle <user@some.where", match_default,
|
||||
make_array(17, 32, -2, -2));
|
||||
test(char(0), test_regex_search_tag());
|
||||
}while(0);
|
||||
#if !defined(BOOST_NO_WREGEX) && !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS) && !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
do{
|
||||
std::string st(big_expression);
|
||||
test_info<wchar_t>::set_info(__FILE__, __LINE__,
|
||||
std::wstring(st.begin(), st.end()),
|
||||
perl|mod_x, L"A missing angle <user@some.where", match_default,
|
||||
make_array(17, 32, -2, -2));
|
||||
test(char(0), test_regex_search_tag());
|
||||
}while(0);
|
||||
#endif
|
||||
}
|
||||
|
100
test/regress/test_replace.cpp
Normal file
100
test/regress/test_replace.cpp
Normal file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
*
|
||||
* 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"
|
||||
|
||||
void test_replace()
|
||||
{
|
||||
using namespace boost::regex_constants;
|
||||
// start by testing subs:
|
||||
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default|format_no_copy, "$`", "...");
|
||||
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default|format_no_copy, "$'", ",,,");
|
||||
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default|format_no_copy, "$&", "aaa");
|
||||
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default|format_no_copy, "$0", "aaa");
|
||||
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default|format_no_copy, "$1", "");
|
||||
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default|format_no_copy, "$15", "");
|
||||
TEST_REGEX_REPLACE("(a+)b+", perl, "...aaabbb,,,", match_default|format_no_copy, "$1", "aaa");
|
||||
TEST_REGEX_REPLACE("[[:digit:]]*", perl, "123ab", match_default|format_no_copy, "<$0>", "<123><><><>");
|
||||
TEST_REGEX_REPLACE("[[:digit:]]*", perl, "123ab1", match_default|format_no_copy, "<$0>", "<123><><><1><>");
|
||||
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default|format_no_copy, "$`$", "...$");
|
||||
// and now escapes:
|
||||
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default|format_no_copy, "$x", "$x");
|
||||
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default|format_no_copy, "\\a", "\a");
|
||||
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default|format_no_copy, "\\f", "\f");
|
||||
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default|format_no_copy, "\\n", "\n");
|
||||
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default|format_no_copy, "\\r", "\r");
|
||||
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default|format_no_copy, "\\t", "\t");
|
||||
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default|format_no_copy, "\\v", "\v");
|
||||
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default|format_no_copy, "\\", "\\");
|
||||
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default|format_no_copy, "\\x21", "!");
|
||||
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default|format_no_copy, "\\xz", "xz");
|
||||
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default|format_no_copy, "\\x", "x");
|
||||
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default|format_no_copy, "\\x{z}", "x{z}");
|
||||
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default|format_no_copy, "\\x{12b", "x{12b");
|
||||
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default|format_no_copy, "\\x{21}", "!");
|
||||
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default|format_no_copy, "\\c@", "\0");
|
||||
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default|format_no_copy, "\\c", "c");
|
||||
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default|format_no_copy, "\\e", "\x1B");
|
||||
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default|format_no_copy, "\\0101", "A");
|
||||
TEST_REGEX_REPLACE("(a+)", perl, "...aaa,,,", match_default|format_no_copy, "\\u$1", "Aaa");
|
||||
TEST_REGEX_REPLACE("(a+)", perl, "...aaa,,,", match_default|format_no_copy, "\\U$1", "AAA");
|
||||
TEST_REGEX_REPLACE("(a+)", perl, "...aaa,,,", match_default|format_no_copy, "\\U$1\\E$1", "AAAaaa");
|
||||
TEST_REGEX_REPLACE("(A+)", perl, "...AAA,,,", match_default|format_no_copy, "\\l$1", "aAA");
|
||||
TEST_REGEX_REPLACE("(A+)", perl, "...AAA,,,", match_default|format_no_copy, "\\L$1", "aaa");
|
||||
TEST_REGEX_REPLACE("(A+)", perl, "...AAA,,,", match_default|format_no_copy, "\\L$1\\E$1", "aaaAAA");
|
||||
// sed format sequences:
|
||||
TEST_REGEX_REPLACE("(a+)(b+)", perl, " ...aabb,,", match_default|format_sed|format_no_copy, "\\0", "aabb");
|
||||
TEST_REGEX_REPLACE("(a+)(b+)", perl, " ...aabb,,", match_default|format_sed|format_no_copy, "\\1", "aa");
|
||||
TEST_REGEX_REPLACE("(a+)(b+)", perl, " ...aabb,,", match_default|format_sed|format_no_copy, "\\2", "bb");
|
||||
TEST_REGEX_REPLACE("(a+)(b+)", perl, " ...aabb,,", match_default|format_sed|format_no_copy, "&", "aabb");
|
||||
TEST_REGEX_REPLACE("(a+)(b+)", perl, " ...aabb,,", match_default|format_sed|format_no_copy, "$", "$");
|
||||
TEST_REGEX_REPLACE("(a+)(b+)", perl, " ...aabb,,", match_default|format_sed|format_no_copy, "$1", "$1");
|
||||
TEST_REGEX_REPLACE("(a+)(b+)", perl, " ...aabb,,", match_default|format_sed|format_no_copy, "()?:", "()?:");
|
||||
TEST_REGEX_REPLACE("(a+)(b+)", perl, " ...aabb,,", match_default|format_sed|format_no_copy, "\\\\", "\\");
|
||||
TEST_REGEX_REPLACE("(a+)(b+)", perl, " ...aabb,,", match_default|format_sed|format_no_copy, "\\&", "&");
|
||||
|
||||
TEST_REGEX_REPLACE("(a+)(b+)", perl, " ...aabb,,", match_default|format_perl|format_no_copy, "$0", "aabb");
|
||||
TEST_REGEX_REPLACE("(a+)(b+)", perl, " ...aabb,,", match_default|format_perl|format_no_copy, "$1", "aa");
|
||||
TEST_REGEX_REPLACE("(a+)(b+)", perl, " ...aabb,,", match_default|format_perl|format_no_copy, "$2", "bb");
|
||||
TEST_REGEX_REPLACE("(a+)(b+)", perl, " ...aabb,,", match_default|format_perl|format_no_copy, "$&", "aabb");
|
||||
TEST_REGEX_REPLACE("(a+)(b+)", perl, " ...aabb,,", match_default|format_perl|format_no_copy, "$$", "$");
|
||||
TEST_REGEX_REPLACE("(a+)(b+)", perl, " ...aabb,,", match_default|format_perl|format_no_copy, "&", "&");
|
||||
TEST_REGEX_REPLACE("(a+)(b+)", perl, " ...aabb,,", match_default|format_perl|format_no_copy, "\\0", "\0");
|
||||
TEST_REGEX_REPLACE("(a+)(b+)", perl, " ...aabb,,", match_default|format_perl|format_no_copy, "()?:", "()?:");
|
||||
TEST_REGEX_REPLACE("a+", perl, "...aaa,,", match_default|format_perl|format_no_copy, "\\0101", "A");
|
||||
|
||||
// move to copying unmatched data:
|
||||
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default|format_all, "bbb", "...bbb,,,");
|
||||
TEST_REGEX_REPLACE("a+(b+)", perl, "...aaabb,,,", match_default|format_all, "$1", "...bb,,,");
|
||||
TEST_REGEX_REPLACE("a+(b+)", perl, "...aaabb,,,ab*abbb?", match_default|format_all, "$1", "...bb,,,b*bbb?");
|
||||
TEST_REGEX_REPLACE("(a+)|(b+)", perl, "...aaabb,,,ab*abbb?", match_default|format_all, "(?1A)(?2B)", "...AB,,,AB*AB?");
|
||||
TEST_REGEX_REPLACE("(a+)|(b+)", perl, "...aaabb,,,ab*abbb?", match_default|format_all, "?1A:B", "...AB,,,AB*AB?");
|
||||
TEST_REGEX_REPLACE("(a+)|(b+)", perl, "...aaabb,,,ab*abbb?", match_default|format_all, "(?1A:B)C", "...ACBC,,,ACBC*ACBC?");
|
||||
TEST_REGEX_REPLACE("(a+)|(b+)", perl, "...aaabb,,,ab*abbb?", match_default|format_all, "?1:B", "...B,,,B*B?");
|
||||
// move to copying unmatched data, but replace first occurance only:
|
||||
TEST_REGEX_REPLACE("a+", perl, "...aaa,,,", match_default|format_all|format_first_only, "bbb", "...bbb,,,");
|
||||
TEST_REGEX_REPLACE("a+(b+)", perl, "...aaabb,,,", match_default|format_all|format_first_only, "$1", "...bb,,,");
|
||||
TEST_REGEX_REPLACE("a+(b+)", perl, "...aaabb,,,ab*abbb?", match_default|format_all|format_first_only, "$1", "...bb,,,ab*abbb?");
|
||||
TEST_REGEX_REPLACE("(a+)|(b+)", perl, "...aaabb,,,ab*abbb?", match_default|format_all|format_first_only, "(?1A)(?2B)", "...Abb,,,ab*abbb?");
|
||||
TEST_REGEX_REPLACE("(a+)|(b+)", perl, "...aaabb,,,ab*abbb?", match_default|format_all, "?1A", "...A,,,A*A?");
|
||||
TEST_REGEX_REPLACE("(a+)|(b+)", perl, "...aaabb,,,ab*abbb?", match_default|format_all, "?1:B", "...B,,,B*B?");
|
||||
TEST_REGEX_REPLACE("(a+)|(b+)", perl, "...aaabb,,,ab*abbb?", match_default|format_all, "(?1A:(?2B))", "...AB,,,AB*AB?");
|
||||
TEST_REGEX_REPLACE("X", literal, "XX", match_default, "Y", "YY");
|
||||
TEST_REGEX_REPLACE("(a+)|(b+)", perl, "...aaabb,,,ab*abbb?", match_default|format_all, "(?", "...??,,,??*???");
|
||||
TEST_REGEX_REPLACE("(a+)|(b+)", perl, "...aaabb,,,ab*abbb?", match_default|format_all, "(?a", "...?a?a,,,?a?a*?a?a?");
|
||||
TEST_REGEX_REPLACE("(a+)|(b+)", perl, "...aaabb,,,ab*abbb?", match_default|format_all, "(?1A:(?2B))abc", "...AabcBabc,,,AabcBabc*AabcBabc?");
|
||||
TEST_REGEX_REPLACE("a+(b+)", perl, "...aaabb,,,", match_default|format_all|format_no_copy, "(?2abc:def)", "def");
|
||||
TEST_REGEX_REPLACE("a+(b+)", perl, "...aaabb,,,", match_default|format_all|format_no_copy, "(?1abc:def)", "abc");
|
||||
TEST_REGEX_REPLACE("a+(b+)", perl, "...aaabb,,,", match_default|format_perl|format_no_copy, "(?1abc:def)", "(?1abc:def)");
|
||||
TEST_REGEX_REPLACE("a+(b+)", perl, "...", match_default|format_perl, "(?1abc:def)", "...");
|
||||
TEST_REGEX_REPLACE("a+(b+)", perl, "...", match_default|format_perl|format_no_copy, "(?1abc:def)", "");
|
||||
}
|
||||
|
230
test/regress/test_sets.cpp
Normal file
230
test/regress/test_sets.cpp
Normal file
@ -0,0 +1,230 @@
|
||||
/*
|
||||
*
|
||||
* 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"
|
||||
|
||||
void test_sets()
|
||||
{
|
||||
using namespace boost::regex_constants;
|
||||
// now test the set operator []
|
||||
TEST_REGEX_SEARCH("[abc]", extended, "a", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[abc]", extended, "b", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[abc]", extended, "c", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[abc]", extended, "d", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("[^bcd]", extended, "a", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[^bcd]", extended, "b", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("[^bcd]", extended, "d", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("[^bcd]", extended, "e", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a[b]c", extended, "abc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a[ab]c", extended, "abc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a[a^b]*c", extended, "aba^c", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("a[^ab]c", extended, "adc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a[]b]c", extended, "a]c", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a[[b]c", extended, "a[c", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a[-b]c", extended, "a-c", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a[^]b]c", extended, "adc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a[^-b]c", extended, "adc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a[b-]c", extended, "a-c", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_INVALID_REGEX("a[b", extended);
|
||||
TEST_INVALID_REGEX("a[", extended);
|
||||
TEST_INVALID_REGEX("a[]", extended);
|
||||
|
||||
// now some ranges:
|
||||
TEST_REGEX_SEARCH("[b-e]", extended, "a", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("[b-e]", extended, "b", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[b-e]", extended, "e", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[b-e]", extended, "f", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("[^b-e]", extended, "a", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[^b-e]", extended, "b", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("[^b-e]", extended, "e", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("[^b-e]", extended, "f", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a[1-3]c", extended, "a2c", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a[-3]c", extended, "a-c", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a[-3]c", extended, "a3c", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a[^-3]c", extended, "a-c", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("a[^-3]c", extended, "a3c", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("a[^-3]c", extended, "axc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_INVALID_REGEX("a[3-1]c", extended);
|
||||
TEST_INVALID_REGEX("a[1-3-5]c", extended);
|
||||
TEST_INVALID_REGEX("a[1-", extended);
|
||||
TEST_INVALID_REGEX("a[\\9]", perl);
|
||||
|
||||
// and some classes
|
||||
TEST_REGEX_SEARCH("a[[:alpha:]]c", extended, "abc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_INVALID_REGEX("a[[:unknown:]]c", extended);
|
||||
TEST_INVALID_REGEX("a[[", extended);
|
||||
TEST_INVALID_REGEX("a[[:", extended);
|
||||
TEST_INVALID_REGEX("a[[:a", extended);
|
||||
TEST_INVALID_REGEX("a[[:alpha", extended);
|
||||
TEST_INVALID_REGEX("a[[:alpha:", extended);
|
||||
TEST_INVALID_REGEX("a[[:alpha:]", extended);
|
||||
TEST_INVALID_REGEX("a[[:alpha:!", extended);
|
||||
TEST_INVALID_REGEX("a[[:alpha,:]", extended);
|
||||
TEST_INVALID_REGEX("a[[:]:]]b", extended);
|
||||
TEST_INVALID_REGEX("a[[:-:]]b", extended);
|
||||
TEST_INVALID_REGEX("a[[:alph:]]", extended);
|
||||
TEST_INVALID_REGEX("a[[:alphabet:]]", extended);
|
||||
TEST_REGEX_SEARCH("[[:alnum:]]+", extended, "-%@a0X_-", match_default, make_array(3, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[:alpha:]]+", extended, " -%@aX_0-", match_default, make_array(4, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[:blank:]]+", extended, "a \tb", match_default, make_array(1, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[:cntrl:]]+", extended, " a\n\tb", match_default, make_array(2, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[:digit:]]+", extended, "a019b", match_default, make_array(1, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[:graph:]]+", extended, " a%b ", match_default, make_array(1, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[:lower:]]+", extended, "AabC", match_default, make_array(1, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[:print:]]+", extended, "AabC", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[:punct:]]+", extended, " %-&\t", match_default, make_array(1, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[:space:]]+", extended, "a \n\t\rb", match_default, make_array(1, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[:upper:]]+", extended, "aBCd", match_default, make_array(1, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[:xdigit:]]+", extended, "p0f3Cx", match_default, make_array(1, 5, -2, -2));
|
||||
|
||||
//
|
||||
// escapes are supported in character classes if we have either
|
||||
// perl or awk regular expressions:
|
||||
//
|
||||
TEST_REGEX_SEARCH("[\\n]", perl, "\n", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[\\b]", perl, "\b", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[\\n]", basic, "\n", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("[\\n]", basic, "\\", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[:class:]", basic|no_char_classes, ":", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[:class:]", basic|no_char_classes, "[", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[:class:]", basic|no_char_classes, "c", match_default, make_array(0, 1, -2, -2));
|
||||
//
|
||||
// test single character escapes:
|
||||
//
|
||||
TEST_REGEX_SEARCH("\\w", perl, "A", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\w", perl, "Z", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\w", perl, "a", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\w", perl, "z", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\w", perl, "_", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\w", perl, "}", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("\\w", perl, "`", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("\\w", perl, "[", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("\\w", perl, "@", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("\\W", perl, "a", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("\\W", perl, "z", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("\\W", perl, "A", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("\\W", perl, "Z", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("\\W", perl, "_", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("\\W", perl, "}", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\W", perl, "`", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\W", perl, "[", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\W", perl, "@", match_default, make_array(0, 1, -2, -2));
|
||||
}
|
||||
|
||||
void test_sets2()
|
||||
{
|
||||
using namespace boost::regex_constants;
|
||||
// collating elements
|
||||
TEST_REGEX_SEARCH("[[.zero.]]", perl, "0", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.one.]]", perl, "1", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.two.]]", perl, "2", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.three.]]", perl, "3", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.a.]]", perl, "bac", match_default, make_array(1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.\xf0.]]", perl, "b\xf0x", match_default, make_array(1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.right-curly-bracket.]]", perl, "}", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.NUL.]]", perl, "\0", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.NUL.][.ae.]]", perl, "\0", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_INVALID_REGEX("[[..]]", perl);
|
||||
TEST_INVALID_REGEX("[[.not-a-collating-element.]]", perl);
|
||||
TEST_INVALID_REGEX("[[.", perl);
|
||||
TEST_INVALID_REGEX("[[.N", perl);
|
||||
TEST_INVALID_REGEX("[[.NUL", perl);
|
||||
TEST_INVALID_REGEX("[[.NUL.", perl);
|
||||
TEST_INVALID_REGEX("[[.NUL.]", perl);
|
||||
TEST_INVALID_REGEX("[[:<:]z]", perl);
|
||||
TEST_INVALID_REGEX("[a[:>:]]", perl);
|
||||
TEST_REGEX_SEARCH("[[.A.]]", extended|icase, "A", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.A.]]", extended|icase, "a", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.A.]-b]+", extended|icase, "AaBb", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("[A-[.b.]]+", extended|icase, "AaBb", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.a.]-B]+", extended|icase, "AaBb", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("[a-[.B.]]+", extended|icase, "AaBb", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("[\x61]", extended, "a", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[\x61-c]+", extended, "abcd", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("[a-\x63]+", extended, "abcd", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.a.]-c]+", extended, "abcd", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("[a-[.c.]]+", extended, "abcd", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_INVALID_REGEX("[[:alpha:]-a]", extended);
|
||||
TEST_INVALID_REGEX("[a-[:alpha:]]", extended);
|
||||
TEST_REGEX_SEARCH("[[.ae.]]", basic, "ae", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.ae.]]", basic, "aE", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("[[.AE.]]", basic, "AE", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.Ae.]]", basic, "Ae", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.ae.]-b]", basic, "a", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("[[.ae.]-b]", basic, "b", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.ae.]-b]", basic, "ae", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("[a-[.ae.]]", basic, "a", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[a-[.ae.]]", basic, "b", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("[a-[.ae.]]", basic, "ae", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.ae.]]", basic|icase, "AE", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.ae.]]", basic|icase, "Ae", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.AE.]]", basic|icase, "Ae", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.Ae.]]", basic|icase, "aE", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.AE.]-B]", basic|icase, "a", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("[[.Ae.]-b]", basic|icase, "b", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.Ae.]-b]", basic|icase, "B", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.ae.]-b]", basic|icase, "AE", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.ae.]]", perl, "ae", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.ae.]]", perl, "aE", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("[[.AE.]]", perl, "AE", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.Ae.]]", perl, "Ae", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.ae.]-b]", perl, "a", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("[[.ae.]-b]", perl, "b", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.ae.]-b]", perl, "ae", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("[a-[.ae.]]", perl, "a", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[a-[.ae.]]", perl, "b", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("[a-[.ae.]]", perl, "ae", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.ae.]]", perl|icase, "AE", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.ae.]]", perl|icase, "Ae", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.AE.]]", perl|icase, "Ae", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.Ae.]]", perl|icase, "aE", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.AE.]-B]", perl|icase, "a", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("[[.Ae.]-b]", perl|icase, "b", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.Ae.]-b]", perl|icase, "B", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.ae.]-b]", perl|icase, "AE", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.ae.][:lower:]]", perl|icase, "AE", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.ae.][:lower:]]", perl|icase, "A", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[.ae.][=a=]]+", perl, "zzaA", match_default, make_array(2, 4, -2, -2));
|
||||
TEST_INVALID_REGEX("[d-[.ae.]]", perl);
|
||||
//
|
||||
// try some equivalence classes:
|
||||
//
|
||||
TEST_REGEX_SEARCH("[[=a=]]", basic, "a", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[=a=]]", basic, "A", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[=ae=]]", basic, "ae", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[=right-curly-bracket=]]", basic, "}", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_INVALID_REGEX("[[=", perl);
|
||||
TEST_INVALID_REGEX("[[=a", perl);
|
||||
TEST_INVALID_REGEX("[[=ae", perl);
|
||||
TEST_INVALID_REGEX("[[=ae=", perl);
|
||||
TEST_INVALID_REGEX("[[=ae=]", perl);
|
||||
//
|
||||
// now some perl style single character classes:
|
||||
//
|
||||
TEST_REGEX_SEARCH("\\l+", perl, "ABabcAB", match_default, make_array(2, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("[\\l]+", perl, "ABabcAB", match_default, make_array(2, 5, -2, -2));
|
||||
TEST_INVALID_REGEX("[\\l-a]", perl);
|
||||
TEST_INVALID_REGEX("[\\L]", perl);
|
||||
TEST_REGEX_SEARCH("\\L+", perl, "abABCab", match_default, make_array(2, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\u+", perl, "abABCab", match_default, make_array(2, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("[\\u]+", perl, "abABCab", match_default, make_array(2, 5, -2, -2));
|
||||
TEST_INVALID_REGEX("[\\U]", perl);
|
||||
TEST_REGEX_SEARCH("\\U+", perl, "ABabcAB", match_default, make_array(2, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\d+", perl, "AB012AB", match_default, make_array(2, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("[\\d]+", perl, "AB012AB", match_default, make_array(2, 5, -2, -2));
|
||||
TEST_INVALID_REGEX("[\\D]", perl);
|
||||
TEST_REGEX_SEARCH("\\D+", perl, "01abc01", match_default, make_array(2, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\s+", perl, "AB AB", match_default, make_array(2, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("[\\s]+", perl, "AB AB", match_default, make_array(2, 5, -2, -2));
|
||||
TEST_INVALID_REGEX("[\\S]", perl);
|
||||
TEST_REGEX_SEARCH("\\S+", perl, " abc ", match_default, make_array(2, 5, -2, -2));
|
||||
}
|
||||
|
341
test/regress/test_simple_repeats.cpp
Normal file
341
test/regress/test_simple_repeats.cpp
Normal file
@ -0,0 +1,341 @@
|
||||
/*
|
||||
*
|
||||
* 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"
|
||||
|
||||
void test_simple_repeats()
|
||||
{
|
||||
using namespace boost::regex_constants;
|
||||
// simple repeats:
|
||||
TEST_REGEX_SEARCH("a*", perl, "b", match_default, make_array(0, 0, -2, 1, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab*", perl, "ab", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab*", basic, "ab", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab*", perl, "sssabbbbbbsss", match_default, make_array(3, 10, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab*c*", perl, "a", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab*c*", perl, "abbb", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab*c*", perl, "accc", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab*c*", perl, "abbcc", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("*a", basic, "*a", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("^*a", basic, "*a", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_INVALID_REGEX("*a", perl);
|
||||
TEST_INVALID_REGEX("\\<*", perl);
|
||||
TEST_INVALID_REGEX("\\>*", perl);
|
||||
TEST_REGEX_SEARCH("\n*", perl, "\n\n", match_default, make_array(0, 2, -2, 2, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\**", perl, "**", match_default, make_array(0, 2, -2, 2, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\*", perl, "*", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("(ab)*", perl, "abab", match_default, make_array(0, 4, 2, 4, -2, 4, 4, -2, -2));
|
||||
|
||||
// now try operator + :
|
||||
TEST_REGEX_SEARCH("ab+", perl, "a", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("ab+", perl, "ab", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab+", perl, "sssabbbbbbsss", match_default, make_array(3, 10, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab+c+", perl, "abbb", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("ab+c+", perl, "accc", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("ab+c+", perl, "abbcc", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_INVALID_REGEX("+a", perl);
|
||||
TEST_INVALID_REGEX("\\<+", perl);
|
||||
TEST_INVALID_REGEX("\\>+", perl);
|
||||
TEST_REGEX_SEARCH("\n+", perl, "\n\n", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\+", perl, "+", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\+", perl, "++", match_default, make_array(0, 1, -2, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\++", perl, "++", match_default, make_array(0, 2, -2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("+", basic|bk_plus_qm, "+", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_INVALID_REGEX("\\+", basic|bk_plus_qm);
|
||||
TEST_REGEX_SEARCH("a\\+", basic|bk_plus_qm, "aa", match_default, make_array(0, 2, -2, -2));
|
||||
|
||||
// now try operator ?
|
||||
TEST_REGEX_SEARCH("a?", perl, "b", match_default, make_array(0, 0, -2, 1, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab?", perl, "a", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab?", perl, "ab", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab?", perl, "sssabbbbbbsss", match_default, make_array(3, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab?c?", perl, "a", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab?c?", perl, "abbb", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab?c?", perl, "accc", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab?c?", perl, "abcc", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_INVALID_REGEX("?a", perl);
|
||||
TEST_INVALID_REGEX("\\<?", perl);
|
||||
TEST_INVALID_REGEX("\\>?", perl);
|
||||
TEST_REGEX_SEARCH("\n?", perl, "\n\n", match_default, make_array(0, 1, -2, 1, 2, -2, 2, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\?", perl, "?", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\?", perl, "?", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\??", perl, "??", match_default, make_array(0, 1, -2, 1, 2, -2, 2, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("?", basic|bk_plus_qm, "?", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_INVALID_REGEX("\\?", basic|bk_plus_qm);
|
||||
TEST_REGEX_SEARCH("a\\?", basic|bk_plus_qm, "aa", match_default, make_array(0, 1, -2, 1, 2, -2, 2, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\?", basic|bk_plus_qm, "b", match_default, make_array(0, 0, -2, 1, 1, -2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("a?", basic, "a?", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a+", basic, "a+", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\?", basic, "a?", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\+", basic, "a+", match_default, make_array(0, 2, -2, -2));
|
||||
|
||||
// now try operator {}
|
||||
TEST_REGEX_SEARCH("a{2}", perl, "a", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("a{2}", perl, "aa", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a{2}", perl, "aaa", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a{2,}", perl, "a", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("a{2,}", perl, "aa", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a{2,}", perl, "aaaaa", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("a{2,4}", perl, "a", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("a{2,4}", perl, "aa", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a{2,4}", perl, "aaa", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a{2,4}", perl, "aaaa", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("a{2,4}", perl, "aaaaa", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("a{ 2 , 4 }", perl, "aaaaa", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("a{ 2 , }", perl, "aaaaa", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("a{ 2 }", perl, "aaa", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\{\\}", perl, "a{}", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_INVALID_REGEX("a{}", perl);
|
||||
TEST_INVALID_REGEX("a{", perl);
|
||||
TEST_INVALID_REGEX("a{1", perl);
|
||||
TEST_INVALID_REGEX("a{1,", perl);
|
||||
TEST_INVALID_REGEX("a{1,2", perl);
|
||||
TEST_INVALID_REGEX("a{ 1 , 2 ", perl);
|
||||
TEST_INVALID_REGEX("a{ }", perl);
|
||||
TEST_INVALID_REGEX("a}", perl);
|
||||
TEST_INVALID_REGEX("{1}", perl);
|
||||
TEST_INVALID_REGEX("a{b}", perl);
|
||||
TEST_INVALID_REGEX("a{1b}", perl);
|
||||
TEST_INVALID_REGEX("a{1,b}", perl);
|
||||
TEST_INVALID_REGEX("a{1,2v}", perl);
|
||||
TEST_INVALID_REGEX("a{2,1}", perl);
|
||||
|
||||
// now try operator \\{\\} for POSIX basic regexes
|
||||
TEST_REGEX_SEARCH("a\\{2\\}", basic, "a", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("a\\{2\\}", basic|no_intervals, "a{2}", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\{2\\}", basic, "aa", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\{2\\}", basic, "aaa", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\{2,\\}", basic, "a", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("a\\{2,\\}", basic, "aa", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\{2,\\}", basic, "aaaaa", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\{2,4\\}", basic, "a", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("a\\{2,4\\}", basic, "aa", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\{2,4\\}", basic, "aaa", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\{2,4\\}", basic, "aaaa", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\{2,4\\}", basic, "aaaaa", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\{ 2 , 4 \\}", basic, "aaaaa", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\{ 2 , \\}", basic, "aaaaa", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\{ 2 \\}", basic, "aaa", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a{}", basic, "a{}", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_INVALID_REGEX("a\\{\\}", basic);
|
||||
TEST_INVALID_REGEX("a\\{", basic);
|
||||
TEST_INVALID_REGEX("a\\{1", basic);
|
||||
TEST_INVALID_REGEX("a\\{1,", basic);
|
||||
TEST_INVALID_REGEX("a\\{1,\\", basic);
|
||||
TEST_INVALID_REGEX("a\\{ \\}", basic);
|
||||
TEST_INVALID_REGEX("a\\}", basic);
|
||||
TEST_INVALID_REGEX("\\{1\\}", basic);
|
||||
TEST_INVALID_REGEX("a\\{b\\}", basic);
|
||||
TEST_INVALID_REGEX("a\\{1b\\}", basic);
|
||||
TEST_INVALID_REGEX("a\\{1,b\\}", basic);
|
||||
TEST_INVALID_REGEX("a\\{1,2v\\}", basic);
|
||||
TEST_INVALID_REGEX("a\\{3,1\\}", basic);
|
||||
|
||||
}
|
||||
|
||||
void test_fast_repeats()
|
||||
{
|
||||
using namespace boost::regex_constants;
|
||||
// extended repeat checking to exercise new algorithms:
|
||||
TEST_REGEX_SEARCH("ab.*xy", perl, "abxy_", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.*xy", perl, "ab_xy_", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.*xy", perl, "abxy", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.*xy", perl, "ab_xy", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.*", perl, "ab", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.*", perl, "ab__", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH(".*xy", perl, "abc", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH(".*?xy", perl, "abc", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("a+?xy", perl, "abc", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("ab.{2,5}xy", perl, "ab__xy_", match_default, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}xy", perl, "ab____xy_", match_default, make_array(0, 8, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}xy", perl, "ab_____xy_", match_default, make_array(0, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}xy", perl, "ab__xy", match_default, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}xy", perl, "ab_____xy", match_default, make_array(0, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}", perl, "ab__", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}", perl, "ab_______", match_default, make_array(0, 7, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}xy", perl, "ab______xy", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}xy", perl, "ab_xy", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("ab.*?xy", perl, "abxy_", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.*?xy", perl, "ab_xy_", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.*?xy", perl, "abxy", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.*?xy", perl, "ab_xy", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.*?", perl, "ab", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.*?", perl, "ab__", match_default, make_array(0, 2, -2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("ab.{2,5}?xy", perl, "ab__xy_", match_default, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}?xy", perl, "ab____xy_", match_default, make_array(0, 8, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}?xy", perl, "ab_____xy_", match_default, make_array(0, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}?xy", perl, "ab__xy", match_default, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}?xy", perl, "ab_____xy", match_default, make_array(0, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}?", perl, "ab__", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}?", perl, "ab_______", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}?xy", perl, "ab______xy", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}xy", perl, "ab_xy", match_default, make_array(-2, -2));
|
||||
|
||||
// again but with slower algorithm variant:
|
||||
TEST_REGEX_SEARCH("ab.*xy", perl, "abxy_", match_not_dot_newline|match_not_dot_null, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.*xy", perl, "ab_xy_", match_not_dot_newline|match_not_dot_null, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.*xy", perl, "abxy", match_not_dot_newline|match_not_dot_null, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.*xy", perl, "ab_xy", match_not_dot_newline|match_not_dot_null, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.*", perl, "ab", match_not_dot_newline|match_not_dot_null, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.*", perl, "ab__", match_not_dot_newline|match_not_dot_null, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH(".*xy", perl, "abc", match_not_dot_newline|match_not_dot_null, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH(".*?xy", perl, "abc", match_not_dot_newline|match_not_dot_null, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH(".*xy", perl, "ab\nbc", match_not_dot_newline|match_not_dot_null, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH(".*?xy", perl, "ax\nbc", match_not_dot_newline|match_not_dot_null, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("ab.{2,5}xy", perl, "ab__xy_", match_not_dot_newline|match_not_dot_null, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}xy", perl, "ab____xy_", match_not_dot_newline|match_not_dot_null, make_array(0, 8, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}xy", perl, "ab_____xy_", match_not_dot_newline|match_not_dot_null, make_array(0, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}xy", perl, "ab__xy", match_not_dot_newline|match_not_dot_null, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}xy", perl, "ab_____xy", match_not_dot_newline|match_not_dot_null, make_array(0, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}", perl, "ab__", match_not_dot_newline|match_not_dot_null, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}", perl, "ab_______", match_not_dot_newline|match_not_dot_null, make_array(0, 7, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}xy", perl, "ab______xy", match_not_dot_newline|match_not_dot_null, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}xy", perl, "ab_xy", match_not_dot_newline|match_not_dot_null, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("ab.*?xy", perl, "abxy_", match_not_dot_newline|match_not_dot_null, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.*?xy", perl, "ab_xy_", match_not_dot_newline|match_not_dot_null, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.*?xy", perl, "abxy", match_not_dot_newline|match_not_dot_null, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.*?xy", perl, "ab_xy", match_not_dot_newline|match_not_dot_null, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.*?", perl, "ab", match_not_dot_newline|match_not_dot_null, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.*?", perl, "ab__", match_not_dot_newline|match_not_dot_null, make_array(0, 2, -2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("ab.{2,5}?xy", perl, "ab__xy_", match_not_dot_newline|match_not_dot_null, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}?xy", perl, "ab____xy_", match_not_dot_newline|match_not_dot_null, make_array(0, 8, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}?xy", perl, "ab_____xy_", match_not_dot_newline|match_not_dot_null, make_array(0, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}?xy", perl, "ab__xy", match_not_dot_newline|match_not_dot_null, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}?xy", perl, "ab_____xy", match_not_dot_newline|match_not_dot_null, make_array(0, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}?", perl, "ab__", match_not_dot_newline|match_not_dot_null, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}?", perl, "ab_______", match_not_dot_newline|match_not_dot_null, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}?xy", perl, "ab______xy", match_not_dot_newline|match_not_dot_null, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("ab.{2,5}xy", perl, "ab_xy", match_not_dot_newline|match_not_dot_null, make_array(-2, -2));
|
||||
|
||||
// now again for single character repeats:
|
||||
TEST_REGEX_SEARCH("ab_*xy", perl, "abxy_", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab_*xy", perl, "ab_xy_", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab_*xy", perl, "abxy", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab_*xy", perl, "ab_xy", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab_*", perl, "ab", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab_*", perl, "ab__", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab_*?z", perl, "ab__", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("ab_{2,5}xy", perl, "ab__xy_", match_default, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab_{2,5}xy", perl, "ab____xy_", match_default, make_array(0, 8, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab_{2,5}xy", perl, "ab_____xy_", match_default, make_array(0, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab_{2,5}xy", perl, "ab__xy", match_default, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab_{2,5}xy", perl, "ab_____xy", match_default, make_array(0, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab_{2,5}", perl, "ab__", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab_{2,5}", perl, "ab_______", match_default, make_array(0, 7, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab_{2,5}xy", perl, "ab______xy", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("ab_{2,5}xy", perl, "ab_xy", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("ab_*?xy", perl, "abxy_", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab_*?xy", perl, "ab_xy_", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab_*?xy", perl, "abxy", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab_*?xy", perl, "ab_xy", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab_*?", perl, "ab", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab_*?", perl, "ab__", match_default, make_array(0, 2, -2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("ab_{2,5}?xy", perl, "ab__xy_", match_default, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab_{2,5}?xy", perl, "ab____xy_", match_default, make_array(0, 8, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab_{2,5}?xy", perl, "ab_____xy_", match_default, make_array(0, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab_{2,5}?xy", perl, "ab__xy", match_default, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab_{2,5}?xy", perl, "ab_____xy", match_default, make_array(0, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab_{2,5}?", perl, "ab__", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab_{2,5}?", perl, "ab_______", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab_{2,5}?xy", perl, "ab______xy", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("ab_{2,5}xy", perl, "ab_xy", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(5*?).somesite", perl, "//555.somesite", match_default, make_array(2, 14, 2, 5, -2, -2));
|
||||
}
|
||||
|
||||
void test_fast_repeats2()
|
||||
{
|
||||
using namespace boost::regex_constants;
|
||||
// and again for sets:
|
||||
TEST_REGEX_SEARCH("ab[_,;]*xy", perl, "abxy_", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]*xy", perl, "ab_xy_", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]*xy", perl, "abxy", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]*xy", perl, "ab_xy", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]*", perl, "ab", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]*", perl, "ab__", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]*?xy", perl, "ab__z", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]*?z", perl, "ab__", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]*?.z", perl, "ab__,;,__z", match_default, make_array(0, 10, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]*?.z", perl, "ab__,;,__y", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("ab[_,;]{2,5}xy", perl, "ab__xy_", match_default, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]{2,5}xy", perl, "ab____xy_", match_default, make_array(0, 8, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]{2,5}xy", perl, "ab_____xy_", match_default, make_array(0, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]{2,5}xy", perl, "ab__xy", match_default, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]{2,5}xy", perl, "ab_____xy", match_default, make_array(0, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]{2,5}", perl, "ab__", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]{2,5}", perl, "ab_______", match_default, make_array(0, 7, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]{2,5}xy", perl, "ab______xy", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]{2,5}xy", perl, "ab_xy", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("ab[_,;]*?xy", perl, "abxy_", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]*?xy", perl, "ab_xy_", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]*?xy", perl, "abxy", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]*?xy", perl, "ab_xy", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]*?", perl, "ab", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]*?", perl, "ab__", match_default, make_array(0, 2, -2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("ab[_,;]{2,5}?xy", perl, "ab__xy_", match_default, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]{2,5}?xy", perl, "ab____xy_", match_default, make_array(0, 8, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]{2,5}?xy", perl, "ab_____xy_", match_default, make_array(0, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]{2,5}?xy", perl, "ab__xy", match_default, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]{2,5}?xy", perl, "ab_____xy", match_default, make_array(0, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]{2,5}?", perl, "ab__", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]{2,5}?", perl, "ab_______", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]{2,5}?xy", perl, "ab______xy", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_,;]{2,5}xy", perl, "ab_xy", match_default, make_array(-2, -2));
|
||||
|
||||
// and again for tricky sets with digraphs:
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]*xy", perl, "abxy_", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]*xy", perl, "ab_xy_", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]*xy", perl, "abxy", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]*xy", perl, "ab_xy", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]*", perl, "ab", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]*", perl, "ab__", match_default, make_array(0, 4, -2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]{2,5}xy", perl, "ab__xy_", match_default, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]{2,5}xy", perl, "ab____xy_", match_default, make_array(0, 8, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]{2,5}xy", perl, "ab_____xy_", match_default, make_array(0, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]{2,5}xy", perl, "ab__xy", match_default, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]{2,5}xy", perl, "ab_____xy", match_default, make_array(0, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]{2,5}", perl, "ab__", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]{2,5}", perl, "ab_______", match_default, make_array(0, 7, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]{2,5}xy", perl, "ab______xy", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]{2,5}xy", perl, "ab_xy", match_default, make_array(-2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]*?xy", perl, "abxy_", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]*?xy", perl, "ab_xy_", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]*?xy", perl, "abxy", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]*?xy", perl, "ab_xy", match_default, make_array(0, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]*?", perl, "ab", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]*?", perl, "ab__", match_default, make_array(0, 2, -2, -2));
|
||||
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]{2,5}?xy", perl, "ab__xy_", match_default, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]{2,5}?xy", perl, "ab____xy_", match_default, make_array(0, 8, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]{2,5}?xy", perl, "ab_____xy_", match_default, make_array(0, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]{2,5}?xy", perl, "ab__xy", match_default, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]{2,5}?xy", perl, "ab_____xy", match_default, make_array(0, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]{2,5}?", perl, "ab__", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]{2,5}?", perl, "ab_______", match_default, make_array(0, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]{2,5}?xy", perl, "ab______xy", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("ab[_[.ae.]]{2,5}xy", perl, "ab_xy", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("([5[.ae.]]*?).somesite", perl, "//555.somesite", match_default, make_array(2, 14, 2, 5, -2, -2));
|
||||
}
|
||||
|
292
test/regress/test_tricky_cases.cpp
Normal file
292
test/regress/test_tricky_cases.cpp
Normal file
@ -0,0 +1,292 @@
|
||||
/*
|
||||
*
|
||||
* 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"
|
||||
|
||||
void test_tricky_cases()
|
||||
{
|
||||
using namespace boost::regex_constants;
|
||||
//
|
||||
// now follows various complex expressions designed to try and bust the matcher:
|
||||
//
|
||||
TEST_REGEX_SEARCH("a(((b)))c", perl, "abc", match_default, make_array(0, 3, 1, 2, 1, 2, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|(c))d", perl, "abd", match_default, make_array(0, 3, 1, 2, -1, -1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|(c))d", perl, "acd", match_default, make_array(0, 3, 1, 2, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b*|c)d", perl, "abbd", match_default, make_array(0, 4, 1, 3, -2, -2));
|
||||
// just gotta have one DFA-buster, of course
|
||||
TEST_REGEX_SEARCH("a[ab]{20}", perl, "aaaaabaaaabaaaabaaaab", match_default, make_array(0, 21, -2, -2));
|
||||
// and an inline expansion in case somebody gets tricky
|
||||
TEST_REGEX_SEARCH("a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab]", perl, "aaaaabaaaabaaaabaaaab", match_default, make_array(0, 21, -2, -2));
|
||||
// and in case somebody just slips in an NFA...
|
||||
TEST_REGEX_SEARCH("a[ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab][ab](wee|week)(knights|night)", perl, "aaaaabaaaabaaaabaaaabweeknights", match_default, make_array(0, 31, 21, 24, 24, 31, -2, -2));
|
||||
// one really big one
|
||||
TEST_REGEX_SEARCH("1234567890123456789012345678901234567890123456789012345678901234567890", perl, "a1234567890123456789012345678901234567890123456789012345678901234567890b", match_default, make_array(1, 71, -2, -2));
|
||||
// fish for problems as brackets go past 8
|
||||
TEST_REGEX_SEARCH("[ab][cd][ef][gh][ij][kl][mn]", perl, "xacegikmoq", match_default, make_array(1, 8, -2, -2));
|
||||
TEST_REGEX_SEARCH("[ab][cd][ef][gh][ij][kl][mn][op]", perl, "xacegikmoq", match_default, make_array(1, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("[ab][cd][ef][gh][ij][kl][mn][op][qr]", perl, "xacegikmoqy", match_default, make_array(1, 10, -2, -2));
|
||||
TEST_REGEX_SEARCH("[ab][cd][ef][gh][ij][kl][mn][op][q]", perl, "xacegikmoqy", match_default, make_array(1, 10, -2, -2));
|
||||
// and as parenthesis go past 9:
|
||||
TEST_REGEX_SEARCH("(a)(b)(c)(d)(e)(f)(g)(h)", perl, "zabcdefghi", match_default, make_array(1, 9, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, -2, -2));
|
||||
TEST_REGEX_SEARCH("(a)(b)(c)(d)(e)(f)(g)(h)(i)", perl, "zabcdefghij", match_default, make_array(1, 10, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, -2, -2));
|
||||
TEST_REGEX_SEARCH("(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)", perl, "zabcdefghijk", match_default, make_array(1, 11, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, -2, -2));
|
||||
TEST_REGEX_SEARCH("(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)", perl, "zabcdefghijkl", match_default, make_array(1, 12, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, -2, -2));
|
||||
TEST_REGEX_SEARCH("(a)d|(b)c", perl, "abc", match_default, make_array(1, 3, -1, -1, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("_+((www)|(ftp)|(mailto)):_*", perl, "_wwwnocolon _mailto:", match_default, make_array(12, 20, 13, 19, -1, -1, -1, -1, 13, 19, -2, -2));
|
||||
// subtleties of matching
|
||||
TEST_REGEX_SEARCH("a(b)?c\\1d", perl, "acd", match_default, make_array(0, 3, -1, -1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b?c)+d", perl, "accd", match_default, make_array(0, 4, 2, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("(wee|week)(knights|night)", perl, "weeknights", match_default, make_array(0, 10, 0, 3, 3, 10, -2, -2));
|
||||
TEST_REGEX_SEARCH(".*", perl, "abc", match_default, make_array(0, 3, -2, 3, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|(c))d", perl, "abd", match_default, make_array(0, 3, 1, 2, -1, -1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|(c))d", perl, "acd", match_default, make_array(0, 3, 1, 2, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b*|c|e)d", perl, "abbd", match_default, make_array(0, 4, 1, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b*|c|e)d", perl, "acd", match_default, make_array(0, 3, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b*|c|e)d", perl, "ad", match_default, make_array(0, 2, 1, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b?)c", perl, "abc", match_default, make_array(0, 3, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b?)c", perl, "ac", match_default, make_array(0, 2, 1, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b+)c", perl, "abc", match_default, make_array(0, 3, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b+)c", perl, "abbbc", match_default, make_array(0, 5, 1, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b*)c", perl, "ac", match_default, make_array(0, 2, 1, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("(a|ab)(bc([de]+)f|cde)", perl, "abcdef", match_default, make_array(0, 6, 0, 1, 1, 6, 3, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("a([bc]?)c", perl, "abc", match_default, make_array(0, 3, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a([bc]?)c", perl, "ac", match_default, make_array(0, 2, 1, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a([bc]+)c", perl, "abc", match_default, make_array(0, 3, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a([bc]+)c", perl, "abcc", match_default, make_array(0, 4, 1, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a([bc]+)bc", perl, "abcbc", match_default, make_array(0, 5, 1, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(bb+|b)b", perl, "abb", match_default, make_array(0, 3, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(bbb+|bb+|b)b", perl, "abb", match_default, make_array(0, 3, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(bbb+|bb+|b)b", perl, "abbb", match_default, make_array(0, 4, 1, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(bbb+|bb+|b)bb", perl, "abbb", match_default, make_array(0, 4, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("(.*).*", perl, "abcdef", match_default, make_array(0, 6, 0, 6, -2, 6, 6, 6, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("(a*)*", perl, "bc", match_default, make_array(0, 0, 0, 0, -2, 1, 1, 1, 1, -2, 2, 2, 2, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("xyx*xz", perl, "xyxxxxyxxxz", match_default, make_array(5, 11, -2, -2));
|
||||
// do we get the right subexpression when it is used more than once?
|
||||
TEST_REGEX_SEARCH("a(b|c)*d", perl, "ad", match_default, make_array(0, 2, -1, -1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|c)*d", perl, "abcd", match_default, make_array(0, 4, 2, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|c)+d", perl, "abd", match_default, make_array(0, 3, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|c)+d", perl, "abcd", match_default, make_array(0, 4, 2, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|c?)+d", perl, "ad", match_default, make_array(0, 2, 1, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|c){0,0}d", perl, "ad", match_default, make_array(0, 2, -1, -1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|c){0,1}d", perl, "ad", match_default, make_array(0, 2, -1, -1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|c){0,1}d", perl, "abd", match_default, make_array(0, 3, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|c){0,2}d", perl, "ad", match_default, make_array(0, 2, -1, -1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|c){0,2}d", perl, "abcd", match_default, make_array(0, 4, 2, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|c){0,}d", perl, "ad", match_default, make_array(0, 2, -1, -1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|c){0,}d", perl, "abcd", match_default, make_array(0, 4, 2, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|c){1,1}d", perl, "abd", match_default, make_array(0, 3, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|c){1,2}d", perl, "abd", match_default, make_array(0, 3, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|c){1,2}d", perl, "abcd", match_default, make_array(0, 4, 2, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|c){1,}d", perl, "abd", match_default, make_array(0, 3, 1, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|c){1,}d", perl, "abcd", match_default, make_array(0, 4, 2, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|c){2,2}d", perl, "acbd", match_default, make_array(0, 4, 2, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|c){2,2}d", perl, "abcd", match_default, make_array(0, 4, 2, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|c){2,4}d", perl, "abcd", match_default, make_array(0, 4, 2, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|c){2,4}d", perl, "abcbd", match_default, make_array(0, 5, 3, 4, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|c){2,4}d", perl, "abcbcd", match_default, make_array(0, 6, 4, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|c){2,}d", perl, "abcd", match_default, make_array(0, 4, 2, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|c){2,}d", perl, "abcbd", match_default, make_array(0, 5, 3, 4, -2, -2));
|
||||
// perl only:
|
||||
TEST_REGEX_SEARCH("a(b|c?)+d", perl, "abcd", match_default, make_array(0, 4, 3, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b+|((c)*))+d", perl, "abd", match_default, make_array(0, 3, 2, 2, 2, 2, -1, -1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b+|((c)*))+d", perl, "abcd", match_default, make_array(0, 4, 3, 3, 3, 3, 2, 3, -2, -2));
|
||||
// posix only:
|
||||
TEST_REGEX_SEARCH("a(b|c?)+d", extended, "abcd", match_default, make_array(0, 4, 2, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b|((c)*))+d", extended, "abcd", match_default, make_array(0, 4, 2, 3, 2, 3, 2, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b+|((c)*))+d", extended, "abd", match_default, make_array(0, 3, 1, 2, -1, -1, -1, -1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a(b+|((c)*))+d", extended, "abcd", match_default, make_array(0, 4, 2, 3, 2, 3, 2, 3, -2, -2));
|
||||
// literals:
|
||||
TEST_REGEX_SEARCH("\\**?/{}", literal, "\\**?/{}", match_default, make_array(0, 7, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\**?/{}", literal, "\\**?/{", match_default, make_array(-2, -2));
|
||||
// try to match C++ syntax elements:
|
||||
// line comment:
|
||||
TEST_REGEX_SEARCH("//[^\\n]*", perl, "++i //here is a line comment\n", match_default, make_array(4, 28, -2, -2));
|
||||
// block comment:
|
||||
TEST_REGEX_SEARCH("/\\*([^*]|\\*+[^*/])*\\*+/", perl, "/* here is a block comment */", match_default, make_array(0, 29, 26, 27, -2, -2));
|
||||
TEST_REGEX_SEARCH("/\\*([^*]|\\*+[^*/])*\\*+/", perl, "/**/", match_default, make_array(0, 4, -1, -1, -2, -2));
|
||||
TEST_REGEX_SEARCH("/\\*([^*]|\\*+[^*/])*\\*+/", perl, "/***/", match_default, make_array(0, 5, -1, -1, -2, -2));
|
||||
TEST_REGEX_SEARCH("/\\*([^*]|\\*+[^*/])*\\*+/", perl, "/****/", match_default, make_array(0, 6, -1, -1, -2, -2));
|
||||
TEST_REGEX_SEARCH("/\\*([^*]|\\*+[^*/])*\\*+/", perl, "/*****/", match_default, make_array(0, 7, -1, -1, -2, -2));
|
||||
TEST_REGEX_SEARCH("/\\*([^*]|\\*+[^*/])*\\*+/", perl, "/*****/*/", match_default, make_array(0, 7, -1, -1, -2, -2));
|
||||
// preprossor directives:
|
||||
TEST_REGEX_SEARCH("^[[:blank:]]*#([^\\n]*\\\\[[:space:]]+)*[^\\n]*", perl, "#define some_symbol", match_default, make_array(0, 19, -1, -1, -2, -2));
|
||||
TEST_REGEX_SEARCH("^[[:blank:]]*#([^\\n]*\\\\[[:space:]]+)*[^\\n]*", perl, "#define some_symbol(x) #x", match_default, make_array(0, 25, -1, -1, -2, -2));
|
||||
// perl only:
|
||||
TEST_REGEX_SEARCH("^[[:blank:]]*#([^\\n]*\\\\[[:space:]]+)*[^\\n]*", perl, "#define some_symbol(x) \\ \r\n foo();\\\r\n printf(#x);", match_default, make_array(0, 53, 30, 42, -2, -2));
|
||||
// literals:
|
||||
}
|
||||
|
||||
void test_tricky_cases2()
|
||||
{
|
||||
using namespace boost::regex_constants;
|
||||
TEST_REGEX_SEARCH("((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)?", perl, "0xFF", match_default, make_array(0, 4, 0, 4, 0, 4, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2));
|
||||
TEST_REGEX_SEARCH("((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)?", perl, "35", match_default, make_array(0, 2, 0, 2, -1, -1, 0, 2, -1, -1, -1, -1, -1, -1, -2, -2));
|
||||
TEST_REGEX_SEARCH("((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)?", perl, "0xFFu", match_default, make_array(0, 5, 0, 4, 0, 4, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2));
|
||||
TEST_REGEX_SEARCH("((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)?", perl, "0xFFL", match_default, make_array(0, 5, 0, 4, 0, 4, -1, -1, 4, 5, -1, -1, -1, -1, -2, -2));
|
||||
TEST_REGEX_SEARCH("((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)?", perl, "0xFFFFFFFFFFFFFFFFuint64", match_default, make_array(0, 24, 0, 18, 0, 18, -1, -1, 19, 24, 19, 24, 22, 24, -2, -2));
|
||||
// strings:
|
||||
TEST_REGEX_SEARCH("'([^\\\\']|\\\\.)*'", perl, "'\\x3A'", match_default, make_array(0, 6, 4, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("'([^\\\\']|\\\\.)*'", perl, "'\\''", match_default, make_array(0, 4, 1, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("'([^\\\\']|\\\\.)*'", perl, "'\\n'", match_default, make_array(0, 4, 1, 3, -2, -2));
|
||||
// posix only:
|
||||
TEST_REGEX_SEARCH("^[[:blank:]]*#([^\\n]*\\\\[[:space:]]+)*[^\\n]*", awk, "#define some_symbol(x) \\ \r\n foo();\\\r\n printf(#x);", match_default, make_array(0, 53, 28, 42, -2, -2));
|
||||
// now try and test some unicode specific characters:
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, < 0x560)
|
||||
TEST_REGEX_SEARCH_W(L"[[:unicode:]]+", perl, L"a\x0300\x0400z", match_default, make_array(1, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH_W(L"[\x10-\xff]", perl, L"\x0300\x0400", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH_W(L"[\01-\05]{5}", perl, L"\x0300\x0400\x0300\x0400\x0300\x0400", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH_W(L"[\x300-\x400]+", perl, L"\x0300\x0400\x0300\x0400\x0300\x0400", match_default, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH_W(L"[\\x{300}-\\x{400}]+", perl, L"\x0300\x0400\x0300\x0400\x0300\x0400", match_default, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH_W(L"\\x{300}\\x{400}+", perl, L"\x0300\x0400\x0400\x0400\x0400\x0400", match_default, make_array(0, 6, -2, -2));
|
||||
#endif
|
||||
// finally try some case insensitive matches:
|
||||
TEST_REGEX_SEARCH("0123456789@abcdefghijklmnopqrstuvwxyz\\[\\\\\\]\\^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ\\{\\|\\}", perl|icase, "0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}", match_default, make_array(0, 72, -2, -2));
|
||||
TEST_REGEX_SEARCH("a", perl|icase, "A", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("A", perl|icase, "a", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("[abc]+", perl|icase, "abcABC", match_default, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("[ABC]+", perl|icase, "abcABC", match_default, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("[a-z]+", perl|icase, "abcABC", match_default, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("[A-Z]+", perl|icase, "abzANZ", match_default, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("[a-Z]+", perl|icase, "abzABZ", match_default, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("[A-z]+", perl|icase, "abzABZ", match_default, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[:lower:]]+", perl|icase, "abyzABYZ", match_default, make_array(0, 8, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[:upper:]]+", perl|icase, "abzABZ", match_default, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[:word:]]+", perl|icase, "abcZZZ", match_default, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[:alpha:]]+", perl|icase, "abyzABYZ", match_default, make_array(0, 8, -2, -2));
|
||||
TEST_REGEX_SEARCH("[[:alnum:]]+", perl|icase, "09abyzABYZ", match_default, make_array(0, 10, -2, -2));
|
||||
|
||||
// known and suspected bugs:
|
||||
TEST_REGEX_SEARCH("\\(", perl, "(", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\)", perl, ")", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\$", perl, "$", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\^", perl, "^", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\.", perl, ".", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\*", perl, "*", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\+", perl, "+", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\?", perl, "?", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\[", perl, "[", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\]", perl, "]", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\|", perl, "|", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\\\", perl, "\\", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("#", perl, "#", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\#", perl, "#", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a-", perl, "a-", match_default, make_array(0, 2, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\-", perl, "-", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\{", perl, "{", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\}", perl, "}", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("0", perl, "0", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("1", perl, "1", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("9", perl, "9", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("b", perl, "b", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("B", perl, "B", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("<", perl, "<", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH(">", perl, ">", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("w", perl, "w", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("W", perl, "W", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("`", perl, "`", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH(" ", perl, " ", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\n", perl, "\n", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH(",", perl, ",", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a", perl, "a", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("f", perl, "f", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("n", perl, "n", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("r", perl, "r", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("t", perl, "t", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("v", perl, "v", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("c", perl, "c", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("x", perl, "x", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH(":", perl, ":", match_default, make_array(0, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("(\\.[[:alnum:]]+){2}", perl, "w.a.b ", match_default, make_array(1, 5, 3, 5, -2, -2));
|
||||
|
||||
// new bugs detected in spring 2003:
|
||||
TEST_REGEX_SEARCH("b", perl, "abc", match_default|match_continuous, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(?!foo)bar", perl, "foobar", match_default, make_array(3, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?!foo)bar", perl, "??bar", match_default, make_array(2, 5, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?!foo)bar", perl, "barfoo", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?!foo)bar", perl, "bar??", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("(?!foo)bar", perl, "bar", match_default, make_array(0, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("a\\Z", perl, "a\nb", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("()", perl, "abc", match_default, make_array(0, 0, 0, 0, -2, 1, 1, 1, 1, -2, 2, 2, 2, 2, -2, 3, 3, 3, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH("^()", perl, "abc", match_default, make_array(0, 0, 0, 0, -2, -2));
|
||||
TEST_REGEX_SEARCH("^()+", perl, "abc", match_default, make_array(0, 0, 0, 0, -2, -2));
|
||||
TEST_REGEX_SEARCH("^(){1}", perl, "abc", match_default, make_array(0, 0, 0, 0, -2, -2));
|
||||
TEST_REGEX_SEARCH("^(){2}", perl, "abc", match_default, make_array(0, 0, 0, 0, -2, -2));
|
||||
TEST_REGEX_SEARCH("^((){2})", perl, "abc", match_default, make_array(0, 0, 0, 0, 0, 0, -2, -2));
|
||||
TEST_REGEX_SEARCH("()", perl, "", match_default, make_array(0, 0, 0, 0, -2, -2));
|
||||
TEST_REGEX_SEARCH("()\\1", perl, "", match_default, make_array(0, 0, 0, 0, -2, -2));
|
||||
TEST_REGEX_SEARCH("()\\1", perl, "a", match_default, make_array(0, 0, 0, 0, -2, 1, 1, 1, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a()\\1b", perl, "ab", match_default, make_array(0, 2, 1, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("a()b\\1", perl, "ab", match_default, make_array(0, 2, 1, 1, -2, -2));
|
||||
TEST_REGEX_SEARCH("([a-c]+)\\1", perl, "abcbc", match_default, make_array(1, 5, 1, 3, -2, -2));
|
||||
TEST_REGEX_SEARCH(".+abc", perl, "xxxxxxxxyyyyyyyyab", match_default, make_array(-2, -2));
|
||||
TEST_REGEX_SEARCH("(.+)\\1", perl, "abcdxxxyyyxxxyyy", match_default, make_array(4, 16, 4, 10, -2, -2));
|
||||
// this should not throw:
|
||||
TEST_REGEX_SEARCH("[_]+$", perl, "___________________________________________x", match_default, make_array(-2, -2));
|
||||
// bug in V4 code detected 2004/05/12:
|
||||
TEST_REGEX_SEARCH("\\l+", perl|icase, "abcXYZ", match_default, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("\\u+", perl|icase, "abcXYZ", match_default, make_array(0, 6, -2, -2));
|
||||
TEST_REGEX_SEARCH("(a)(?:b)", perl|nosubs, "ab", match_default, make_array(0, 2, -2, -2));
|
||||
|
||||
|
||||
//
|
||||
// the strings in the next test case are too long for most compilers to cope with,
|
||||
// we have to break them up and call the testing procs directly rather than rely on the macros:
|
||||
//
|
||||
static const char* big_text = "00001 01 \r\n00002 02 1 2 3 4 5 6"
|
||||
"7 8 9 0\r\n00003 03 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\r\n"
|
||||
"00004 04 \r\n00005 05 \r\n00006 06 "
|
||||
"Seite: 0001\r\n00007 07 "
|
||||
"StartSeitEEnde: 0001\r\n00008 08 "
|
||||
"StartSeiTe Ende: 0001\r\n00009 09 "
|
||||
"Start seiteEnde: 0001\r\n00010 10 "
|
||||
"28.2.03\r\n00011 11 "
|
||||
"Page: 0001\r\n00012 12 "
|
||||
"Juhu die Erste: 0001\r\n00013 13 "
|
||||
"Es war einmal! 0001\r\n00014 14 ABCDEFGHIJKLMNOPQRSTUVWXYZ0001\r\n"
|
||||
"00015 15 abcdefghijklmnopqrstuvwxyz0001\r\n"
|
||||
"00016 16 lars.schmeiser@gft.com\r\n00017 17 \r\n"
|
||||
"00018 18 \r\n00019 19 \r\n00020 20 \r\n00021 21 1 2 3 4 5 "
|
||||
"6 7 8 9 0\r\n"
|
||||
"00022 22 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\r\n"
|
||||
"00023 01 \r\n00024 02 1 2 3 4 5 6 7 8 9 0\r\n"
|
||||
"00025 03 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\r\n"
|
||||
"00026 04 \r\n00027 05 \r\n00028 06 "
|
||||
"Seite: 0002\r\n00029 07 StartSeitEEnde: 0002\r\n"
|
||||
"00030 08 "
|
||||
"StartSeiTe Ende: 0002\r\n00031 09 "
|
||||
"Start seiteEnde: 0002\r\n00032 10 "
|
||||
"28.02.2003\r\n00033 11 "
|
||||
"Page: 0002\r\n00034 12 "
|
||||
"Juhu die Erste: 0002\r\n00035 13 "
|
||||
"Es war einmal! 0002\r\n00036 14 ABCDEFGHIJKLMNOPQRSTUVWXYZ0002\r\n00037 "
|
||||
"15 abcdefghijklmnopqrstuvwxyz0002\r\n00038 16 "
|
||||
"lars.schmeiser@194.1.12.111\r\n00039 17 \r\n00040 18 \r\n00041 19 \r\n"
|
||||
"00042 20 \r\n00043 21 1 2 3 4 5 6 7 8 9 0\r\n";
|
||||
|
||||
do{
|
||||
test_info<char>::set_info(__FILE__, __LINE__,
|
||||
"(.*\\r\\n){3}.* abcdefghijklmnopqrstuvwxyz.*\\r\\n",
|
||||
perl, big_text, match_default|match_not_dot_newline,
|
||||
make_array(753, 1076, 934, 1005, -2, 2143, 2466, 2324, 2395, -2, -2));
|
||||
test(char(0), test_regex_search_tag());
|
||||
}while(0);
|
||||
#if !defined(BOOST_NO_WREGEX) && !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS) && !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
do{
|
||||
std::string st(big_text);
|
||||
test_info<wchar_t>::set_info(__FILE__, __LINE__,
|
||||
L"(.*\\r\\n){3}.* abcdefghijklmnopqrstuvwxyz.*\\r\\n",
|
||||
perl, std::wstring(st.begin(), st.end()), match_default|match_not_dot_newline,
|
||||
make_array(753, 1076, 934, 1005, -2, 2143, 2466, 2324, 2395, -2, -2));
|
||||
test(char(0), test_regex_search_tag());
|
||||
}while(0);
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user