always NUL-terminate the m_szFlags buffer; add test for %*s case

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@58994 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Francesco Montorsi
2009-02-18 15:49:09 +00:00
parent 2e70f5211e
commit 4a7f0351fc
2 changed files with 18 additions and 3 deletions

View File

@@ -40,6 +40,11 @@ int r;
#define ASSERT_STR_EQUAL( a, b ) \
CPPUNIT_ASSERT_EQUAL( wxString(a), wxString(b) );
#define CMP6(expected, x, y, z, w, t) \
r=wxSnprintf(buf, MAX_TEST_LEN, wxT(x), y, z, w, t); \
CPPUNIT_ASSERT( r > 0 ); \
ASSERT_STR_EQUAL( wxT(expected), buf );
#define CMP5(expected, x, y, z, w) \
r=wxSnprintf(buf, MAX_TEST_LEN, wxT(x), y, z, w); \
CPPUNIT_ASSERT( r > 0 ); \
@@ -290,6 +295,10 @@ void VsnprintfTestCase::Asterisk()
CMP5("0.1", "%*.*f", 3, 1, 0.123);
CMP4("%0.002", "%%%.*f", 3, 0.0023456789);
CMP4(" a", "%*c", 8, 'a');
CMP4(" four", "%*s", 8, "four");
CMP6(" four four", "%*s %*s", 8, "four", 6, "four");
}
void VsnprintfTestCase::Percent()