]> git.saurik.com Git - wxWidgets.git/commitdiff
added a test for passing wxCharBufer to wxprintf functions
authorVáclav Slavík <vslavik@fastmail.fm>
Tue, 29 Jul 2008 13:32:35 +0000 (13:32 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Tue, 29 Jul 2008 13:32:35 +0000 (13:32 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54811 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

tests/strings/vararg.cpp

index b0e0eaa5da1fe368a0d53aabfc983c39d3b033a6..1cc62ba3f0dec6459d9d72544e838b1f09699d49 100644 (file)
@@ -41,6 +41,7 @@ private:
         CPPUNIT_TEST( StdString );
 #endif
         CPPUNIT_TEST( Sscanf );
+        CPPUNIT_TEST( RepeatedPrintf );
     CPPUNIT_TEST_SUITE_END();
 
     void StringPrintf();
@@ -49,6 +50,7 @@ private:
     void StdString();
 #endif
     void Sscanf();
+    void RepeatedPrintf();
 
     DECLARE_NO_COPY_CLASS(VarArgTestCase)
 };
@@ -165,3 +167,19 @@ void VarArgTestCase::Sscanf()
     CPPUNIT_ASSERT( i == 42 );
     CPPUNIT_ASSERT( wxStrcmp(wstr, "test") == 0 );
 }
+
+void VarArgTestCase::RepeatedPrintf()
+{
+    wxCharBuffer buffer(2);
+    char *p = buffer.data();
+    *p = 'h';
+    p++;
+    *p = 'i';
+
+    wxString s;
+    s = wxString::Format("buffer %s, len %d", buffer, wxStrlen(buffer));
+    CPPUNIT_ASSERT_EQUAL("buffer hi, len 2", s);
+
+    s = wxString::Format("buffer %s, len %d", buffer, wxStrlen(buffer));
+    CPPUNIT_ASSERT_EQUAL("buffer hi, len 2", s);
+}