From 233f083720d3cc40568328eafb51b416242f0b8a Mon Sep 17 00:00:00 2001
From: John Maddock
Date: Fri, 19 Aug 2005 16:12:45 +0000
Subject: [PATCH] Updated History. Added additional tests for regexes that are
supposed to be empty. Added additional test cases for non-greedy repeats.
[SVN r30605]
---
doc/Attic/history.html | 19 +++++++++++++++++++
doc/history.html | 19 +++++++++++++++++++
test/regress/test.hpp | 6 ++++++
test/regress/test_not_regex.hpp | 27 +++++++++++++++++++++++++++
test/regress/test_simple_repeats.cpp | 14 ++++++++++++++
5 files changed, 85 insertions(+)
diff --git a/doc/Attic/history.html b/doc/Attic/history.html
index a1793ddb..ed9b467c 100644
--- a/doc/Attic/history.html
+++ b/doc/Attic/history.html
@@ -24,6 +24,25 @@
+ Boost 1.33.0 Hotfix
+
+ -
+ Fixed broken makefiles.
+ -
+ Fixed configuration setup to allow building with VC7.1 - STLport-4.6.2 when
+ using /Zc:wchar_t.
+ -
+ Moved declarations class-inline in static_mutex.hpp so that SGI Irix compiler
+ can cope.
+ -
+ Added missing #includes to fileiter.hpp and cpp_regex_traits.hpp, this is
+ probably an SGI Irix specific fix.
+ -
+ Fixed a bug where non-greedy repeats could in certain strange curcumstances
+ repeat more times than their maximum value.
+ -
+ Fixed the value returned by basic_regex<>::empty() from a default
+ constructed object.
Boost 1.33.0.
-
diff --git a/doc/history.html b/doc/history.html
index a1793ddb..ed9b467c 100644
--- a/doc/history.html
+++ b/doc/history.html
@@ -24,6 +24,25 @@
+ Boost 1.33.0 Hotfix
+
+ -
+ Fixed broken makefiles.
+ -
+ Fixed configuration setup to allow building with VC7.1 - STLport-4.6.2 when
+ using /Zc:wchar_t.
+ -
+ Moved declarations class-inline in static_mutex.hpp so that SGI Irix compiler
+ can cope.
+ -
+ Added missing #includes to fileiter.hpp and cpp_regex_traits.hpp, this is
+ probably an SGI Irix specific fix.
+ -
+ Fixed a bug where non-greedy repeats could in certain strange curcumstances
+ repeat more times than their maximum value.
+ -
+ Fixed the value returned by basic_regex<>::empty() from a default
+ constructed object.
Boost 1.33.0.
-
diff --git a/test/regress/test.hpp b/test/regress/test.hpp
index 2668abfe..442e6680 100644
--- a/test/regress/test.hpp
+++ b/test/regress/test.hpp
@@ -60,6 +60,12 @@ void do_test(const charT& c, const tagT& tag)
#ifndef BOOST_NO_STD_LOCALE
test_info::set_typename(typeid(boost::basic_regex >).name());
boost::basic_regex > e1;
+ static bool done_empty_test = false;
+ if(done_empty_test == false)
+ {
+ test_empty(e1);
+ done_empty_test = true;
+ }
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)
diff --git a/test/regress/test_not_regex.hpp b/test/regress/test_not_regex.hpp
index bd193b5c..8b0cdeb9 100644
--- a/test/regress/test_not_regex.hpp
+++ b/test/regress/test_not_regex.hpp
@@ -25,6 +25,31 @@
//
struct test_invalid_regex_tag{};
+template
+void test_empty(boost::basic_regex& r)
+{
+ if(!r.empty())
+ {
+ BOOST_REGEX_TEST_ERROR("Invalid value returned from basic_regex<>::empty().", charT);
+ }
+ if(r.size())
+ {
+ BOOST_REGEX_TEST_ERROR("Invalid value returned from basic_regex<>::size().", charT);
+ }
+ if(r.str().size())
+ {
+ BOOST_REGEX_TEST_ERROR("Invalid value returned from basic_regex<>::str().", charT);
+ }
+ if(r.begin() != r.end())
+ {
+ BOOST_REGEX_TEST_ERROR("Invalid value returned from basic_regex<>::begin().", charT);
+ }
+ if(r.status() == 0)
+ {
+ BOOST_REGEX_TEST_ERROR("Invalid value returned from basic_regex<>::status().", charT);
+ }
+}
+
template
void test(boost::basic_regex& r, const test_invalid_regex_tag&)
{
@@ -39,6 +64,7 @@ void test(boost::basic_regex& r, const test_invalid_regex_tag&)
{
BOOST_REGEX_TEST_ERROR("Expression compiled when it should not have done so.", charT);
}
+ test_empty(r);
}
catch(...)
{
@@ -58,6 +84,7 @@ void test(boost::basic_regex& r, const test_invalid_regex_tag&)
catch(const boost::bad_expression&)
{
have_catch = true;
+ test_empty(r);
}
catch(const std::runtime_error& r)
{
diff --git a/test/regress/test_simple_repeats.cpp b/test/regress/test_simple_repeats.cpp
index 069c3e32..e095ac20 100644
--- a/test/regress/test_simple_repeats.cpp
+++ b/test/regress/test_simple_repeats.cpp
@@ -98,6 +98,20 @@ void test_simple_repeats()
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_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, 2, -2, -2));
+ TEST_REGEX_SEARCH("a{2,4}?", perl, "aaaa", match_default, make_array(0, 2, -2, 2, 4, -2, -2));
+ TEST_REGEX_SEARCH("a{2,4}?", perl, "aaaaa", match_default, make_array(0, 2, -2, 2, 4, -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(1, 5, -2, -2));
+ TEST_REGEX_SEARCH("^a{0,1}?$", perl, "aaaaa", match_default, make_array(-2, -2));
+ TEST_REGEX_SEARCH("^(?:a){0,1}?$", perl, "aaaaa", match_default, make_array(-2, -2));
+ TEST_REGEX_SEARCH("^a(?:bc)?", perl, "abcbc", match_any|match_all, make_array(-2, -2));
+
TEST_INVALID_REGEX("a{}", perl);
TEST_INVALID_REGEX("a{", perl);
TEST_INVALID_REGEX("a{1", perl);