ReactOS 0.4.15-dev-7942-gd23573b
floor.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 floor / floorf
5 * COPYRIGHT: Copyright 2021 Timo Kreuzer <timo.kreuzer@reactos.org>
6 */
7
8#if !defined(_CRTBLD) && !defined(_M_IX86)
9#define _CRTBLD // we don't want inline floorf!
10#endif
11#include "math_helpers.h"
12
13#ifdef _MSC_VER
14#pragma function(floor)
15#ifdef _M_AMD64
16#pragma function(floorf)
17#endif
18#endif
19
21{
22 /* Special values */
23 { 0x0000000000000000 /* 0.000000000000000e+000 */, 0x0000000000000000 /* 0.000000000000000e+000 */ },
24 { 0x8000000000000000 /* -0.000000000000000e+000 */, 0x8000000000000000 /* -0.000000000000000e+000 */ },
25 { 0x7ff0000000000000 /* 1.#INF00000000000e+000 */, 0x7ff0000000000000 /* 1.#INF00000000000e+000 */ },
26 { 0x7ff0000000000001 /* 1.#QNAN0000000000e+000 */, 0x7ff8000000000001 /* 1.#QNAN0000000000e+000 */ },
27 { 0x7ff7ffffffffffff /* 1.#QNAN0000000000e+000 */, 0x7fffffffffffffff /* 1.#QNAN0000000000e+000 */ },
28 { 0x7ff8000000000000 /* 1.#QNAN0000000000e+000 */, 0x7ff8000000000000 /* 1.#QNAN0000000000e+000 */ },
29 { 0x7ff8000000000001 /* 1.#QNAN0000000000e+000 */, 0x7ff8000000000001 /* 1.#QNAN0000000000e+000 */ },
30 { 0x7fffffffffffffff /* 1.#QNAN0000000000e+000 */, 0x7fffffffffffffff /* 1.#QNAN0000000000e+000 */ },
31 { 0xfff0000000000000 /* -1.#INF00000000000e+000 */, 0xfff0000000000000 /* -1.#INF00000000000e+000 */ },
32 { 0xfff0000000000001 /* -1.#QNAN0000000000e+000 */, 0xfff8000000000001 /* -1.#QNAN0000000000e+000 */ },
33 { 0xfff7ffffffffffff /* -1.#QNAN0000000000e+000 */, 0xffffffffffffffff /* -1.#QNAN0000000000e+000 */ },
34 { 0xfff8000000000000 /* -1.#IND00000000000e+000 */, 0xfff8000000000000 /* -1.#IND00000000000e+000 */ },
35 { 0xfff8000000000001 /* -1.#QNAN0000000000e+000 */, 0xfff8000000000001 /* -1.#QNAN0000000000e+000 */ },
36 { 0xffffffffffffffff /* -1.#QNAN0000000000e+000 */, 0xffffffffffffffff /* -1.#QNAN0000000000e+000 */ },
37
38 /* Some random doubles */
39 { 0x386580c747a3402b /* 5.055340589883462e-037 */, 0x0000000000000000 /* 0.000000000000000e+000 */ },
40 { 0xb74298e6627fb9ed /* -1.667860443847725e-042 */, 0xbff0000000000000 /* -1.000000000000000e+000 */ },
41 { 0x0ef25f06e414aa2d /* 1.128498317470960e-236 */, 0x0000000000000000 /* 0.000000000000000e+000 */ },
42 { 0x24002a37167638b5 /* 2.780001692929186e-135 */, 0x0000000000000000 /* 0.000000000000000e+000 */ },
43 { 0x44258d1be62a0d22 /* 1.987747995999515e+020 */, 0x44258d1be62a0d22 /* 1.987747995999515e+020 */ },
44 { 0x9ed4e46a65aad464 /* -3.715074250469020e-160 */, 0xbff0000000000000 /* -1.000000000000000e+000 */ },
45 { 0xc5afcd6f4ae4bf41 /* -4.921195330852160e+027 */, 0xc5afcd6f4ae4bf41 /* -4.921195330852160e+027 */ },
46 { 0x330fac896cbb01d2 /* 9.624395081137827e-063 */, 0x0000000000000000 /* 0.000000000000000e+000 */ },
47 { 0xc18026ab4c845405 /* -3.387120956461338e+007 */, 0xc18026ab50000000 /* -3.387121000000000e+007 */ },
48 { 0x2f42a7dc898a741a /* 4.916804395045249e-081 */, 0x0000000000000000 /* 0.000000000000000e+000 */ },
49};
50
51
52void Test_floor(void)
53{
54 int i;
55
56 for (i = 0; i < _countof(s_floor_tests); i++)
57 {
58 double x = u64_to_dbl(s_floor_tests[i].x);
59 double z = floor(x);
61 }
62}
63
65{
66 /* Special values */
67 { 0x00000000 /* 0.000000e+000 */, 0x00000000 /* 0.000000e+000 */ },
68 { 0x00000000 /* 0.000000e+000 */, 0x00000000 /* 0.000000e+000 */ },
69 { 0x00000000 /* 0.000000e+000 */, 0x00000000 /* 0.000000e+000 */ },
70 { 0x00000001 /* 1.401298e-045 */, 0x00000000 /* 0.000000e+000 */ },
71 { 0xffffffff /* -1.#QNAN0e+000 */, 0xffffffff /* -1.#QNAN0e+000 */ },
72 { 0x00000000 /* 0.000000e+000 */, 0x00000000 /* 0.000000e+000 */ },
73 { 0x00000001 /* 1.401298e-045 */, 0x00000000 /* 0.000000e+000 */ },
74 { 0xffffffff /* -1.#QNAN0e+000 */, 0xffffffff /* -1.#QNAN0e+000 */ },
75 { 0x00000000 /* 0.000000e+000 */, 0x00000000 /* 0.000000e+000 */ },
76 { 0x00000001 /* 1.401298e-045 */, 0x00000000 /* 0.000000e+000 */ },
77 { 0xffffffff /* -1.#QNAN0e+000 */, 0xffffffff /* -1.#QNAN0e+000 */ },
78 { 0x00000000 /* 0.000000e+000 */, 0x00000000 /* 0.000000e+000 */ },
79 { 0x00000001 /* 1.401298e-045 */, 0x00000000 /* 0.000000e+000 */ },
80 { 0xffffffff /* -1.#QNAN0e+000 */, 0xffffffff /* -1.#QNAN0e+000 */ },
81
82 /* Some random floats */
83 { 0x386580c7 /* 5.471779e-005 */, 0x00000000 /* 0.000000e+000 */ },
84 { 0x47a3402b /* 8.358434e+004 */, 0x47a34000 /* 8.358400e+004 */ },
85 { 0xb74298e6 /* -1.159890e-005 */, 0xbf800000 /* -1.000000e+000 */ },
86 { 0x627fb9ed /* 1.179329e+021 */, 0x627fb9ed /* 1.179329e+021 */ },
87 { 0x0ef25f06 /* 5.974911e-030 */, 0x00000000 /* 0.000000e+000 */ },
88 { 0xe414aa2d /* -1.096952e+022 */, 0xe414aa2d /* -1.096952e+022 */ },
89 { 0x24002a37 /* 2.779133e-017 */, 0x00000000 /* 0.000000e+000 */ },
90 { 0x167638b5 /* 1.988962e-025 */, 0x00000000 /* 0.000000e+000 */ },
91 { 0x44258d1b /* 6.622048e+002 */, 0x44258000 /* 6.620000e+002 */ },
92 { 0xe62a0d22 /* -2.007611e+023 */, 0xe62a0d22 /* -2.007611e+023 */ },
93};
94
95void Test_floorf(void)
96{
97 int i;
98
99 for (i = 0; i < _countof(s_floorf_tests); i++)
100 {
101 float x = u32_to_flt(s_floorf_tests[i].x);
102 float z = floorf(x);
104 }
105}
106
108{
109 Test_floor();
110 Test_floorf();
111}
#define START_TEST(x)
Definition: atltest.h:75
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint64EXT * result
Definition: glext.h:11304
GLdouble GLdouble z
Definition: glext.h:5874
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_ _CRTIMP double __cdecl floor(_In_ double x)
#define ok_eq_dbl_exact(func, ullx, z, ullexp)
Definition: math_helpers.h:67
static __inline double u64_to_dbl(UINT64 x)
Definition: math_helpers.h:18
static __inline float u32_to_flt(UINT32 x)
Definition: math_helpers.h:34
#define ok_eq_flt_exact(func, ux, z, uexp)
Definition: math_helpers.h:77
static TESTENTRY_DBL s_floor_tests[]
Definition: floor.c:20
static TESTENTRY_FLT s_floorf_tests[]
Definition: floor.c:64
void Test_floorf(void)
Definition: floor.c:95
void Test_floor(void)
Definition: floor.c:52
#define floorf(x)
Definition: mymath.h:65
#define _countof(array)
Definition: sndvol32.h:68