ReactOS 0.4.16-dev-1946-g52006dd
_finite.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS API tests
3 * LICENSE: MIT (https://spdx.org/licenses/MIT)
4 * PURPOSE: Tests for _finite / _finitef
5 * COPYRIGHT: Copyright 2025 Timo Kreuzer <timo.kreuzer@reactos.org>
6 */
7
8#if !defined(_CRTBLD) && !defined(_M_IX86)
9#define _CRTBLD // we don't want inline _finitef!
10#endif
11#include "math_helpers.h"
12
14{
15 /* Special values */
16 { 0x0000000000000000 /* 0.000000000000000e+000 */, 1 },
17 { 0x0000000000000001 /* 0.000000000000000e+000 */, 1 },
18 { 0x000fffffffffffff /* 0.000000000000000e+000 */, 1 },
19 { 0x8000000000000000 /* -0.000000000000000e+000 */, 1 },
20 { 0x8000000000000001 /* -0.000000000000000e+000 */, 1 },
21 { 0x800fffffffffffff /* -0.000000000000000e+000 */, 1 },
22 { 0x7ff0000000000000 /* 1.#INF00000000000e+000 */, 0 },
23 { 0x7ff0000000000001 /* 1.#QNAN0000000000e+000 */, 0 },
24 { 0x7ff7ffffffffffff /* 1.#QNAN0000000000e+000 */, 0 },
25 { 0x7ff8000000000000 /* 1.#QNAN0000000000e+000 */, 0 },
26 { 0x7ff8000000000001 /* 1.#QNAN0000000000e+000 */, 0 },
27 { 0x7fffffffffffffff /* 1.#QNAN0000000000e+000 */, 0 },
28 { 0xfff0000000000000 /* -1.#INF00000000000e+000 */, 0 },
29 { 0xfff0000000000001 /* -1.#QNAN0000000000e+000 */, 0 },
30 { 0xfff7ffffffffffff /* -1.#QNAN0000000000e+000 */, 0 },
31 { 0xfff8000000000000 /* -1.#IND00000000000e+000 */, 0 },
32 { 0xfff8000000000001 /* -1.#QNAN0000000000e+000 */, 0 },
33 { 0xffffffffffffffff /* -1.#QNAN0000000000e+000 */, 0 },
34
35 /* Some random doubles */
36 { 0x386580c747a3402b /* 5.055340589883462e-037 */, 1 },
37 { 0xb74298e6627fb9ed /* -1.667860443847725e-042 */, 1 },
38 { 0x0ef25f06e414aa2d /* 1.128498317470960e-236 */, 1 },
39 { 0x24002a37167638b5 /* 2.780001692929186e-135 */, 1 },
40 { 0x44258d1be62a0d22 /* 1.987747995999515e+020 */, 1 },
41 { 0x9ed4e46a65aad464 /* -3.715074250469020e-160 */, 1 },
42 { 0xc5afcd6f4ae4bf41 /* -4.921195330852160e+027 */, 1 },
43 { 0x330fac896cbb01d2 /* 9.624395081137827e-063 */, 1 },
44 { 0xc18026ab4c845405 /* -3.387120956461338e+007 */, 1 },
45 { 0x2f42a7dc898a741a /* 4.916804395045249e-081 */, 1 },
46};
47
48
49void Test__finite(void)
50{
51 int i;
52
53 for (i = 0; i < _countof(s_finite_tests); i++)
54 {
55 double x = u64_to_dbl(s_finite_tests[i].x);
56 int r = _finite(x);
57 ok(r == s_finite_tests[i].result, "Wrong result for %f [0x%016I64x]. Expected %d, got %d\n", x, s_finite_tests[i].x, s_finite_tests[i].result, r);
58 }
59}
60
61#ifndef _M_IX86
63{
64 /* Special values */
65 { 0x00000000 /* 0.000000 */, 1 },
66 { 0x00000001 /* 0.000000 */, 1 },
67 { 0x007FFFFF /* 0.000000 */, 1 },
68 { 0x80000000 /* -0.000000 */, 1 },
69 { 0x80000001 /* -0.000000 */, 1 },
70 { 0x807FFFFF /* -0.000000 */, 1 },
71 { 0x7f800000 /* 1.#INF00 */, 0 },
72 { 0x7f800001 /* 1.#SNAN0 */, 0 },
73 { 0x7fBFffff /* 1.#SNAN0 */, 0 },
74 { 0x7fC00000 /* 1.#QNAN0 */, 0 },
75 { 0x7fC80001 /* 1.#QNAN0 */, 0 },
76 { 0x7fFfffff /* 1.#QNAN0 */, 0 },
77 { 0xff800000 /* -1.#INF00 */, 0 },
78 { 0xff800001 /* -1.#SNAN0 */, 0 },
79 { 0xffBfffff /* -1.#SNAN0 */, 0 },
80 { 0xffC00000 /* -1.#IND00 */, 0 },
81 { 0xfff80001 /* -1.#QNAN0 */, 0 },
82 { 0xffffffff /* -1.#QNAN0 */, 0 },
83
84 /* Some random floats */
85 { 0x386580c7 /* 5.471779e-005 */, 1 },
86 { 0x47a3402b /* 8.358434e+004 */, 1 },
87 { 0xb74298e6 /* -1.159890e-005 */, 1 },
88 { 0x627fb9ed /* 1.179329e+021 */, 1 },
89 { 0x0ef25f06 /* 5.974911e-030 */, 1 },
90 { 0xe414aa2d /* -1.096952e+022 */, 1 },
91 { 0x24002a37 /* 2.779133e-017 */, 1 },
92 { 0x167638b5 /* 1.988962e-025 */, 1 },
93 { 0x44258d1b /* 6.622048e+002 */, 1 },
94 { 0xe62a0d22 /* -2.007611e+023 */, 1 },
95};
96
97void Test__finitef(void)
98{
99 int i;
100
101 for (i = 0; i < _countof(s_finitef_tests); i++)
102 {
103 float x = u32_to_flt(s_finitef_tests[i].x);
104 int r = _finitef(x);
105 ok(r == s_finitef_tests[i].result, "Wrong result for %f [0x%08lx]. Expected %d, got %d\n", x, s_finitef_tests[i].x, s_finitef_tests[i].result, r);
106 }
107}
108#endif // !_MIX86
109
111{
112 Test__finite();
113#ifndef _M_IX86
115#endif // !_MIX86
116}
_Check_return_ int __cdecl _finitef(_In_ float _X)
Definition: _finitef.c:14
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint64EXT * result
Definition: glext.h:11304
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_Check_return_ __MINGW_NOTHROW _CRTIMP int __cdecl _finite(_In_ double)
Definition: _finite.c:14
static __inline double u64_to_dbl(UINT64 x)
Definition: math_helpers.h:25
static __inline float u32_to_flt(UINT32 x)
Definition: math_helpers.h:41
void Test__finitef(void)
Definition: _finite.c:97
static TESTENTRY_FLT s_finitef_tests[]
Definition: _finite.c:62
static TESTENTRY_DBL_INT s_finite_tests[]
Definition: _finite.c:13
void Test__finite(void)
Definition: _finite.c:49
#define _countof(array)
Definition: sndvol32.h:70