Commit Graph

54 Commits

Author SHA1 Message Date
Anonymous Maarten
1737340978 Use helper_ddtod function to compare atan2 infinity cases
This fixes a test failure when building on mingw32 in Release mode.
2024-01-21 23:44:53 +01:00
Anonymous Maarten
69a6efcd1b Avoid using higher precision floating point numbers by using it in a function 2024-01-21 23:44:53 +01:00
Anonymous Maarten
880c69392a testautomation_math: do relative comparison + more precise correct trigonometric values 2024-01-21 23:44:53 +01:00
Sam Lantinga
e3203278f4 Updated tests so they'll pass if we enable the C runtime in SDL2.dll
This isn't needed here, but will be necessary for sdl2-compat
2024-01-21 11:23:50 -08:00
Simon McVittie
69f3bb2e34 test: Accept small numerical differences in more mathematical tests
We can't rely on irrational numbers like pi being represented exactly,
particularly when compiling for i386, where the i387 floating-point
interface carries out calculations in registers that have higher
precision than the actual double-precision variable. The 1980s were a
strange time.

Resolves: https://github.com/libsdl-org/SDL/issues/8311
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 6248472c0c738496a6f246aafa07a0e30afa6a01)
2024-01-09 06:06:46 -08:00
Anonymous Maarten
d1c5038f16 testautomation: don't do float equality tests
(cherry picked from commit 474c8d0073b0fb4b14b65b79c7e620db1332e4f3)
2024-01-09 06:06:46 -08:00
Anonymous Maarten
fcae9cd210 cmake: build with -Wdocumentation 2023-08-09 02:53:48 +02:00
Anonymous Maarten
977781d3f4 testautomation_math: avoid equality tests with INFINITY
Fixes this warning:
 warning: comparison with infinity always evaluates to false in fast floating point modes [-Wtautological-constant-compare]
