ReactOS 0.4.15-dev-8219-ge8b88cf
__64tof.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 __i64tod/u64tod/i64tos/u64tos on ARM
5 * COPYRIGHT: Copyright 2021 Stanislav Motylkov <x86corez@gmail.com>
6 */
7
8#include <apitest.h>
9
10typedef struct _I64TOD_TEST_DATA
11{
12 long long given;
13 union
14 {
15 double value;
16 unsigned long long raw;
19
20typedef struct _U64TOD_TEST_DATA
21{
22 unsigned long long given;
23 union
24 {
25 double value;
26 unsigned long long raw;
29
30typedef struct _I64TOS_TEST_DATA
31{
32 long long given;
33 union
34 {
35 float value;
36 unsigned int raw;
39
40typedef struct _U64TOS_TEST_DATA
41{
42 unsigned long long given;
43 union
44 {
45 float value;
46 unsigned int raw;
49
51{
52 I64TOD_TEST_DATA i64tod[] =
53 {
54 { 1383034209LL, 1383034209.0 }, /* test 32bit number */
55 { -1383034209LL, -1383034209.0 }, /* test negative 32bit number */
56 { 354056757614LL, 354056757614.0 }, /* test 64bit int */
57 { -354056757614LL, -354056757614.0 }, /* test negative 64bit int */
58 { 18446744073709550000LL, -1616.0 }, /* test 20bit in float */
59 { 0x8000000000000000LL, -9223372036854775800.0 }, /* test big 64bit int */
60 { 0xFFFFFFFFFFFFFFFFLL, -1.0 }, /* test -1 */
61 { 0LL, +0.0 }, /* test 0 */
62 };
63 U64TOD_TEST_DATA u64tod[] =
64 {
65 { 1383034209ULL, 1383034209.0 }, /* test 32bit number */
66 { 354056757614ULL, 354056757614.0 }, /* test 64bit int */
67 { 18445937028656326656ULL, 18445937028656326656.0 }, /* test unsigned 64bit */
68 { 18446744073709550000ULL, 18446744073709550000.0 }, /* test 20bit in float */
69 { 18446744073709551615ULL, 18446744073709552000.0 }, /* test big 64bit number */
70 { 0ULL, +0.0 }, /* test 0 */
71 };
72 I64TOS_TEST_DATA i64tos[] =
73 {
74 { 1383034LL, 1383034.0f }, /* test 32bit number */
75 { -1383034LL, -1383034.0f }, /* test negative 32bit number */
76 { 354056765440LL, 354056765440.0f }, /* test 64bit int */
77 { -354056765440LL, -354056765440.0f }, /* test negative 64bit int */
78 { 18446744073709550000LL, -1616.0f }, /* test 20bit in float */
79 { 0x8000000000000000LL, -9223372036854775800.0f }, /* test big 64bit int */
80 { 0xFFFFFFFFFFFFFFFFLL, -1.0f }, /* test -1 */
81 { 0LL, +0.0f }, /* test 0 */
82 };
83 U64TOS_TEST_DATA u64tos[] =
84 {
85 { 1383034ULL, 1383034.0f }, /* test 32bit number */
86 { 354056765440ULL, 354056765440.0f }, /* test 64bit int */
87 { 18445937032174764032ULL, 18445937032174764032.0f }, /* test unsigned 64bit */
88 { 18446744073709550000ULL, 18446744073709550000.0f }, /* test 20bit in float */
89 { 18446744073709551615ULL, 18446744073709552000.0f }, /* test big 64bit number */
90 { 0ULL, +0.0f }, /* test 0 */
91 };
92
93 unsigned int i;
94
95 for (i = 0; i < _countof(i64tod); ++i)
96 {
97 double actual;
98
99 actual = (double)i64tod[i].given;
100 ok(actual == i64tod[i].expected.value, "(i64tod) %d: Expected %lf, but %lld -> %lf\n",
101 i, i64tod[i].expected.value, i64tod[i].given, actual);
102 }
103
104 for (i = 0; i < _countof(u64tod); ++i)
105 {
106 double actual;
107
108 actual = (double)u64tod[i].given;
109 ok(actual == u64tod[i].expected.value, "(u64tod) %d: Expected %lf, but %llu -> %lf\n",
110 i, u64tod[i].expected.value, u64tod[i].given, actual);
111 }
112
113 for (i = 0; i < _countof(i64tos); ++i)
114 {
115 float actual;
116
117 actual = (float)i64tos[i].given;
118 ok(actual == i64tos[i].expected.value, "(i64tos) %d: Expected %f, but %lld -> %f\n",
119 i, i64tos[i].expected.value, i64tos[i].given, actual);
120 }
121
122 for (i = 0; i < _countof(u64tos); ++i)
123 {
124 float actual;
125
126 actual = (float)u64tos[i].given;
127 ok(actual == u64tos[i].expected.value, "(u64tos) %d: Expected %f, but %llu -> %f\n",
128 i, u64tos[i].expected.value, u64tos[i].given, actual);
129 }
130}
struct _I64TOD_TEST_DATA I64TOD_TEST_DATA
struct _I64TOS_TEST_DATA I64TOS_TEST_DATA
struct _U64TOS_TEST_DATA U64TOS_TEST_DATA
struct _U64TOD_TEST_DATA U64TOD_TEST_DATA
#define __64tof
Definition: __i64tod.c:8
#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
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80
static float(__cdecl *square_half_float)(float x
#define _countof(array)
Definition: sndvol32.h:70
double value
Definition: __64tof.c:15
union _I64TOD_TEST_DATA::@1592 expected
long long given
Definition: __64tof.c:12
unsigned long long raw
Definition: __64tof.c:16
long long given
Definition: __64tof.c:32
union _I64TOS_TEST_DATA::@1594 expected
unsigned int raw
Definition: __64tof.c:36
unsigned long long raw
Definition: __64tof.c:26
unsigned long long given
Definition: __64tof.c:22
double value
Definition: __64tof.c:25
union _U64TOD_TEST_DATA::@1593 expected
unsigned long long given
Definition: __64tof.c:42
unsigned int raw
Definition: __64tof.c:46
union _U64TOS_TEST_DATA::@1595 expected
#define LL
Definition: tui.h:167