Commit Graph
115 Commits
Author SHA1 Message Date
dxbjavid 18582927af Fix out-of-bounds read on trailing % in wxFileType::ExpandCommand()
A command ending in a bare '%' made the loop advance in this function
advance past the end of string.

Fix this by handling only non-trailing '%' specifically

Closes #26531.
2026-05-31 00:57:30 +02:00
Vadim Zeitlin 7ffe27e84d Disable bogus -Warray-bounds for gcc 16.1 too
Similar to 7eb942431e (Disable bogus -Wmaybe-initialized for gcc 16.1
too, 2026-05-08).
2026-05-08 16:27:16 +02:00
Vadim Zeitlin e3ecf72ca9 Suppress bogus -Warray-bounds for gcc 16 in the unit test
These warnings look very much like a compiler bug, so suppress them just
for this version, hoping that they will get fixed in 16.1 release.
2026-04-29 17:15:41 +02:00
Vadim Zeitlin 65e8f2b7ca Merge branch 'stattext-wrap'
No Response / no-response (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxGTK 3 compatible 3.0 (push) Has been cancelled
Unix builds / Ubuntu 24.04 wxGTK ASAN not compatible (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxGTK UTF-8 (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxQt (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxX11 (push) Has been cancelled
Unix builds / Ubuntu 20.04 wxGTK 3 with clang (push) Has been cancelled
Unix builds / Ubuntu 22.04 wxGTK with wx containers (push) Has been cancelled
Unix builds / Ubuntu 24.04 wxGTK UBSAN (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxDFB (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxGTK 3 static with gcc 4.8 (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxGTK 2 (push) Has been cancelled
CMake builds / Ubuntu 22.04 wxGTK 3 (push) Has been cancelled
CMake builds / MSW/MSVC wxMSW (push) Has been cancelled
CMake builds / MSW/Clang wxMSW (push) Has been cancelled
CMake builds / macOS latest wxOSX Ninja (push) Has been cancelled
CMake builds / macOS 14 wxOSX Xcode (push) Has been cancelled
CMake builds / macOS 14 wxIOS (push) Has been cancelled
CMake builds / MSW/MSVC wxQt 5.15 (push) Has been cancelled
CMake builds / MSW/MSVC wxQt 6.8 (push) Has been cancelled
Mac builds / wxMac ARM ASAN not compatible (push) Has been cancelled
Mac builds / wxMac Universal C++14 (push) Has been cancelled
Mac builds / wxiOS Simulator on Silicon Mac (push) Has been cancelled
Mac builds / wxiOS (push) Has been cancelled
Mac builds / wxMac Intel C++17 (push) Has been cancelled
Mac Xcode builds / iOS Simulator static (push) Has been cancelled
Mac Xcode builds / macOS dynamic Release (push) Has been cancelled
Mac Xcode builds / iOS static Debug (push) Has been cancelled
MSW builds / wxMSW vs2022 DLL Debug x64 (push) Has been cancelled
MSW builds / wxMSW vs2022 DLL Release x64 (push) Has been cancelled
MSW builds / wxMSW vs2022 Debug Win32 (push) Has been cancelled
MSW builds / wxMSW vs2022 Release arm64 (push) Has been cancelled
MSW cross-builds / wxMSW 64 bits not compatible (push) Has been cancelled
MSW cross-builds / wxMSW/Univ (push) Has been cancelled
MSW cross-builds / wxMSW 32 bits (push) Has been cancelled
Code Checks / Check Spelling (push) Has been cancelled
Code Checks / Check Whitespace (push) Has been cancelled
Code Checks / Check Mixed EOL (push) Has been cancelled
Code Checks / Check C++ Style (push) Has been cancelled
Code Checks / Check All Headers In allheaders.h (push) Has been cancelled
Update Documentation / Update Online Documentation (push) Has been cancelled
Implement automatic wxStaticText wrapping.

See #25925.

Closes #25753.
2025-10-25 17:40:16 +02:00
Vadim Zeitlin 38424e5f7b Add support for wrapping on non-ASCII space characters
Break lines on zero width space and other Unicode characters with the
"white space" property, but not non-breaking ones.

Closes #751.
2025-10-25 15:59:25 +02:00
AliKet 701d35e5ee Add tests to wxWindow::ClientToScreen() for RTL layout 2025-10-20 14:44:29 +01:00
Vadim Zeitlin 9886f14fdb Don't leave temporary files after running "Load" unit test
This test created temporary files but never deleted them.

Fix this by using TestFile helper class, which also simplifies the test
code.
2025-09-13 15:42:13 +02:00
Vadim Zeitlin f680059b96 Use std::vector instead of manual memory management in a test
Make the test code a bit safer.
2025-09-09 00:12:02 +02:00
Blake-Madden 2bc4bcb3a1 Migrate fuzzer unit test to Catch2 2025-09-07 18:38:37 -04:00
Vadim Zeitlin 0045ee4e5c Fix comparing wxObjectDataPtr<> objects
Previously comparing objects of this type involved implicitly converting
both of them to the unspecified_bool_type and then comparing these
values, which meant that all non-null pointers were considered to be
equal.

Fix this now and add a trivial unit test which was failing before this
commit.
2025-05-07 19:56:23 +02:00
Lauri Nurmi 96c72db0d7 Move wxGetLibraryVersionInfo() to core from base
Unix builds / Ubuntu 24.04 wxGTK with ASAN (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxGTK 3 compatible 3.0 (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxGTK UTF-8 (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxQt (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxX11 (push) Has been cancelled
Unix builds / Ubuntu 20.04 wxGTK 3 with clang (push) Has been cancelled
Unix builds / Ubuntu 22.04 wxGTK with wx containers (push) Has been cancelled
Unix builds / Ubuntu 24.04 wxGTK with UBSAN (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxDFB (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxGTK 3 static with gcc 4.8 (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxGTK 2 (push) Has been cancelled
CMake builds / Windows MSVC (push) Has been cancelled
CMake builds / macOS 14 wxIOS (push) Has been cancelled
CMake builds / Ubuntu 22.04 wxGTK 3 (push) Has been cancelled
CMake builds / macOS 14 wxOSX (push) Has been cancelled
Mac builds / wxMac Universal C++14 (push) Has been cancelled
Mac builds / wxMac ARM with ASAN (push) Has been cancelled
Mac builds / wxiOS (push) Has been cancelled
Mac builds / wxMac macOS 14 (push) Has been cancelled
Mac builds / wxMac Intel C++17 (push) Has been cancelled
Mac Xcode builds / iOS static Debug (push) Has been cancelled
Mac Xcode builds / iOS Simulator static (push) Has been cancelled
Mac Xcode builds / macOS dynamic Release (push) Has been cancelled
MSW builds / wxMSW vs2022 DLL Debug x64 (push) Has been cancelled
MSW builds / wxMSW vs2019 DLL Release x64 (push) Has been cancelled
MSW builds / wxMSW vs2019 Debug Win32 (push) Has been cancelled
MSW builds / wxMSW vs2022 Release arm64 (push) Has been cancelled
MSW builds / msw-msys2-clang (push) Has been cancelled
MSW cross-builds / wxMSW 64 bits (push) Has been cancelled
MSW cross-builds / wxMSW/Univ (push) Has been cancelled
MSW cross-builds / wxMSW 32 bits (push) Has been cancelled
Code Checks / Check Spelling (push) Has been cancelled
Code Checks / Check Whitespace (push) Has been cancelled
Code Checks / Check Mixed EOL (push) Has been cancelled
Code Checks / Check C++ Style (push) Has been cancelled
Code Checks / Check All Headers In allheaders.h (push) Has been cancelled
Update Documentation / Update Online Documentation (push) Has been cancelled
Move determining compile-time GTK+/QT versions to wxAppTraits,
which is presumably the only reason why wxGetLibraryVersionInfo()
needed to be in core.

Revert "Move wxGetLibraryVersionInfo() to core from base."
This reverts commit 9aea251043.

Closes #25236.
2025-03-12 23:59:39 +01:00
Vadim Zeitlin f741789a10 Add a pseudo test allowing to test wxTextWrapper interactively
By defining WX_TEST_TEXT_WRAP and WX_TEST_TEXT_WIDTH it's possible to
see how the given text would be wrapped at the given width, which is
useful for testing.
2025-01-20 16:24:21 +01:00
Vadim Zeitlin c056a2f4f8 Fix wxTextWrapper::Wrap() when width is just at the word boundary
Don't move words to the next line if they just fit into the current one.

This requires checking for the space just at the boundary before looking
for the previous or next space and also using the correct predicate with
lower_bound() which uses inexact comparison.
2025-01-20 16:24:21 +01:00
Vadim Zeitlin 5972730200 Fix logic in wxTextWrapper::Wrap()
The existing code behaved completely wrongly whenever a word longer than
the maximal width was present as it just gave up and didn't wrap
anything at all after it -- when it should have just let this word
overflow but still wrap the rest.

Fix this and add a unit test checking that this works correctly now
(several of the tests would have failed before).

Closes #23339.
2025-01-20 16:24:21 +01:00
Vadim Zeitlin 4897743c58 Add a simple function wrapping lines at given width
This could be enhanced, e.g. break lines at characters other than
spaces, support Unicode better etc, but for now add just a very simple
function that should be suitable for wrapping help message in
wxCmdLineParser, where it will be used next.
2024-11-22 23:02:58 +01:00
Vadim Zeitlin 7aa6da06d0 Remove wxUSE_LONGLONG and always use wxLongLong_t
All supported platforms provide 64-bit integer types since many years,
so remove the legacy wxLongLongWx implementation and rename
wxLongLongNative to just wxLongLong and always compile it in.

Note that wxLongLong itself must still be kept for compatibility as it
has member functions, such as GetValue() or ToString(), that can be used
in the existing code.
2024-10-18 19:26:15 +02:00
Samuel Thibault 62f75c235d Fix DynamicLibrary::Load() test for less common platforms
alpha and ia64 use libc.so.6.1, GNU/kFreeBSD uses libc.so.0.1, and
GNU/Hurd uses libc.so.0.3, so check for these versions too in addition
to 6 and 7 used under x86 Linux.

Closes #23801.
2023-08-24 02:49:31 +02:00
Carlo Bramini 1bc8631b52 Fix DynamicLibrary::Load unit test under Cygwin
While running the test_base on CYGWIN, this message will be printed on the console:

-------------------------------------------------------------------------------
DynamicLibrary::Load
-------------------------------------------------------------------------------
/cygdrive/c/Users/carlo/Documents/GitHub/wxWidgets/tests/misc/dynamiclib.cpp:26
...............................................................................

/cygdrive/c/Users/carlo/Documents/GitHub/wxWidgets/tests/misc/dynamiclib.cpp:80: warning:
  Couldn't find libc.so, skipping DynamicLibrary::Load() test.

/cygdrive/c/Users/carlo/Documents/GitHub/wxWidgets/tests/misc/dynamiclib.cpp:84: warning:
  Possible candidates:
  /lib/libc.a
  /usr/lib/libc.a

CYGWIN uses NEWLIB as C library and it is compiled into cygwin1.dll.
This patch adds the right test case for CYGWIN, for letting the execution of the test.

Closes #23781.
2023-08-24 02:24:16 +02:00
Vadim Zeitlinandmcorino 72c5691d2f Fix buffer overrun in wxHTMLDataObject under non-MSW platforms
Using strcpy() in GetDataHere() added an extra NUL at the end which
didn't fit into the buffer of the size returned by GetDataSize(). This
could have been also fixed by returning an extra byte from the latter
function, but as the string doesn't need to be NUL-terminated,
apparently, just use memcpy() with the correct number of bytes instead.

Also, because the string is not necessarily NUL-terminated, use the
provided length in wxHTMLDataObject::SetData() instead of relying on the
buffer being NUL-terminated and reading uninitialized memory beyond its
size.

Add a unit test confirming that there are no more ASAN errors when using
this class.

Closes #23660.

Co-Authored-By: mcorino <martin@corino.nl>
2023-06-21 20:38:25 +01:00
Vadim Zeitlin c7d414bbed Make HTML pasting code more robust and efficient
Use StartFragment and EndFragment headers values in order to extract the
HTML fragment from the entire CF_HTML string, instead of searching for
"<!--StartFragment-->" and "<!--EndFragment-->" comments which could be
wrong (e.g. if a StartFragment comment actually appeared inside the HTML
fragment) and less efficient too.

Also add a simple pseudo-test, disabled by default, allowing to view the
clipboard contents if HTML is available on it.
2023-06-21 20:38:25 +01:00
Vadim Zeitlin 363f0988cf Replace wxScopedPtr with std::unique_ptr in the tests
Just use the standard class instead of the wx one, as they can be used
in exactly the same way.
2023-03-06 23:34:44 +01:00
Vadim Zeitlin d737d98d27 Consistently include trailing NUL in wxMSW wxTextDataObject size
Fix a long-standing bug in wxMSW wxTextDataObject which returned the
size including the trailing NUL from its GetDataSize() and used the same
convention in GetData(), but didn't account for this NUL being included
into the buffer passed to SetData().

This was partially compensated by also passing the wrong (too small)
buffer size when calling SetData() from wxIDataObject, but still
resulted in problems when using SetData() with the length returned from
GetDataSize(), as done in wxDataViewCtrl code.

Fix this by now always considering NUL part of the buffer (as this is
the platform convention, i.e. all CF_TEXT data on the system clipboard
must include the trailing NUL) and taking it into account when
determining the buffer size in wxIDataObject.

This change is not fully backwards-compatible as it breaks any code
calling SetData() directly, as e.g. wxURLDataObject in wxMSW itself did,
so document it as such, but it's still worth making it as there doesn't
seem to be any other way of fixing the problem described in the linked
issue and direct calls to SetData() should be rare as simpler SetText()
should be used instead.

Also add a unit test for wxTextDataObject and extend the existing test
of wxURLDataObject.

Closes #22928.
2022-12-06 02:25:44 +01:00
Vadim Zeitlin 2a39377ca4 Add wxVersionInfo::AtLeast()
Allow easily checking if the version is at least equal to the given one.
2022-12-04 00:44:09 +01:00
Vadim Zeitlin 84229199c7 Make wxFileTypeInfo ctor a variadic template function
Stop using vararg macros in wxFileTypeInfo and make ctor a template
function instead, this is simpler and more clear.

Add a unit test checking that the ctor still behaves as expected.
2022-11-23 02:44:50 +01:00
Vadim Zeitlin 4f4c5fcfdf Use nullptr instead of NULL in the code and documentation
This is a combination of running clang-tidy with modernize-use-nullptr
check for some ports (GTK, X11, OSX) and manual changes to the ports for
which it couldn't be used easily (MSW, DFB) and also manually updating
the docs.

Also replace NULL with null or nullptr in the comments as this is more
consistent with the use of nullptr in the code and makes it simpler to
grep for the remaining occurrences of NULL itself.

And also use null in the assert messages.

Only a few occurrences of "NULL" are still left in non-C files, mostly
corresponding to unclear comments or string output which it might not be
safe to change.
2022-10-18 01:25:25 +02:00
PB 88d526660f Replace wxOVERRIDE and wxNOEXCEPT with override and noexcept
Don't use deprecated macros in wxWidgets itself.
2022-10-15 18:10:45 +02:00
Vadim Zeitlin 73869d37fd Always use variadic macros and remove wxNO_VARIADIC_MACROS
Variadic macros are always available in C++11, which will be required
very soon, so don't bother testing for them and just always use them.
2022-10-11 00:02:29 +02:00
Vadim Zeitlin 512b8033fe Determine location of libc dynamically in wxDynamicLibrary test
Don't hard code the path to it, even different Linux versions use
different paths, e.g. /lib/x86_64-linux-gnu under Debian and /lib64
under Fedora, so just try all the possibilities until we find something.
2022-08-04 01:07:35 +02:00
PBandVadim Zeitlin 8d3812adce Fix wxDynamicLibrary unit test compilation in C++20 mode
Don't use operator<<() with a wide char string, as this overload has
been removed in C++20. This can be done simply by not using wide char
string at all in this test, as it's not really needed.

Co-Authored-By: Vadim Zeitlin <vadim@wxwidgets.org>

Closes #22599.
2022-07-05 01:36:42 +02:00
Vadim Zeitlin ab204afcab Use correct libc.so location under FreeBSD
This allows wxDynamicLibrary to pass there instead of just warning and
skipping the test.
2022-06-30 16:28:29 +02:00
Vadim Zeitlin 20c8844925 Don't try using /usr/lib/libc.so on unknown Unix systems
This doesn't work under FreeBSD, even if the file exists there.

Show the existing libc candidates on such systems to see if any of them
look plausible.
2022-06-30 14:03:44 +02:00
Vadim Zeitlin 587c1fafe0 Remove unused wx/log.h include from wxDynamicLibrary unit test
No real changes.
2022-06-30 14:03:28 +02:00
Vadim Zeitlin 3fcf4a5f74 Fix Windows wxDynamicLibrary tests build after recent change
Fix a mistake in e32f49bca0 (Do run DynamicLibrary::Load unit test under
Linux, 2022-06-29).
2022-06-29 22:42:10 +02:00
Vadim Zeitlin e32f49bca0 Do run DynamicLibrary::Load unit test under Linux
Use existing path for libc.so on Linux/x86_64 platforms to prevent the
test from just exiting without doing anything.

Also don't give a compilation error for unknown platforms, just a
run-time warning is sufficient.
2022-06-29 22:25:08 +02:00
Vadim Zeitlin 02434dcc1f Workaround a crash with MSYS2 gcc 9.1 again
The changes of 2144ca38d2 (Get rid of CppUnit boilerplate in
DynamicLibraryTestCase, 2022-04-17) accidentally undid the workaround
from 054cb35b39 (Workaround for a crash with gcc 9.1 from MSYS2 MinGW
32bit, 2019-08-03), so work around the same problem again by avoiding
using CHECK() with function pointers.
2022-04-18 14:36:52 +02:00
Vadim Zeitlin 2144ca38d2 Get rid of CppUnit boilerplate in DynamicLibraryTestCase
Use CATCH macros directly, this is simpler and more clear.

Also use narrow strings instead of wide ones and get rid of wxT() too.

No real changes.

This commit is best viewed ignoring whitespace-only changes.
2022-04-17 18:44:51 +02:00
Vadim Zeitlin f3b4ee3b5f Skip dynamic library file existence check under Darwin
Under Monterrey (macOS 10.12) we can actually load the file using
wxDynamicLibrary even though it does _not_ exist on the disk, so don't
skip the test just because of this.
2022-04-17 18:38:08 +02:00
Vadim Zeitlin c6b3b4a39c Make the warning in DynamicLibraryTestCase actually visible
Using wxLogWarning() doesn't work as logs are suppressed by default, but
using CATCH WARN() macro does work.
2022-04-17 18:35:34 +02:00
Vadim Zeitlin 6a48431ca1 Add missing wxLogWarning() argument to wxDynamicLibrary test
The argument corresponding to the "%s" format specifier was missing,
which resulted in a crash if the dynamic library tested didn't actually
exist.
2022-04-17 18:30:42 +02:00
Vadim Zeitlin b91173f76e Fix comparing wxDataFormat with wxDF_INVALID in wxGTK
Define wxDataFormat::operator==(wxDataFormatId) instead of relying on
the implicit conversion from wxDataFormatId to wxDataFormat, as this
can't be done when the format ID is wxDF_INVALID because creating
wxDataFormat results in an assert failure in this case, while comparing
with wxDF_INVALID is clearly a perfectly valid operation.

Add a unit test checking for this.

Closes #22213.
2022-03-23 13:43:44 +01:00
Vadim Zeitlin 9e5c8eef24 Make wxDumpWindow() public and available in wxMSW too
This function was defined in wxGTK and wxOSX, but not in wxMSW or the
other ports, but it can be useful there too, so make it public and
define it in common code.
2021-10-20 23:35:37 +01:00
Vadim Zeitlin 85503d1dcd Get rid of CppUnit boilerplate in MiscGUIFuncsTestCase
Simplify code by not defining an unnecessary test case class and using
CATCH macros directly.

No real changes.
2021-10-20 23:35:37 +01:00
Vadim Zeitlin 87b394a555 Use wxScopedPtr in MiscGUIFuncsTestCase for automatic cleanup
Replace manual calls to Destroy() to ensure that the objects created in
this test will be destroyed even if a check fails.
2021-10-20 23:35:37 +01:00
Vadim Zeitlin cc3c836711 Fix tests build with wxDEBUG_LEVEL==0
Define various macros used in the test code (or in the headers included
from it) as nothing when wxDEBUG_LEVEL==0.

Also don't define a helper function used when asserts are enabled in
this build to avoid clang warnings about unused function.
2021-08-21 15:05:13 +02:00
Vadim Zeitlin 7c6f290995 Document wxMulDivInt32() and add a test for it
This function exists since always and is probably already used outside
wx, so make it officially public and add at least a trivial unit test
for it.
2021-07-13 23:05:16 +01:00
Vadim Zeitlin 0585c96a3b Restore wxObject::ms_classInfo public access
This undoes accidental change of ms_classInfo from public to protected
in 95c98a0b5f (Work around -Wuggest-override for event table macros from
gcc 11, 2021-04-25).

Also add a unit test checking that using wxCLASSINFO(wxObject) compiles
and works as expected.
2021-05-04 23:14:41 +02:00
Vadim Zeitlin 5ddf57c150 Add wxModule::AreInitialized()
This internal function will be useful to check if the modules are
already initialized, i.e. if the library is in the "steady state"
between the end of the initialization and the beginning of the cleanup
phases.
2021-03-07 20:39:09 +01:00
Vadim Zeitlin fbd23270e3 Remove CppUnit boilerplate from wxModule unit test
Also use wxString instead of fixed size char array and wxStrcat().
2021-03-07 20:39:09 +01:00
Vadim Zeitlin 86f9778ea9 Add a unit test exercising the bug fix in the parent commit
This test used to fail, but passes now.
2021-01-23 16:40:30 +01:00
Vadim Zeitlin 6b3ff511ee Get rid of all CppUnit boilerplate in wxSelectionStore test
This simplifies the code and allows running the test cases individually
from the command line.
2021-01-23 16:40:30 +01:00