From ab6b0d99719510bd33b60e96fb25dd7e4dc374b4 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Sat, 7 Jul 2012 18:36:25 +0000 Subject: [PATCH] Fix begin() and end() members and add tests. Fixes #6346. [SVN r79340] --- doc/history.qbk | 2 +- include/boost/regex/v4/basic_regex.hpp | 4 ++-- test/regress/test_not_regex.hpp | 4 ++++ test/regress/test_regex_search.hpp | 4 ++++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/doc/history.qbk b/doc/history.qbk index 8c71192c..3be7549f 100644 --- a/doc/history.qbk +++ b/doc/history.qbk @@ -19,7 +19,7 @@ All issues including closed ones can be viewed [@https://svn.boost.org/trac/boos Fixed issues: [@https://svn.boost.org/trac/boost/ticket/589 #589], [@https://svn.boost.org/trac/boost/ticket/7084 #7084], -[@https://svn.boost.org/trac/boost/ticket/7032 #7032]. +[@https://svn.boost.org/trac/boost/ticket/7032 #7032], [@https://svn.boost.org/trac/boost/ticket/6346 #6346]. [h4 Boost-1.50] diff --git a/include/boost/regex/v4/basic_regex.hpp b/include/boost/regex/v4/basic_regex.hpp index 1e71877e..c96131be 100644 --- a/include/boost/regex/v4/basic_regex.hpp +++ b/include/boost/regex/v4/basic_regex.hpp @@ -243,11 +243,11 @@ public: // begin, end: const_iterator BOOST_REGEX_CALL begin()const { - return (!this->m_status ? 0 : this->m_expression); + return (this->m_status ? 0 : this->m_expression); } const_iterator BOOST_REGEX_CALL end()const { - return (!this->m_status ? 0 : this->m_expression + this->m_expression_len); + return (this->m_status ? 0 : this->m_expression + this->m_expression_len); } flag_type BOOST_REGEX_CALL flags()const { diff --git a/test/regress/test_not_regex.hpp b/test/regress/test_not_regex.hpp index c1032994..18dfccfb 100644 --- a/test/regress/test_not_regex.hpp +++ b/test/regress/test_not_regex.hpp @@ -48,6 +48,10 @@ void test_empty(boost::basic_regex& r) { BOOST_REGEX_TEST_ERROR("Invalid value returned from basic_regex<>::status().", charT); } + if(r.begin() != r.end()) + { + BOOST_REGEX_TEST_ERROR("Invalid value returned from basic_regex<>::begin().", charT); + } } template diff --git a/test/regress/test_regex_search.hpp b/test/regress/test_regex_search.hpp index ff70d765..0d87f94c 100644 --- a/test/regress/test_regex_search.hpp +++ b/test/regress/test_regex_search.hpp @@ -482,6 +482,10 @@ void test(boost::basic_regex& r, const test_regex_search_tag&) { BOOST_REGEX_TEST_ERROR("Expression did not compile when it should have done, error code = " << r.status(), charT); } + if(expression != std::basic_string(r.begin(), r.end())) + { + BOOST_REGEX_TEST_ERROR("Stored expression string was incorrect", charT); + } test_simple_search(r); test_regex_iterator(r); test_regex_token_iterator(r);