Commit Graph

103 Commits

Author SHA1 Message Date
Maarten Bent
7c1ab06ea5 Add more wxOVERRIDE 2018-09-22 14:44:07 +02:00
Maarten Bent
57180d68c8 Add wxOVERRIDE to test files
And cleanup some tailing spaces and tabs.
2018-07-29 12:08:53 +02:00
Vadim Zeitlin
7c34ca65a0 Add unit test for wxLZMA{Input,Output}Stream classes
Create another generic stream test using BaseStreamTestCase framework.
2018-04-06 15:39:55 +02:00
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
Vadim Zeitlin
0858cd52a7 Don't unnecessarily use heap-allocated objects in a test
Just use local stack variables instead.
2017-11-05 17:30:46 +01:00
Vadim Zeitlin
10b80a16f0 Factor out TempFile class and reuse it in other tests
Ensure we don't leave "mytext.dat" and "test.txt" lying around in any
directory the tests are run from by ensuring that these files are
destroyed by the test code using them.
2017-11-05 17:28:24 +01:00
Vadim Zeitlin
e3589af56a Fix wxStringOutputStream position when using external string
Initialize m_pos correctly when using an existing, and hence possibly
not empty, string (and not the internal one which is always empty
initially). The old code was totally wrong as it divided the string
length by the size of wxChar instead of multiplying by it, but doing
this could have been wrong too with UTF-16 and surrogates, so use the
conversion object to compute the real length of the string
representation in the corresponding encoding.

Add a simple unit test checking that this works as intended.

Closes #17985.
2017-11-03 15:25:36 +01:00
Paul Cornett
c2513d8a4e Add missing break statement 2017-11-02 08:55:00 -07:00
Vadim Zeitlin
e70fc11ef1 Replace CppUnit with Catch for unit tests
Drop the legacy CppUnit testing framework used for the unit tests.
Replacing it with Catch has the advantage of not requiring CppUnit
libraries to be installed on the system in order to be able to run
tests (Catch is header-only and a copy of it is now included in the
main repository itself) and, in the future, of being able to write
the tests in a much more natural way.

For now, however, avoid changing the existing tests code as much as
[reasonably] possible to avoid introducing bugs in them and provide
the CppUnit compatibility macros in the new wx/catch_cppunit.h header
which allow to preserve the 99% of the existing code unchanged. Some
of the required changes are:

 - Decompose asserts using "a && b" conditions into multiple asserts
   checking "a" and "b" independently. This would have been better
   even with CppUnit (to know which part of condition exactly failed)
   and is required with Catch.

 - Use extra parentheses around such conditions when they can't be
   easily decomposed in the arrays test, due to the use of macros.
   This is not ideal from the point of view of messages given when
   the tests fail but will do for now.

 - Rewrite asserts using "a || b" as a combination of condition
   checks and assert macros. Again, this is better anyhow, and is
   required with Catch. Incidentally, this allowed to fix a bug in
   the "exec" unit test which didn't leave enough time for the new
   process to be launched before trying to kill it.

 - Remove multiple CPPUNIT_TEST_SUITE_NAMED_REGISTRATION() macros,
   our emulation of this macro can be used only once.

 - Provide string conversions using Catch-specific StringMaker for
   a couple of types.

 - Replace custom wxImage comparison with a Catch-specific matcher
   class.

 - Remove most of test running logic from test.cpp, in particular don't
   parse command line ourselves any longer but use Catch built-in
   command line parser. This is a source of a minor regression:
   previously, both "Foo" and "FooTestCase" could be used as the name of
   the test to run, but now only the latter is accepted.
2017-11-02 01:53:16 +01:00
Vadim Zeitlin
5520d56222 Remove test input file in file stream unit tests only once
Don't remove the files in the test cases classes dtors, this was
inconsistent with how they were created: we either need to create the
file in the ctor and destroy it in the dtor or do both only once
globally.

Implement the second solution using the helper AutoRemoveFile instead of
a simple static bool in GetInFileName() implementations.
2017-11-01 14:45:06 +01:00
Vadim Zeitlin
c54b611093 Replace few uses of CPPUNIT_TEST_FAIL with just CPPUNIT_TEST
Use positive tests really checking for whatever we want to check (that
the stream is not seekable in this particular case) instead of just
checking that the test fails, for whatever reason -- which might not be
at all the reason for which we expect it to fail.
2017-10-31 22:04:12 +01:00
Vadim Zeitlin
b8c9cd3528 Use wxScopedPtr<> instead of std::auto_ptr<> in the tests
It is better to use wholly non-standard wxWidgets smart pointer class
rather than using standard, but deprecated in C++17, std::auto_ptr<> as
this results in warnings from recent compilers.
2017-10-31 21:14:05 +01:00
Vadim Zeitlin
9f609a8148 Remove WXTEST_WITH_CONDITION macro to simplify the code
It was only used as part of WXTEST_WITH_GZIP_CONDITION which was
necessary only to support running the tests on systems using zlib < 1.2
which is not a concern since many years any more, so simplify the code
by using the simple non-conditional CPPUNIT_TEST instead and drop the
helper macros which were required only for this.
2017-10-30 14:16:11 +01:00
Vadim Zeitlin
d68eb10e3d Handle strings with embedded NULs in wxDataStream
Read/write the entire string and not just the part until the first NUL in it.