2023-03-27 06:13:28 +00:00
Pierre Wendling
d0bbfdbfb8 Clang-Tidy fixes (#6725)
(cherry picked from commit 3c501b963dd8f0605a6ce7978882df39ba76f9cd)
2022-12-01 13:08:50 -08:00
Sam Lantinga
b8d85c6939 Update for SDL3 coding style (#6717)
I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base.

In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted.

The script I ran for the src directory is added as build-scripts/clang-format-src.sh

This fixes:
#6592
#6593
#6594

(cherry picked from commit 5750bcb174300011b91d1de20edb288fcca70f8c)
2022-11-30 12:57:41 -08:00
Pierre Wendling
6784d84c9d N3DS: Fix -Wformat warnings in tests.
All warnings were about invalid specifiers. Since U/Sint32 is a long,
using `%d` emits a -Wformat warning.
2022-10-10 08:50:59 -07:00
Pierre Wendling
73d8d02629 Test: Fix Exp base case for Win32.
Add epsilon to the check.
2022-08-09 21:39:46 -07:00
Pierre Wendling
6bd3e0b189 Test: Check sqrt and atan against the epsilon.
On i686-linux, the `sqrt_regularCases` and `atan_limitCases` tests would
fail as the result was not precise enough.
2022-06-15 23:32:40 +03:00
Pierre Wendling
cee47a9ebe Test: Use inexact helper for log10 regular cases.
On ARMv6, the result is not precise enough for this function.
2022-06-15 12:05:30 -07:00
Pierre Wendling
a52b8580f0 Test: Tidy up test descriptions and documentation.
Test function documentation now lists the input(s) and expected output(s).
Descriptions in TestCaseReference were updated.
2022-06-15 12:05:30 -07:00
Pierre Wendling
4d7f12f6bd Test: Add Atan2 tests to math suite. 2022-06-15 12:05:30 -07:00
Pierre Wendling
8ebe640a36 Test: Change inexact tests to use an epsilon.
Instead of using `trunc` to check the first ten digits, inexact test now
relies on an epsilon defining an acceptable range for the expected
result to be in.
2022-06-15 12:05:30 -07:00
Pierre Wendling
62fd6aad39 Test: Add Atan tests to math suite. 2022-06-15 12:05:30 -07:00
Pierre Wendling
6a6e93bc29 Test: Add +/-0.0 tests to Acos. 2022-06-15 12:05:30 -07:00
Pierre Wendling
6b4b6d8e59 Test: Add Asin tests to math suite. 2022-06-15 12:05:30 -07:00
Pierre Wendling
43f6983a24 Test: Add Acos tests to math suite. 2022-06-15 12:05:30 -07:00
Pierre Wendling
95f6edb9a5 Test: Refactor trigonometric tests into a helper.
The precision test of these functions need a special helper, it can also
be used for their arc functions down the line.
2022-06-15 12:05:30 -07:00
Pierre Wendling
3b9f47b85f Test: Remove early return in pow test. 2022-06-15 12:05:30 -07:00
Pierre Wendling
6be430c7f7 Test: Add Tan tests to math suite. 2022-06-15 12:05:30 -07:00
Pierre Wendling
af79b46f9e Test: Add Sin tests to math suite. 2022-06-15 12:05:30 -07:00
Pierre Wendling
b06eda55e9 Test: Fix math suite build on Win32.
The cosine precision test now uses an array of double and the result
gets truncated instead of casted to signed int64.
2022-06-15 12:05:30 -07:00
Pierre Wendling
adb445eafb Test: Add Cos tests to math suite. 2022-06-15 12:05:30 -07:00
Pierre Wendling
a864180cf3 Test: Add float header for FLT_RADIX definition. 2022-06-15 12:05:30 -07:00
Pierre Wendling
7a55fa4e56 Test: Add Scalbn tests to math suite. 2022-06-15 12:05:30 -07:00
Pierre Wendling
afd812374f Test: Add Sqrt tests to math suite. 2022-06-15 12:05:30 -07:00
Pierre Wendling
c389c32d30 Test: Change assertion type in range tests.
Changes SDLTest_AssertPass(...) to SDLTest_AssertCheck(SDL_FALSE, ...)
for failed assertions so the internal counter gets updated properly.
2022-06-15 12:05:30 -07:00
Pierre Wendling
5ecc75a4fc Test: Add Pow tests to math suite. 2022-06-15 12:05:30 -07:00
Pierre Wendling
6349ad7319 Test: Add Log10 tests to math suite. 2022-06-15 12:05:30 -07:00
Pierre Wendling
7041bbaf00 Test: Add Log tests to math suite. 2022-06-15 12:05:30 -07:00
Pierre Wendling
dd30ff2e31 Test: Add Exp tests to math suite. 2022-06-15 12:05:30 -07:00
Pierre Wendling
aacb5e1774 Test: Extract range test parameters into defines. 2022-06-15 12:05:30 -07:00
Pierre Wendling
75b9aab6c1 Test: Add Fmod tests to math suite. 2022-06-15 12:05:30 -07:00
Pierre Wendling
0dbdf90e7b Test: Use SDLCALL in typedefs instead of ifdefs.
Thanks to @sezero for the tip.
2022-06-15 12:05:30 -07:00
Pierre Wendling
2ec48b36ba Test: Fix OS/2 compilation in math suite. 2022-06-15 12:05:30 -07:00
Pierre Wendling
43c22e5d1e Test: Refactor math suite duplicate code.
Many tests were using the same underlying routine, as such three helper
functions were added:
- A wrapper to test double -> double functions.
- A wrapper to test (double, double) -> double functions,
- A wrapper for range tests on double -> double functions.
2022-06-15 12:05:30 -07:00
Pierre Wendling
3d720ba381 Test: Refactor math suites edge cases.
Split infinity and zero checks in their own functions.
The result of NAN tests is now logged.
The SDL_TestCaseReference structure were renamed to be more explicit.
2022-06-15 12:05:30 -07:00
Pierre Wendling
a530fc9199 Test: Add Copysign tests to math suite. 2022-06-15 12:05:30 -07:00
Pierre Wendling
48a406db4d Test: Add Fabs tests to math suite. 2022-06-15 12:05:30 -07:00
Pierre Wendling
2130dff0fc Test: Add Round tests to math suite. 2022-06-15 12:05:30 -07:00
Pierre Wendling
324b96153f Test: Add Trunc tests to math suite. 2022-06-15 12:05:30 -07:00
Pierre Wendling
b09266a4ef Test: Add Ceil tests to math suite. 2022-06-15 12:05:30 -07:00
Pierre Wendling
9eb09d2392 Test: Refactored and formatted math test suite. 2022-06-15 12:05:30 -07:00
Pierre Wendling
e64acb619a Test: Fix for-loop for OS/2 in math suite. 2022-06-15 12:05:30 -07:00
Pierre Wendling
a3a852e912 Test: Unrolled the array of cases in math suite.
On OS/2, `INFINITY` is a `const double` which cannot be used to
instantiate an array.
2022-06-15 12:05:30 -07:00
Pierre Wendling
c23216bf46 Test: Removed static from local variables (Math).
Static would break compilation on OS/2.
2022-06-15 12:05:30 -07:00