mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-09-25 08:54:19 +08:00
Restore value of errno after wxString::ToInt()/Long()/etc.
Such functions modifying errno is undocumented, and may come as a surprise to the caller. Consequently also a call to wxString::Format() would modify errno.
This commit is contained in:
@@ -172,6 +172,16 @@ void StringTestCase::Format()
|
||||
CPPUNIT_ASSERT_EQUAL( len, wxString::Format(wxT("%s"), s.c_str()).length());
|
||||
}
|
||||
|
||||
int errnoWas = errno;
|
||||
// wxString::Format() should not modify errno
|
||||
errno = 1234;
|
||||
wxString::Format("abc %d %d", 1, 1);
|
||||
CPPUNIT_ASSERT_EQUAL
|
||||
(
|
||||
1234,
|
||||
errno
|
||||
);
|
||||
errno = errnoWas;
|
||||
|
||||
// Positional parameters tests:
|
||||
CPPUNIT_ASSERT_EQUAL
|
||||
|
||||
Reference in New Issue
Block a user