Closes #17556.
2016-06-04 21:47:12 +02:00
Vadim Zeitlin
ba5a0a3878 Fix more typos in comments and wxFAIL messages
Closes https://github.com/wxWidgets/wxWidgets/pull/270
2016-04-14 16:08:28 +02:00
Vadim Zeitlin
c15ae5e4a3 Add a check for wxSocketServer creation to the unit tests.
This should prevent an assert failure which happens if we call Accept() on an
invalid server below and also confirm if the server creation really failed or
not.
2015-06-23 19:11:31 +02:00
Dimitri Schoolwerth
8f8d58d193 Use wx-prefixed macros throughout the repository.
Change {DECLARE,IMPLEMENT}_*CLASS and {DECLARE,BEGIN,END}_EVENT_TABLE
occurrences to use the wx-prefixed version of the macros.
2015-04-23 22:00:35 +04:00
Vadim Zeitlin
01f9accd19 Remove wxPM, wxWidgets port to OS/2.
This port is not used and is not being worked on, so remove it to reduce the
amount of the code which needs to be updated for every global change.

Also remove tests for VisualAge compiler which isn't used since ages.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76533 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-05-15 23:56:58 +00:00
Vadim Zeitlin
acd8a61bd8 Do run TextStreamTestCase::TestULongLong() test case.
We ran TestLongLong test case twice because of an accidental typo.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76111 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-03-10 19:05:25 +00:00
Vadim Zeitlin
3f66f6a5b3 Remove all lines containing cvs/svn "$Id$" keyword.
This keyword is not expanded by Git which means it's not replaced with the
correct revision value in the releases made using git-based scripts and it's
confusing to have lines with unexpanded "$Id$" in the released files. As
expanding them with Git is not that simple (it could be done with git archive
and export-subst attribute) and there are not many benefits in having them in
the first place, just remove all these lines.

If nothing else, this will make an eventual transition to Git simpler.

Closes #14487.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74602 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-07-26 16:02:46 +00:00
Vadim Zeitlin
789ab84044 Add IEEE 754 single/double precision support to wxDataStream classes.
Allow to optionally raed/write float/double values in IEEE 754 single/double
precision formats, respectively, instead of always using the extended
precision format for both of them.

This makes the code more flexible, allowing for better interoperability with
the other programs, and also allows to implement floating point functions in
these classes even when wxUSE_APPLE_IEEE is turned off (as can be the case
because of the licencing concerns for the code in extended.c).

Closes #10625.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73938 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-05-06 00:31:03 +00:00
Vadim Zeitlin
1274add43f Test wxDataStream floating point methods in big endian format too.
Added a hack to test float/double reading/writing using
wxDataInputStream/wxDataOutputStream to the test case using big endian
extended float format too.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73936 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-05-06 00:30:56 +00:00
Vadim Zeitlin
393b6027be No changes, just a small optimization in DataStreamTestCase.
Don't create streams on the heap completely unnecessarily, just allocate them
on the stack. This makes the code shorter, safer and slightly more efficient.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73935 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-05-06 00:30:53 +00:00
Vadim Zeitlin
bb5a951418 Use __WINDOWS__ for OS checks and __WXMSW__ for GUI checks (round 2).
This is continuation of r70796 and serves the same purpose.

Closes #14065, #14066.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70808 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2012-03-04 20:31:42 +00:00
Dimitri Schoolwerth
a1b806b982 Replaced Ok() occurrences with IsOk() throughout trunk.
Additionally renamed wxOSX' private wxNativePrinterDC::Ok() function to IsOk().

Didn't deprecate the various Ok() functions: given the amount of changes already introduced in 3.0 a trivial one like this seems more suitable for after 3.0.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67681 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2011-05-03 16:29:04 +00:00
Dimitri Schoolwerth
e3778b4d9c No code changes, fixed some typos.
Changed several occurrences of "it's" where "its" is meant, as well as a few other minor typos.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67656 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2011-04-30 10:57:04 +00:00
Dimitri Schoolwerth
d13b34d3f2 No code changes, fixed various typos.
Applied patch by snowleopard2 fixing typos in interface/. Extended the fixes throughout trunk.

Closes #13076.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67384 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2011-04-03 20:31:32 +00:00
Dimitri Schoolwerth
4c51a665c6 Fixed various typos.
Applied patch by snowleopard2 fixing a bunch of typos such as misspellings and double words in the documentation. Combined the patch with some local queued typos waiting to be committed as well as adding new typo fixes inspired by the patch.

Function names with American spelling were not changed nor was third-party code touched. The only code changes involve some changes in strings that are translated ("Can not" -> "Cannot").

