Add more wxString::Format() positional parameters tests.
Verify that repeating positional parameters does work with wxString::Format() instead of keeping these tests commented out in wxVsnprintf() tests, which are not run at all if we're using the compiler-provided vsprintf(). Closes #9367.
This commit is contained in:
@@ -168,11 +168,24 @@ void StringTestCase::Format()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Positional parameters tests:
|
||||||
CPPUNIT_ASSERT_EQUAL
|
CPPUNIT_ASSERT_EQUAL
|
||||||
(
|
(
|
||||||
"two one",
|
"two one",
|
||||||
wxString::Format(wxT("%2$s %1$s"), wxT("one"), wxT("two"))
|
wxString::Format(wxT("%2$s %1$s"), wxT("one"), wxT("two"))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT_EQUAL
|
||||||
|
(
|
||||||
|
"hello hello",
|
||||||
|
wxString::Format("%1$s %1$s", "hello")
|
||||||
|
);
|
||||||
|
|
||||||
|
CPPUNIT_ASSERT_EQUAL
|
||||||
|
(
|
||||||
|
"4 world hello world 3",
|
||||||
|
wxString::Format("%4$d %2$s %1$s %2$s %3$d", "hello", "world", 3, 4)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StringTestCase::FormatUnicode()
|
void StringTestCase::FormatUnicode()
|
||||||
|
@@ -435,19 +435,6 @@ void VsnprintfTestCase::WrongFormatStrings()
|
|||||||
{
|
{
|
||||||
// test how wxVsnprintf() behaves with wrong format string:
|
// test how wxVsnprintf() behaves with wrong format string:
|
||||||
|
|
||||||
#if 0
|
|
||||||
// NB: the next 2 tests currently return an error but it would be nice
|
|
||||||
// if they didn't (see ticket #9367)
|
|
||||||
|
|
||||||
// two positionals with the same index:
|
|
||||||
r = wxSnprintf(buf, MAX_TEST_LEN, wxT("%1$s %1$s"), "hello");
|
|
||||||
CPPUNIT_ASSERT(r != -1);
|
|
||||||
|
|
||||||
// three positionals with the same index mixed with other pos args:
|
|
||||||
r = wxSnprintf(buf, MAX_TEST_LEN, wxT("%4$d %2$f %1$s %2$s %3$d"), "hello", "world", 3, 4);
|
|
||||||
CPPUNIT_ASSERT(r != -1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// a missing positional arg should result in an assert
|
// a missing positional arg should result in an assert
|
||||||
WX_ASSERT_FAILS_WITH_ASSERT(
|
WX_ASSERT_FAILS_WITH_ASSERT(
|
||||||
wxSnprintf(buf, MAX_TEST_LEN, wxT("%1$d %3$d"), 1, 2, 3) );
|
wxSnprintf(buf, MAX_TEST_LEN, wxT("%1$d %3$d"), 1, 2, 3) );
|
||||||
|
Reference in New Issue
Block a user