]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/strings/strings.cpp
Fix buffer overflow in wxURLDataObject.
[wxWidgets.git] / tests / strings / strings.cpp
index 98b5230666caf0d1cb3ee1b89a7ad545a69397f1..92dff3e9942cabf30b6707a291ada90dfdc8d536 100644 (file)
@@ -602,6 +602,17 @@ void StringTestCase::ToLong()
         if ( ld.IsOk() )
             CPPUNIT_ASSERT_EQUAL( ld.LValue(), l );
     }
+
+    // special case: check that the output is not modified if the parsing
+    // failed completely
+    l = 17;
+    CPPUNIT_ASSERT( !wxString("foo").ToLong(&l) );
+    CPPUNIT_ASSERT_EQUAL( 17, l );
+
+    // also check that it is modified if we did parse something successfully in
+    // the beginning of the string
+    CPPUNIT_ASSERT( !wxString("9 cats").ToLong(&l) );
+    CPPUNIT_ASSERT_EQUAL( 9, l );
 }
 
 void StringTestCase::ToULong()