Closes #13063 (again).

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67280 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2011-03-22 14:17:38 +00:00
Vadim Zeitlin
716ee1223e Use wxString::To8BitData() instead of mb_str() to handle NULs correctly.
In ANSI build wxString::mb_str() returns a pointer to the internal wxString
data directly instead of a buffer with a proper length, so it provides access
to the part of the string before the first embedded NUL only.

Use To8BitData() which always returns the buffer of the correct size in all
builds.

The open question remains whether mb_str() should be changed to return a (non
owned) buffer and not just a pointer in ANSI build. This would make
manipulating strings with embedded NULs safer but mb_str() would be less
efficient and less compatible.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66102 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2010-11-10 13:53:40 +00:00
Vadim Zeitlin
526954c596 Globally use "wxWindows licence" consistently.
Use "wxWindows licence" and not "wxWidgets licence" (the latter doesn't
exist) and consistently spell "licence" using British spelling.

See #12165.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64940 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2010-07-13 13:29:13 +00:00
Francesco Montorsi
3dea816bd2 move TestTextInputStream() function in CppUnit's TextStreamTestCase class
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64318 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2010-05-16 14:31:00 +00:00
Vadim Zeitlin
9def6786d6 Fix string stream unit test compilation in non-Unicode build.
wxScopedCharBuffer can't be constructed from char* string, just use
wxCharBuffer instead, we don't care about efficiency here.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63950 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2010-04-12 11:21:37 +00:00
Vadim Zeitlin
0c550516dd Fix bug in wxStringOutputStream unit test.
We wrote an extra NUL byte to the stream and, unsurprisingly, contents of its
buffer didn't match the original string resulting in the test failure.

Also get rid of a #if wxUSE_UNICODE.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63249 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2010-01-24 11:33:24 +00:00
Michael Wetherell
9e477451a1 Add another test for sparse file support so that the large file tests can run
as part of the default suite for more platforms.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63024 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-12-30 17:44:09 +00:00
Michael Wetherell
c896c76129 Repair the stream tests.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63022 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-12-30 17:39:47 +00:00
Michael Wetherell
224d978ffb Add support for large stdio files for VC 8+. What versions of the other Windows
compilers?


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62974 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-12-22 21:22:59 +00:00
Vadim Zeitlin
caa96da739 Extract TestFile class in a separate header.
This allows to reuse it in the other tests which need to create a temporary
file automatically destroyed on test exit.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61897 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-09-12 22:40:35 +00:00
Vadim Zeitlin
9a83f86094 Globally replace _T() with wxT().
Standardize on using a single macro across all wxWidgets sources and solve the name clash with Sun CC standard headers (see #10660).

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61508 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-07-23 20:30:22 +00:00
Vadim Zeitlin
43b2d5e7c3 Put braces around all calls to wxLogFunctions() inside an if statement.
This suppresses all the remaining g++ -Wparentheses warnings and uses consistent style everywhere.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61475 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-07-20 16:47:54 +00:00
Vadim Zeitlin
845e4f9b32 disable a VC6 warning occurring inside a standard header
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60947 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-06-07 12:41:52 +00:00
Vadim Zeitlin
d4b1783215 use _fileno() instead of fileno() with VC
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60928 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-06-06 23:18:52 +00:00
Vadim Zeitlin
4e42fe49f2 removed the now unnecessary WX_CPPUNIT_ALLOW_EQUALS_TO_INT(wxFileOffset)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60503 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-05-03 11:36:04 +00:00
Vadim Zeitlin
61b1a51bde allow comparison of int with 64 bit integer type (see #10637)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60502 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-05-03 09:59:31 +00:00
Vadim Zeitlin
97818dab10 std::streamoff is just a (32 bit) long under Win32 with MSVC so extra WX_CPPUNIT_ALLOW_EQUALS_TO_INT(std::streamoff) is not needed in this case; this also seems to be the case for Borland and Watcom so assume this is always so for Windows compilers
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60498 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-05-03 07:52:49 +00:00
Vadim Zeitlin
72a7c55982 added wxStd{In,Out}putStream classes (closes #10637)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60483 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-05-02 18:29:33 +00:00
Vadim Zeitlin
51acf83bd6 added wxZlibStream::SetDictionary() (closes #10551)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59370 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-03-06 16:26:15 +00:00
Vadim Zeitlin
68888eeaa8 compilation fixes for 64 bit platforms
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58150 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-01-16 17:41:25 +00:00
Vadim Zeitlin
b2eabfe866 abstract VC6 workaround inside a WX_CPPUNIT_ALLOW_EQUALS_TO_INT() macro
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57833 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-01-04 16:04:22 +00:00
Vadim Zeitlin
9540df9c2e use correct type for file offset
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57831 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-01-04 15:49:24 +00:00
Vadim Zeitlin
a54b285e7c allow using CPPUNIT_ASSERT_EQUAL(int, wxFileOffset) too
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57820 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-01-04 00:47:10 +00:00