wxWidgets/tests/streams
Vadim Zeitlin 4502e7563b Fix wxTextInputStream for input starting with BOM-like bytes
Contrary to what a comment in wxTextInputStream::GetChar() said, it is
actually possible to get more than one wide character from a call to
wxMBConv::ToWChar(len+1) even if a previous call to ToWChar(len) failed
to decode anything at all. This happens with wxConvAuto because it keeps
returning an error while it doesn't have enough data to determine if the
input contains a BOM or not, but then returns all the characters
examined so far at once if it turns out that there was no BOM, after
all.

The simplest case in which this created problems was just input starting
with a NUL byte as it as this could be a start of UTF-32BE BOM.

The fix consists in keeping all the bytes read but not yet decoded in
the m_lastBytes buffer and retrying to decode them during the next
GetChar() call. This implies keeping track of how much valid data is
there in m_lastBytes exactly, as we can't discard the already decoded
data immediately, but need to keep it in the buffer too, in order to
allow implementing UngetLast(). Incidentally, UngetLast() was totally
broken for UTF-16/32 input (containing NUL bytes in the middle of the
characters) before and this change fixes this as a side effect.

Also add test cases for previously failing inputs.
2017-11-09 23:49:59 +01:00
..
bstream.h Replace CppUnit with Catch for unit tests 2017-11-02 01:53:16 +01:00
datastreamtest.cpp Factor out TempFile class and reuse it in other tests 2017-11-05 17:28:24 +01:00
ffilestream.cpp Remove test input file in file stream unit tests only once 2017-11-01 14:45:06 +01:00
fileback.cpp Remove all lines containing cvs/svn "$Id$" keyword. 2013-07-26 16:02:46 +00:00
filestream.cpp Remove test input file in file stream unit tests only once 2017-11-01 14:45:06 +01:00
iostreams.cpp Use wx-prefixed macros throughout the repository. 2015-04-23 22:00:35 +04:00
largefile.cpp Replace CppUnit with Catch for unit tests 2017-11-02 01:53:16 +01:00
memstream.cpp Remove all lines containing cvs/svn "$Id$" keyword. 2013-07-26 16:02:46 +00:00
socketstream.cpp Add a check for wxSocketServer creation to the unit tests. 2015-06-23 19:11:31 +02:00
sstream.cpp Fix wxStringOutputStream position when using external string 2017-11-03 15:25:36 +01:00
stdstream.cpp Use wx-prefixed macros throughout the repository. 2015-04-23 22:00:35 +04:00
tempfile.cpp Remove all lines containing cvs/svn "$Id$" keyword. 2013-07-26 16:02:46 +00:00
textstreamtest.cpp Fix wxTextInputStream for input starting with BOM-like bytes 2017-11-09 23:49:59 +01:00
zlibstream.cpp Add missing break statement 2017-11-02 08:55:00 -07:00