ReactOS 0.4.15-dev-8207-gd73a838
__fto64.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS API tests
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Tests for __dtoi64/dtou64/stoi64/stou64 on ARM
5 * COPYRIGHT: Copyright 2021 Roman Masanin <36927roma@gmail.com>
6 */
7
8#include <apitest.h>
9
10typedef struct _DTOI64_TEST_DATA
11{
12 union
13 {
14 double value;
15 unsigned long long raw;
17 long long expected;
19
20typedef struct _DTOU64_TEST_DATA
21{
22 union
23 {
24 double value;
25 unsigned long long raw;
27 unsigned long long expected;
29
30typedef struct _STOI64_TEST_DATA
31{
32 union
33 {
34 float value;
35 unsigned int raw;
37 long long expected;
39
40typedef struct _STOU64_TEST_DATA
41{
42 union
43 {
44 float value;
45 unsigned int raw;
47 unsigned long long expected;
49
51{
52 DTOI64_TEST_DATA dtoi64[] =
53 {
54 { 1383034209.0, 1383034209LL }, /* test 32bit number */
55 { -1383034209.0, -1383034209LL }, /* test negative 32bit number */
56 { 1383034209.1383034209, 1383034209LL }, /* test rounding 32bit */
57 { -1383034209.1383034209, -1383034209LL }, /* test negative rounding 32bit */
58 { 1383034209.83034209, 1383034209LL }, /* test rounding up 32bit */
59 { -1383034209.83034209, -1383034209LL }, /* test negative rounding up 32bit */
60 { 354056757614.0, 354056757614LL }, /* test 64bit int */
61 { -354056757614.0, -354056757614LL }, /* test negative 64bit int */
62 { 354056757614.83034209, 354056757614LL }, /* test 64bit rounding */
63 { 18445937028656326656.0, 0x8000000000000000LL }, /* test unsigned 64bit */
64 { 1.0000001, 1LL },
65 { 0.0000001, 0LL },
66 { -0.0000001, 0LL },
67
68 /* special values tests */
69
70 { -0.0, 0LL }, /* test -0 */
71 { +0.0, 0LL }, /* test +0 */
72 { .given.raw = 0x7FF0000000000000ULL, 0x8000000000000000LL }, /* test +INFINITY */
73 { .given.raw = 0xFFF0000000000000ULL, 0x8000000000000000LL }, /* test -INFINITY */
74 { .given.raw = 0x7FF0000000000001ULL, 0x8000000000000000LL }, /* test NaN1 */
75 { .given.raw = 0x7FF8000000000001ULL, 0x8000000000000000LL }, /* test NaN2 */
76 { .given.raw = 0x7FFFFFFFFFFFFFFFULL, 0x8000000000000000LL }, /* test NaN3 */
77 { .given.raw = 0x7FF80000000000F1ULL, 0x8000000000000000LL }, /* test NaN4 */
78 };
79 DTOU64_TEST_DATA dtou64[] =
80 {
81 { 1383034209.0, 1383034209ULL }, /* test 32bit number */
82 { -1383034209.0, 18446744072326517407ULL }, /* test negative 32bit number */
83 { 1383034209.1383034209, 1383034209ULL }, /* test rounding 32bit */
84 { -1383034209.1383034209, 18446744072326517407ULL }, /* test negative rounding 32bit */
85 { 1383034209.83034209, 1383034209ULL }, /* test rounding up 32bit */
86 { -1383034209.83034209, 18446744072326517407ULL }, /* test negative rounding up 32bit */
87 { 354056757614.0, 354056757614ULL }, /* test 64bit int */
88 { -354056757614.0, 18446743719652794002ULL }, /* test negative 64bit int */
89 { 354056757614.83034209, 354056757614ULL }, /* test 64bit rounding */
90 { 18445937028656326656.0, 18445937028656326656ULL }, /* test unsigned 64bit */
91 { 1.0000001, 1ULL },
92 { 0.0000001, 0ULL },
93 { -0.0000001, 0ULL },
94
95 /* special values tests */
96
97 { -0.0, 0ULL }, /* test -0 */
98 { +0.0, 0ULL }, /* test +0 */
99 { .given.raw = 0x7FF0000000000000ULL, 0x8000000000000000LL }, /* test +INFINITY */
100 { .given.raw = 0xFFF0000000000000ULL, 0x8000000000000000LL }, /* test -INFINITY */
101 { .given.raw = 0x7FF0000000000001ULL, 0x8000000000000000LL }, /* test NaN1 */
102 { .given.raw = 0x7FF8000000000001ULL, 0x8000000000000000LL }, /* test NaN2 */
103 { .given.raw = 0x7FFFFFFFFFFFFFFFULL, 0x8000000000000000LL }, /* test NaN3 */
104 { .given.raw = 0x7FF80000000000F1ULL, 0x8000000000000000LL }, /* test NaN4 */
105 };
106 STOI64_TEST_DATA stoi64[] =
107 {
108 { 1383034.0f, 1383034LL }, /* test 32bit number */
109 { -1383034.0f, -1383034LL }, /* test negative 32bit number */
110 { 1383034.1383034209f, 1383034LL }, /* test rounding 32bit */
111 { -1383034.1383034209f, -1383034LL }, /* test negative rounding 32bit */
112 { 1383034.83034209f, 1383034LL }, /* test rounding up 32bit */
113 { -1383034.83034209f, -1383034LL }, /* test negative rounding up 32bit */
114 { 354056765440.0f, 354056765440LL }, /* test 64bit int */
115 { -354056765440.0f, -354056765440LL }, /* test negative 64bit int */
116 { 3000000.75f, 3000000LL }, /* test 64bit rounding */
117 { 18445937032174764032.0f, 0x8000000000000000LL }, /* test unsigned 64bit */
118 { 1.0000001f, 1LL },
119 { 0.0000001f, 0LL },
120 { -0.0000001f, 0LL },
121
122 /* special values tests */
123
124 { -0.0f, 0LL }, /* test -0 */
125 { +0.0f, 0LL }, /* test +0 */
126 { .given.raw = 0x7F800000U, 0x8000000000000000LL }, /* test +INFINITY */
127 { .given.raw = 0xFF800000U, 0x8000000000000000LL }, /* test -INFINITY */
128 { .given.raw = 0x7F800001U, 0x8000000000000000LL }, /* test NaN1 */
129 { .given.raw = 0x7FC00001U, 0x8000000000000000LL }, /* test NaN2 */
130 { .given.raw = 0x7F8FFFFFU, 0x8000000000000000LL }, /* test NaN3 */
131 { .given.raw = 0x7F8000F1U, 0x8000000000000000LL }, /* test NaN4 */
132 };
133 STOU64_TEST_DATA stou64[] =
134 {
135 { 1383034.0f, 1383034ULL }, /* test 32bit number */
136 { -1383034.0f, 18446744073708168582ULL }, /* test negative 32bit number */
137 { 1383034.1383034209f, 1383034ULL }, /* test rounding 32bit */
138 { -1383034.1383034209f, 18446744073708168582ULL }, /* test negative rounding 32bit */
139 { 1383034.83034209f, 1383034ULL }, /* test rounding up 32bit */
140 { -1383034.83034209f, 18446744073708168582ULL }, /* test negative rounding up 32bit */
141 { 354056765440.0f, 354056765440ULL }, /* test 64bit int */
142 { -354056765440.0f, 18446743719652786176ULL }, /* test negative 64bit int */
143 { 3000000.75f, 3000000ULL }, /* test 64bit rounding */
144 { 18445937032174764032.0f, 18445937032174764032ULL }, /* test unsigned 64bit */
145 { 1.0000001f, 1ULL },
146 { 0.0000001f, 0ULL },
147 { -0.0000001f, 0ULL },
148
149 /* special values tests */
150
151 { -0.0f, 0LL }, /* test -0 */
152 { +0.0f, 0LL }, /* test +0 */
153 {.given.raw = 0x7F800000U, 0x8000000000000000LL }, /* test +INFINITY */
154 {.given.raw = 0xFF800000U, 0x8000000000000000LL }, /* test -INFINITY */
155 {.given.raw = 0x7F800001U, 0x8000000000000000LL }, /* test NaN1 */
156 {.given.raw = 0x7FC00001U, 0x8000000000000000LL }, /* test NaN2 */
157 {.given.raw = 0x7F8FFFFFU, 0x8000000000000000LL }, /* test NaN3 */
158 {.given.raw = 0x7F8000F1U, 0x8000000000000000LL }, /* test NaN4 */
159 };
160
161 unsigned int i;
162
163 for (i = 0; i < _countof(dtoi64); ++i)
164 {
165 long long actual;
166
167 actual = (long long)dtoi64[i].given.value;
168 ok(actual == dtoi64[i].expected, "(dtoi64) %d: Expected %lld, but %lf -> %lld\n",
169 i, dtoi64[i].expected, dtoi64[i].given.value, actual);
170 }
171
172 for (i = 0; i < _countof(dtou64); ++i)
173 {
174 unsigned long long actual;
175
176 actual = (unsigned long long)dtou64[i].given.value;
177 ok(actual == dtou64[i].expected, "(dtou64) %d: Expected %llu, but %lf -> %llu\n",
178 i, dtou64[i].expected, dtou64[i].given.value, actual);
179 }
180
181 for (i = 0; i < _countof(stoi64); ++i)
182 {
183 long long actual;
184
185 actual = (long long)stoi64[i].given.value;
186 ok(actual == stoi64[i].expected, "(stoi64) %d: Expected %lld, but %f -> %lld\n",
187 i, stoi64[i].expected, stoi64[i].given.value, actual);
188 }
189
190 for (i = 0; i < _countof(stou64); ++i)
191 {
192 unsigned long long actual;
193
194 actual = (unsigned long long)stou64[i].given.value;
195 ok(actual == stou64[i].expected, "(stou64) %d: Expected %llu, but %f -> %llu\n",
196 i, stou64[i].expected, stou64[i].given.value, actual);
197 }
198}
#define __fto64
Definition: __dtoi64.c:8
struct _DTOU64_TEST_DATA DTOU64_TEST_DATA
struct _STOU64_TEST_DATA STOU64_TEST_DATA
struct _DTOI64_TEST_DATA DTOI64_TEST_DATA
struct _STOI64_TEST_DATA STOI64_TEST_DATA
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
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
BOOL expected
Definition: store.c:2063
#define ULL(a, b)
Definition: format_msg.c:27
#define long
Definition: qsort.c:33
#define _countof(array)
Definition: sndvol32.h:70
double value
Definition: __fto64.c:14
unsigned long long raw
Definition: __fto64.c:15
long long expected
Definition: __fto64.c:17
union _DTOI64_TEST_DATA::@1596 given
unsigned long long raw
Definition: __fto64.c:25
unsigned long long expected
Definition: __fto64.c:27
double value
Definition: __fto64.c:24
union _DTOU64_TEST_DATA::@1597 given
union _STOI64_TEST_DATA::@1598 given
unsigned int raw
Definition: __fto64.c:35
long long expected
Definition: __fto64.c:37
unsigned int raw
Definition: __fto64.c:45
unsigned long long expected
Definition: __fto64.c:47
union _STOU64_TEST_DATA::@1599 given
#define LL
Definition: tui.h:167