]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/benchmarks/strings.cpp
Fix crash in wxMSW wxProgressDialog without wxPD_APP_MODAL style.
[wxWidgets.git] / tests / benchmarks / strings.cpp
index f8219729a2ae920d27f3f289a56853ff8d1364a4..22ab5b55a56f52e5c2af343bf398a781dbf92b6f 100644 (file)
@@ -5,7 +5,7 @@
 // Created:     2008-07-19
 // RCS-ID:      $Id$
 // Copyright:   (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
-// Licence:     wxWindows license
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 #include "wx/string.h"
@@ -48,7 +48,11 @@ const wxString& GetTestAsciiString()
     static wxString testString;
     if ( testString.empty() )
     {
-        for ( long n = 0; n < Bench::GetNumericParameter(); n++ )
+        long num = Bench::GetNumericParameter();
+        if ( !num )
+            num = 1;
+
+        for ( long n = 0; n < num; n++ )
             testString += wxString::FromAscii(asciistr);
     }
 
@@ -277,6 +281,18 @@ BENCHMARK_FUNC(ReplaceAll)
     return str.Replace("x", "y") != 0;
 }
 
+BENCHMARK_FUNC(ReplaceLonger)
+{
+    wxString str('x', ASCIISTR_LEN);
+    return str.Replace("x", "yy") != 0;
+}
+
+BENCHMARK_FUNC(ReplaceShorter)
+{
+    wxString str('x', ASCIISTR_LEN);
+    return str.Replace("xx", "y") != 0;
+}
+
 
 // ----------------------------------------------------------------------------
 // string buffers: wx[W]CharBuffer
@@ -318,7 +334,11 @@ BENCHMARK_FUNC(ParseHTML)
 
         // this is going to make for some invalid HTML, of course, but it
         // doesn't really matter
-        for ( long n = 0; n < Bench::GetNumericParameter(); n++ )
+        long num = Bench::GetNumericParameter();
+        if ( !num )
+            num = 1;
+
+        for ( long n = 0; n < num; n++ )
             html += html1;
     }