ReactOS 0.4.16-dev-1946-g52006dd
_isnan.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 _isnan / _isnanf
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 _isnanf!
10#endif
11#include "math_helpers.h"
12
14{
15 /* Special values */
16 { 0x0000000000000000 /* 0.000000000000000e+000 */, 0 },
17 { 0x0000000000000001 /* 0.000000000000000e+000 */, 0 },
18 { 0x000fffffffffffff /* 0.000000000000000e+000 */, 0 },
19 { 0x8000000000000000 /* -0.000000000000000e+000 */, 0 },
20 { 0x8000000000000001 /* -0.000000000000000e+000 */, 0 },
21 { 0x800fffffffffffff /* -0.000000000000000e+000 */, 0 },
22 { 0x7ff0000000000000 /* 1.#INF00000000000e+000 */, 0 },
23 { 0x7ff0000000000001 /* 1.#QNAN0000000000e+000 */, 1 },
24 { 0x7ff7ffffffffffff /* 1.#QNAN0000000000e+000 */, 1 },
25 { 0x7ff8000000000000 /* 1.#QNAN0000000000e+000 */, 1 },
26 { 0x7ff8000000000001 /* 1.#QNAN0000000000e+000 */, 1 },
27 { 0x7fffffffffffffff /* 1.#QNAN0000000000e+000 */, 1 },
28 { 0xfff0000000000000 /* -1.#INF00000000000e+000 */, 0 },
29 { 0xfff0000000000001 /* -1.#QNAN0000000000e+000 */, 1 },
30 { 0xfff7ffffffffffff /* -1.#QNAN0000000000e+000 */, 1 },
31 { 0xfff8000000000000 /* -1.#IND00000000000e+000 */, 1 },
32 { 0xfff8000000000001 /* -1.#QNAN0000000000e+000 */, 1 },
33 { 0xffffffffffffffff /* -1.#QNAN0000000000e+000 */, 1 },
34
35 /* Some random doubles */
36 { 0x386580c747a3402b /* 5.055340589883462e-037 */, 0 },
37 { 0xb74298e6627fb9ed /* -1.667860443847725e-042 */, 0 },
38 { 0x0ef25f06e414aa2d /* 1.128498317470960e-236 */, 0 },
39 { 0x24002a37167638b5 /* 2.780001692929186e-135 */, 0 },
40 { 0x44258d1be62a0d22 /* 1.987747995999515e+020 */, 0 },
41 { 0x9ed4e46a65aad464 /* -3.715074250469020e-160 */, 0 },
42 { 0xc5afcd6f4ae4bf41 /* -4.921195330852160e+027 */, 0 },
43 { 0x330fac896cbb01d2 /* 9.624395081137827e-063 */, 0 },
44 { 0xc18026ab4c845405 /* -3.387120956461338e+007 */, 0 },
45 { 0x2f42a7dc898a741a /* 4.916804395045249e-081 */, 0 },
46};
47
48
49void Test__isnan(void)
50{
51 int i;
52
53 for (i = 0; i < _countof(s_isnan_tests); i++)
54 {
55 double x = u64_to_dbl(s_isnan_tests[i].x);
56 int r = _isnan(x);
57 ok(r == s_isnan_tests[i].result, "Wrong result for %f [0x%016I64x]. Expected %d, got %d\n", x, s_isnan_tests[i].x, s_isnan_tests[i].result, r);
58 }
59}
60
61#ifndef _M_IX86
63{
64 /* Special values */
65 { 0x00000000 /* 0.000000 */, 0 },
66 { 0x00000001 /* 0.000000 */, 0 },
67 { 0x007FFFFF /* 0.000000 */, 0 },
68 { 0x80000000 /* -0.000000 */, 0 },
69 { 0x80000001 /* -0.000000 */, 0 },
70 { 0x807FFFFF /* -0.000000 */, 0 },
71 { 0x7f800000 /* 1.#INF00 */, 0 },
72 { 0x7f800001 /* 1.#SNAN0 */, 1 },
73 { 0x7fBFffff /* 1.#SNAN0 */, 1 },
74 { 0x7fC00000 /* 1.#QNAN0 */, 1 },
75 { 0x7fC80001 /* 1.#QNAN0 */, 1 },
76 { 0x7fFfffff /* 1.#QNAN0 */, 1 },
77 { 0xff800000 /* -1.#INF00 */, 0 },
78 { 0xff800001 /* -1.#SNAN0 */, 1 },
79 { 0xffBfffff /* -1.#SNAN0 */, 1 },
80 { 0xffC00000 /* -1.#IND00 */, 1 },
81 { 0xfff80001 /* -1.#QNAN0 */, 1 },
82 { 0xffffffff /* -1.#QNAN0 */, 1 },
83
84 /* Some random floats */
85 { 0x386580c7 /* 5.471779e-005 */, 0 },
86 { 0x47a3402b /* 8.358434e+004 */, 0 },
87 { 0xb74298e6 /* -1.159890e-005 */, 0 },
88 { 0x627fb9ed /* 1.179329e+021 */, 0 },
89 { 0x0ef25f06 /* 5.974911e-030 */, 0 },
90 { 0xe414aa2d /* -1.096952e+022 */, 0 },
91 { 0x24002a37 /* 2.779133e-017 */, 0 },
92 { 0x167638b5 /* 1.988962e-025 */, 0 },
93 { 0x44258d1b /* 6.622048e+002 */, 0 },
94 { 0xe62a0d22 /* -2.007611e+023 */, 0 },
95};
96
97void Test__isnanf(void)
98{
99 int i;
100
101 for (i = 0; i < _countof(s_isnanf_tests); i++)
102 {
103 float x = u32_to_flt(s_isnanf_tests[i].x);
104 int r = _isnanf(x);
105 ok(r == s_isnanf_tests[i].result, "Wrong result for %f [0x%08lx]. Expected %d, got %d\n", x, s_isnanf_tests[i].x, s_isnanf_tests[i].result, r);
106 }
107}
108#endif // !_MIX86
109
111{
112 Test__isnan();
113#ifndef _M_IX86
114 Test__isnanf();
115#endif // !_MIX86
116}
int __cdecl _isnanf(_In_ float _X)
Definition: _isnanf.c:13
#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 _isnan(_In_ double)
Definition: _isnan.c:13
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__isnan(void)
Definition: _isnan.c:49
static TESTENTRY_DBL_INT s_isnan_tests[]
Definition: _isnan.c:13
void Test__isnanf(void)
Definition: _isnan.c:97
static TESTENTRY_FLT s_isnanf_tests[]
Definition: _isnan.c:62
#define _countof(array)
Definition: sndvol32.h:70