Commit Graph

353 Commits (f6fdbc1e37f445a18003a9ab0408662f3487d1af)

Author SHA1 Message Date
Ozkan Sezer ede73b4cfc testnativeos2.c: make its code style to match SDL2. 2021-11-28 23:02:02 +03:00
Sam Lantinga f1c15aa324 Tests cover the latest SDL features 2021-11-28 08:56:25 -08:00
Nate River 6c25aed419
added hint for joysticks to stablize sixaxis & dualshock controllers (#5007) 2021-11-27 11:01:18 -08:00
Ozkan Sezer d2871a348b testhaptic.c, testjoystick.c: fixed -Wshadow warnings. 2021-11-23 15:10:50 +03:00
Sam Lantinga e6a4230de9 Revert testevdev libc changes
This file uses internal SDL headers as a hack, without actually being built as part of SDL, so we should use normal C functions here.
2021-11-23 03:51:32 -08:00
Ozkan Sezer 3eaa80bb0b testgamecontroller.c: fixed -Wshadow warnings. 2021-11-23 14:22:02 +03:00
Ozkan Sezer 370b8318af testmouse.c: fixed -Wshadow warnings. 2021-11-23 14:01:10 +03:00
Sylvain f1582f549b Fix comment 2021-11-22 08:38:46 -08:00
Sylvain d31251b014 use SDL's functions version inplace of libc version 2021-11-22 08:38:46 -08:00
Ozkan Sezer fadf41fc6e remove excess whitespace 2021-11-20 21:55:20 +03:00
Ryan C. Gordon e86d4bde54
test: Makefile should copy unifont file, for testime.c to use. 2021-11-20 13:35:56 -05:00
Ozkan Sezer 495ee42a83 testcustomcursor.c: replaced libc sscanf with SDL_sscanf 2021-11-20 01:15:20 +03:00
Ozkan Sezer 990fb668f7 tests: several -Wwrite-strings fixes. 2021-11-20 01:02:02 +03:00
Cameron Gutman eb98ff4740 testmessage: Fix overread of stack variable 2021-11-13 13:05:02 -06:00
Ozkan Sezer 62b41f61d4 fix build of testmouse.c 2021-11-13 21:29:50 +03:00
Cameron Gutman f124259e59 testautomation: fix use-after-free when restoring hint value 2021-11-12 17:25:24 -06:00
Ozkan Sezer e688a95ba4 updated os2 makefile for tests 2021-11-12 23:55:40 +03:00
Misa 3bf7994fe2 Add and use `SDL_FALLTHROUGH` for fallthroughs
Case fallthrough warnings can be suppressed using the __fallthrough__
compiler attribute. Unfortunately, not all compilers have this
attribute, or even have __has_attribute to check if they have the
__fallthrough__ attribute. [[fallthrough]] is also available in C++17
and the next C2x, but not everyone uses C++17 or C2x.

So define the SDL_FALLTHROUGH macro to deal with those problems - if we
are using C++17 or C2x, it expands to [[fallthrough]]; else if the
compiler has __has_attribute and has the __fallthrough__ attribute, then
it expands to __attribute__((__fallthrough__)); else it expands to an
empty statement, with a /* fallthrough */ comment (it's a do {} while
(0) statement, because users of this macro need to use a semicolon,
because [[fallthrough]] and __attribute__((__fallthrough__)) require a
semicolon).

Clang before Clang 10 and GCC before GCC 7 have problems with using
__attribute__ as a sole statement and warn about a "declaration not
declaring anything", so fall back to using the /* fallthrough */ comment
if we are using those older compiler versions.

Applications using SDL are also free to use this macro (because it is
defined in begin_code.h).

All existing /* fallthrough */ comments have been replaced with this
macro. Some of them were unnecessary because they were the last case in
a switch; using SDL_FALLTHROUGH in those cases would result in a compile
error on compilers that support __fallthrough__, for having a
__attribute__((__fallthrough__)) statement that didn't immediately
precede a case label.
2021-11-12 07:26:14 +03:00
Sam Lantinga abc12a832c Revert "Add and use `SDL_FALLTHROUGH` for fallthroughs"
This reverts commit 66a08aa391.

This causes problems with older compilers:
https://github.com/libsdl-org/SDL/pull/4791#issuecomment-966630997
2021-11-11 15:58:44 -08:00
Cameron Gutman fe09a4930a joystick: Add APIs to query rumble support 2021-11-11 15:10:08 -08:00
Misa 66a08aa391 Add and use `SDL_FALLTHROUGH` for fallthroughs
Case fallthrough warnings can be suppressed using the __fallthrough__
compiler attribute. Unfortunately, not all compilers have this
attribute, or even have __has_attribute to check if they have the
__fallthrough__ attribute. [[fallthrough]] is also available in C++17
and the next C2x, but not everyone uses C++17 or C2x.

So define the SDL_FALLTHROUGH macro to deal with those problems - if we
are using C++17 or C2x, it expands to [[fallthrough]]; else if the
compiler has __has_attribute and has the __fallthrough__ attribute, then
it expands to __attribute__((__fallthrough__)); else it expands to an
empty statement, with a /* fallthrough */ comment (it's a do {} while
(0) statement, because users of this macro need to use a semicolon,
because [[fallthrough]] and __attribute__((__fallthrough__)) require a
semicolon).

Applications using SDL are also free to use this macro (because it is
defined in begin_code.h).

All existing /* fallthrough */ comments have been replaced with this
macro. Some of them were unnecessary because they were the last case in
a switch; using SDL_FALLTHROUGH in those cases would result in a compile
error on compilers that support __fallthrough__, for having a
__attribute__((__fallthrough__)) statement that didn't immediately
precede a case label.
2021-11-11 07:23:25 -08:00
Sam Lantinga dc4c7d9539 Fixed infinite loop in SDL_vsnprintf() if the format string is too large for the output buffer
Fixes https://github.com/libsdl-org/SDL/issues/4940
2021-11-10 09:48:49 -08:00
Eric Wasylishen 0d98793693
testwm2: Fix video modes menu hit detection when highdpi or logical size used (#4936)
* SDLTest_CommonDrawWindowInfo: log SDL_RenderGetScale, SDL_RenderGetLogicalSize

* testwm2: fix video modes menu hit detection in High DPI cases

- also when logical size is specified, e.g.
  `--logical 640x480 --resizable --allow-highdpi`

* add function to determine logical coordinates of renderer point when given window point

* change since to the targeted milestone

* fix typo

* rename for consistency

* Change logical coordinate type to float, since we can render with floating point precision.

* add function to convert logical to window coordinates

* testwm2: use new SDL_RenderWindowToLogical

* SDL_render.c: alternate SDL_RenderWindowToLogical/SDL_RenderLogicalToWindow

Co-authored-by: John Blat <johnblat64@protonmail.com>
Co-authored-by: John Blat <47202511+johnblat64@users.noreply.github.com>
2021-11-09 21:03:42 -08:00
Sam Lantinga cdb4d8f22f Added a test case for snprintf of 0.0
This verifies regressions in https://github.com/libsdl-org/SDL/issues/4795
2021-11-07 09:39:57 -08:00
Eric Wasylishen a0e055a7f9 testwm2: add mode menu, click on a mode to call SDL_SetWindowDisplayMode 2021-11-07 08:42:09 -08:00
Sam Lantinga 35b0baaa7a Unfixed typo 2021-11-06 19:25:06 -07:00
Sam Lantinga 1d40c69a1b Fixed typo 2021-11-05 22:52:18 -07:00
Eddy Jansson e2ba84a532 testtimer: Be more like the C90's. 2021-11-03 00:22:06 -04:00
Eddy Jansson 4ab7ee1925 testtimer: Add basic sanity check for SDL_GetTicks*() 2021-11-03 00:22:06 -04:00
Ryan C. Gordon d78cb9e903 testtimer: added SDL_GetTicks64() calls. 2021-11-01 14:28:00 -04:00
Cameron Gutman 210713a600 cmake: Work around bug in opengl32.lib detection on MSVC ARM64 2021-10-31 17:57:40 -07:00
Cameron Gutman 77141e84e0 cmake: Fix test linking with MinGW 2021-10-31 17:57:40 -07:00
Cameron Gutman 618b0d414f cmake: Remove SDL2_test_resources dummy hack
It doesn't work properly on MSVC because the dummy target fails to link
2021-10-31 17:57:40 -07:00
Ozkan Sezer f3640e26a4 tests: minor update to acinclude.m4::pkg.m4 2021-10-31 08:47:00 +03:00
Ozkan Sezer cc3fe1a182 tests: don't fail configury if libunwind is not available. 2021-10-31 08:25:24 +03:00
Ozkan Sezer c401627793 testsurround.c: remove unnecessary libc includes and stdint.h types 2021-10-31 08:14:50 +03:00
Ozkan Sezer e28e399338 testsurround.c: add missing newline at end of file. 2021-10-31 08:00:20 +03:00
Cameron Gutman cd66c050fe testsurround: Add surround sound channel tester 2021-10-30 21:26:03 -07:00
Cameron Gutman 6b8e880a10 checkkeysthreads: Create a renderer for window display on Wayland
Applies checkkeys patch from 105f1206 to checkkeysthreads.
2021-10-26 20:27:34 -05:00
Ozkan Sezer 7ac0c73af2 regenerated test/configure 2021-10-25 21:40:04 +03:00
David Gow c57bcb47b1 test: Fix building with libunwind under autotools
There are two issues which are stopping the SDL tests from building on
my machine:
- libunwind is not being linked
- Even if it is, it is missing several symbols.

The first is fixed by having the test programs link against libunwind if
available. Technically, SDL2_test should be linking against it, as it's
used in SDL_test_memory.c, but as SDL2_test is a static library, it
can't itself import libunwind. We just assume that if it's present on
the system, we should link it directly to the test programs. This should
strictly be an improvement, as the only case where this'd fail is if
SDL2 was compiled when libunwind was present, but the tests are being
compiled without it, and that'd fail anyway.

The second is fixed by #define-ing UNW_LOCAL_ONLY before including
libunwind.h: this is required to make libunwind link to predicatable
symbols, in what can only be described as a bit of a farce. There are a
few more details in the libunwind man page, but the gist of it is that
it disables support for "remote unwinding": unwinding stack frames in a
different process (and possibly from a different architecture?):
http://www.nongnu.org/libunwind/man/libunwind(3).html

Note that I haven't tried this with CMake: I suspect that it'll work,
though, as the CMakeLists.txt seems to have SDL2 link against libunwind if
it's present. This adds an ugly extra dependency to SDL2, but does mean
that issue 1 isn't present. The UNW_LOCAL_ONLY change shouldn't be
build-system-specific.
2021-10-25 11:28:20 -07:00
Brick f30e2e438d Fix compiler warnings in testvulkan.c
MSVC gives the following warnings when compiling testvulkan.c:
```
testvulkan.c(656,1): warning C4018: '<': signed/unsigned mismatch
testvulkan.c(656,1): warning C4018: '>': signed/unsigned mismatch
testvulkan.c(660,1): warning C4018: '<': signed/unsigned mismatch
testvulkan.c(660,1): warning C4018: '>': signed/unsigned mismatch
```
2021-10-06 15:24:41 -07:00
Sylvain decd1b4d74
testdraw2: display FPS similarly to testsprit2. fix helper syntax 2021-09-23 22:28:45 +02:00
Sam Lantinga 79b0aae86c The return value of SDL_snprintf is the number of characters that would have been written.
Fixes https://github.com/libsdl-org/SDL/issues/4762
2021-09-22 11:46:24 -07:00
Sam Lantinga 42ae9116ad Getting "(null)" when formatted printing NULL is a valid result 2021-09-22 10:01:42 -07:00
Sam Lantinga a4a9d28461 You may need to wait a bit for SDL_WarpMouseInWindow() to complete 2021-09-22 09:56:06 -07:00
Sam Lantinga 94a42af570 Fixed the name of the verbose hints 2021-09-22 09:49:41 -07:00
Sam Lantinga b914bc3954 SDL_PIXELFORMAT_ARGB2101010 isn't fully supported for all surface conversion paths yet 2021-09-22 09:48:51 -07:00
Sam Lantinga e5d59fa77c Fixed building testgles2 on Linux 2021-09-22 09:31:26 -07:00
Sam Lantinga eb3bf80f9c Fixed compiler warnings using Visual Studio 2019 2021-09-21 18:15:09 -07:00