X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0868a0300964f0c3438f597ae7e250a7d0863472..17a1e846154f10487319e083dda016bef4c55934:/tests/regex/regextest.cpp diff --git a/tests/regex/regextest.cpp b/tests/regex/regextest.cpp index 5b890d2d86..ef63306560 100644 --- a/tests/regex/regextest.cpp +++ b/tests/regex/regextest.cpp @@ -30,7 +30,7 @@ // // For compilers that support precompilation, includes "wx/wx.h". -#include "wx/wxprec.h" +#include "testprec.h" #ifdef __BORLANDC__ #pragma hdrstop @@ -48,7 +48,6 @@ #ifdef wxHAS_REGEX_ADVANCED #include "wx/regex.h" -#include "wx/cppunit.h" #include #include @@ -133,6 +132,7 @@ RegExTestCase::RegExTestCase( m_advanced(false) { bool badconv = m_pattern == convError() || m_data == convError(); + //RN: Removing the std:: here will break MSVC6 compilation std::vector::const_iterator it; for (it = expected.begin(); it != expected.end(); ++it) { @@ -178,8 +178,9 @@ wxString RegExTestCase::Conv(const char *str) // void RegExTestCase::parseFlags(const wxString& flags) { - for (const wxChar *p = flags; *p; p++) { - switch (*p) { + for ( wxString::const_iterator p = flags.begin(); p != flags.end(); ++p ) + { + switch ( (*p).GetValue() ) { // noop case '-': break; @@ -256,16 +257,18 @@ void RegExTestCase::doTest(int flavor) return; // check wxRegEx has correctly counted the number of subexpressions - failIf(m_expected.size() != re.GetMatchCount(), - wxString::Format(_T("GetMatchCount() == %d, expected %d"), - re.GetMatchCount(), m_expected.size())); - - wxString result; - size_t start, len; + wxString msg; + msg << _T("GetMatchCount() == ") << re.GetMatchCount() + << _T(", expected ") << m_expected.size(); + failIf(m_expected.size() != re.GetMatchCount(), msg); for (size_t i = 0; i < m_expected.size(); i++) { - failIf(!re.GetMatch(&start, &len, i), wxString::Format( - _T("wxRegEx::GetMatch failed for match %d"), i)); + wxString result; + size_t start, len; + + msg.clear(); + msg << _T("wxRegEx::GetMatch failed for match ") << i; + failIf(!re.GetMatch(&start, &len, i), msg); // m - check the match returns the strings given if (m_mode == 'm') @@ -276,14 +279,17 @@ void RegExTestCase::doTest(int flavor) // i - check the match returns the offsets given else if (m_mode == 'i') - if (start < INT_MAX) - result = wxString::Format(_T("%d %d"), start, start + len - 1); - else + if (start > INT_MAX) result = _T("-1 -1"); + else if (start + len > 0) + result << start << _T(" ") << start + len - 1; + else + result << start << _T(" -1"); - failIf(result != m_expected[i], wxString::Format( - _T("match(%d) == %s, expected == %s"), i, - quote(result).c_str(), quote(m_expected[i]).c_str())); + msg.clear(); + msg << _T("match(") << i << _T(") == ") << quote(result) + << _T(", expected == ") << quote(m_expected[i]); + failIf(result != m_expected[i], msg); } } @@ -318,7 +324,7 @@ wxString RegExTestCase::quote(const wxString& arg) wxString str; for (size_t i = 0; i < arg.length(); i++) { - wxUChar ch = arg[i]; + wxUChar ch = (wxChar)arg[i]; const wxChar *p = wxStrchr(needEscape, ch); if (p) @@ -326,7 +332,7 @@ wxString RegExTestCase::quote(const wxString& arg) else if (wxIscntrl(ch)) str += wxString::Format(_T("\\%03o"), ch); else - str += ch; + str += (wxChar)ch; } return str.length() == arg.length() && str.find(' ') == wxString::npos ?