tangled
alpha
login
or
join now
huwcampbell.com
/
reactos
0
fork
atom
Reactos
0
fork
atom
overview
issues
pulls
pipelines
[CRT_APITEST] Add tests for ceil/floor
Timo Kreuzer
3 years ago
2943ea2c
e8b830d6
+233
-7
6 changed files
expand all
collapse all
unified
split
modules
rostests
apitests
crt
ceil.c
fabs.c
floor.c
msvcrt_crt_apitest.cmake
static_crt_apitest.cmake
testlist.c
+109
modules/rostests/apitests/crt/ceil.c
reviewed
···
1
1
+
/*
2
2
+
* PROJECT: ReactOS API tests
3
3
+
* LICENSE: MIT (https://spdx.org/licenses/MIT)
4
4
+
* PURPOSE: Tests for ceil / ceilf
5
5
+
* COPYRIGHT: Copyright 2021 Timo Kreuzer <timo.kreuzer@reactos.org>
6
6
+
*/
7
7
+
8
8
+
#if !defined(_CRTBLD) && !defined(_M_IX86)
9
9
+
#define _CRTBLD // we don't want inline ceilf!
10
10
+
#endif
11
11
+
#include "math_helpers.h"
12
12
+
13
13
+
#ifdef _MSC_VER
14
14
+
#pragma function(ceil)
15
15
+
// ceilf is not available as an intrinsic
16
16
+
#endif
17
17
+
18
18
+
static TESTENTRY_DBL s_ceil_tests[] =
19
19
+
{
20
20
+
/* Special values */
21
21
+
{ 0x0000000000000000 /* 0.000000000000000e+000 */, 0x0000000000000000 /* 0.000000000000000e+000 */ },
22
22
+
{ 0x8000000000000000 /* -0.000000000000000e+000 */, 0x8000000000000000 /* 0.000000000000000e+000 */ },
23
23
+
{ 0x7ff0000000000000 /* 1.#INF00000000000e+000 */, 0x7ff0000000000000 /* 1.#INF00000000000e+000 */ },
24
24
+
{ 0x7ff0000000000001 /* 1.#QNAN0000000000e+000 */, 0x7ff8000000000001 /* 1.#QNAN0000000000e+000 */ },
25
25
+
{ 0x7ff7ffffffffffff /* 1.#QNAN0000000000e+000 */, 0x7fffffffffffffff /* 1.#QNAN0000000000e+000 */ },
26
26
+
{ 0x7ff8000000000000 /* 1.#QNAN0000000000e+000 */, 0x7ff8000000000000 /* 1.#QNAN0000000000e+000 */ },
27
27
+
{ 0x7ff8000000000001 /* 1.#QNAN0000000000e+000 */, 0x7ff8000000000001 /* 1.#QNAN0000000000e+000 */ },
28
28
+
{ 0x7fffffffffffffff /* 1.#QNAN0000000000e+000 */, 0x7fffffffffffffff /* 1.#QNAN0000000000e+000 */ },
29
29
+
{ 0xfff0000000000000 /* -1.#INF00000000000e+000 */, 0xfff0000000000000 /* -1.#INF00000000000e+000 */ },
30
30
+
{ 0xfff0000000000001 /* -1.#QNAN0000000000e+000 */, 0xfff8000000000001 /* -1.#QNAN0000000000e+000 */ },
31
31
+
{ 0xfff7ffffffffffff /* -1.#QNAN0000000000e+000 */, 0xffffffffffffffff /* -1.#QNAN0000000000e+000 */ },
32
32
+
{ 0xfff8000000000000 /* -1.#IND00000000000e+000 */, 0xfff8000000000000 /* -1.#IND00000000000e+000 */ },
33
33
+
{ 0xfff8000000000001 /* -1.#QNAN0000000000e+000 */, 0xfff8000000000001 /* -1.#QNAN0000000000e+000 */ },
34
34
+
{ 0xffffffffffffffff /* -1.#QNAN0000000000e+000 */, 0xffffffffffffffff /* -1.#QNAN0000000000e+000 */ },
35
35
+
36
36
+
/* Some random floats */
37
37
+
{ 0x84be2329aed66ce1 /* -7.916792434840887e-286 */, 0x8000000000000000 /* -0.000000000000000e+000 */ },
38
38
+
{ 0xf1499052ebe9bbf1 /* -5.202012813127544e+237 */, 0xf1499052ebe9bbf1 /* -5.202012813127544e+237 */ },
39
39
+
{ 0x3cdba6b3993e0c87 /* 1.534948721304537e-015 */, 0x3ff0000000000000 /* 1.000000000000000e+000 */ },
40
40
+
{ 0x1c0d5e24de47b706 /* 1.484236768428990e-173 */, 0x3ff0000000000000 /* 1.000000000000000e+000 */ },
41
41
+
{ 0xc84d12b3a68bbb43 /* -1.978609508743937e+040 */, 0xc84d12b3a68bbb43 /* -1.978609508743937e+040 */ },
42
42
+
{ 0x7d5a031f1f253809 /* 6.645271626742043e+295 */, 0x7d5a031f1f253809 /* 6.645271626742043e+295 */ },
43
43
+
{ 0xfccbd45d3b45f596 /* -1.388583322422121e+293 */, 0xfccbd45d3b45f596 /* -1.388583322422121e+293 */ },
44
44
+
{ 0x0a890d1332aedb1c /* 6.517185427488806e-258 */, 0x3ff0000000000000 /* 1.000000000000000e+000 */ },
45
45
+
{ 0xee509a20fd367840 /* -2.400484647490954e+223 */, 0xee509a20fd367840 /* -2.400484647490954e+223 */ },
46
46
+
{ 0xf6324912dc497d9e /* -2.249167320514119e+261 */, 0xf6324912dc497d9e /* -2.249167320514119e+261 */ },
47
47
+
};
48
48
+
49
49
+
50
50
+
void Test_ceil(void)
51
51
+
{
52
52
+
int i;
53
53
+
54
54
+
for (i = 0; i < _countof(s_ceil_tests); i++)
55
55
+
{
56
56
+
double x = u64_to_dbl(s_ceil_tests[i].x);
57
57
+
double z = ceil(x);
58
58
+
ok_eq_dbl_exact("ceil", s_ceil_tests[i].x, z, s_ceil_tests[i].result);
59
59
+
}
60
60
+
}
61
61
+
62
62
+
static TESTENTRY_FLT s_ceilf_tests[] =
63
63
+
{
64
64
+
/* Special values */
65
65
+
{ 0x00000000 /* 0.000000e+000 */, 0x00000000 /* 0.000000e+000 */ },
66
66
+
{ 0x80000000 /* -0.000000e+000 */, 0x80000000 /* 0.000000e+000 */ },
67
67
+
{ 0x00000000 /* 0.000000e+000 */, 0x00000000 /* 0.000000e+000 */ },
68
68
+
{ 0x00000001 /* 1.401298e-045 */, 0x3f800000 /* 1.000000e+000 */ },
69
69
+
{ 0xffffffff /* -1.#QNAN0e+000 */, 0xffffffff /* -1.#QNAN0e+000 */ },
70
70
+
{ 0x00000000 /* 0.000000e+000 */, 0x00000000 /* 0.000000e+000 */ },
71
71
+
{ 0x00000001 /* 1.401298e-045 */, 0x3f800000 /* 1.000000e+000 */ },
72
72
+
{ 0xffffffff /* -1.#QNAN0e+000 */, 0xffffffff /* -1.#QNAN0e+000 */ },
73
73
+
{ 0x00000000 /* 0.000000e+000 */, 0x00000000 /* 0.000000e+000 */ },
74
74
+
{ 0x00000001 /* 1.401298e-045 */, 0x3f800000 /* 1.000000e+000 */ },
75
75
+
{ 0xffffffff /* -1.#QNAN0e+000 */, 0xffffffff /* -1.#QNAN0e+000 */ },
76
76
+
{ 0x00000000 /* 0.000000e+000 */, 0x00000000 /* 0.000000e+000 */ },
77
77
+
{ 0x00000001 /* 1.401298e-045 */, 0x3f800000 /* 1.000000e+000 */ },
78
78
+
{ 0xffffffff /* -1.#QNAN0e+000 */, 0xffffffff /* -1.#QNAN0e+000 */ },
79
79
+
80
80
+
/* Some random floats */
81
81
+
{ 0xf2144fad /* -2.937607e+030 */, 0xf2144fad /* -2.937607e+030 */ },
82
82
+
{ 0xd0664044 /* -1.545189e+010 */, 0xd0664044 /* -1.545189e+010 */ },
83
83
+
{ 0xb730c46b /* -1.053615e-005 */, 0x80000000 /* -0.000000e+000 */ },
84
84
+
{ 0x22a13b32 /* 4.370181e-018 */, 0x3f800000 /* 1.000000e+000 */ },
85
85
+
{ 0x9d9122f6 /* -3.841733e-021 */, 0x80000000 /* -0.000000e+000 */ },
86
86
+
{ 0xda1f8be1 /* -1.122708e+016 */, 0xda1f8be1 /* -1.122708e+016 */ },
87
87
+
{ 0x0299cab0 /* 2.259767e-037 */, 0x3f800000 /* 1.000000e+000 */ },
88
88
+
{ 0x499d72b9 /* 1.289815e+006 */, 0x499d72c0 /* 1.289816e+006 */ },
89
89
+
{ 0xc57e802c /* -4.072011e+003 */, 0xc57e8000 /* -4.072000e+003 */ },
90
90
+
{ 0x80e9d599 /* -2.147430e-038 */, 0x80000000 /* -0.000000e+000 */ },
91
91
+
};
92
92
+
93
93
+
void Test_ceilf(void)
94
94
+
{
95
95
+
int i;
96
96
+
97
97
+
for (i = 0; i < _countof(s_ceilf_tests); i++)
98
98
+
{
99
99
+
float x = u32_to_flt(s_ceilf_tests[i].x);
100
100
+
float z = ceilf(x);
101
101
+
ok_eq_flt_exact("ceilf", s_ceilf_tests[i].x, z, s_ceilf_tests[i].result);
102
102
+
}
103
103
+
}
104
104
+
105
105
+
START_TEST(ceil)
106
106
+
{
107
107
+
Test_ceil();
108
108
+
Test_ceilf();
109
109
+
}
+2
-2
modules/rostests/apitests/crt/fabs.c
reviewed
···
5
5
* COPYRIGHT: Copyright 2021 Timo Kreuzer <timo.kreuzer@reactos.org>
6
6
*/
7
7
8
8
-
/* Don't use the inline ceilf, unless required */
9
9
-
#if defined(TEST_STATIC_CRT) || defined(_M_ARM)
8
8
+
/* Don't use the inline fabsf, unless required */
9
9
+
#if !defined(_CRTBLD) && defined(_M_ARM)
10
10
#define _CRTBLD
11
11
#endif
12
12
#include "math_helpers.h"
+111
modules/rostests/apitests/crt/floor.c
reviewed
···
1
1
+
/*
2
2
+
* PROJECT: ReactOS API tests
3
3
+
* LICENSE: MIT (https://spdx.org/licenses/MIT)
4
4
+
* PURPOSE: Tests for floor / floorf
5
5
+
* COPYRIGHT: Copyright 2021 Timo Kreuzer <timo.kreuzer@reactos.org>
6
6
+
*/
7
7
+
8
8
+
#if !defined(_CRTBLD) && !defined(_M_IX86)
9
9
+
#define _CRTBLD // we don't want inline floorf!
10
10
+
#endif
11
11
+
#include "math_helpers.h"
12
12
+
13
13
+
#ifdef _MSC_VER
14
14
+
#pragma function(floor)
15
15
+
#ifdef _M_AMD64
16
16
+
#pragma function(floorf)
17
17
+
#endif
18
18
+
#endif
19
19
+
20
20
+
static TESTENTRY_DBL s_floor_tests[] =
21
21
+
{
22
22
+
/* Special values */
23
23
+
{ 0x0000000000000000 /* 0.000000000000000e+000 */, 0x0000000000000000 /* 0.000000000000000e+000 */ },
24
24
+
{ 0x8000000000000000 /* -0.000000000000000e+000 */, 0x8000000000000000 /* -0.000000000000000e+000 */ },
25
25
+
{ 0x7ff0000000000000 /* 1.#INF00000000000e+000 */, 0x7ff0000000000000 /* 1.#INF00000000000e+000 */ },
26
26
+
{ 0x7ff0000000000001 /* 1.#QNAN0000000000e+000 */, 0x7ff8000000000001 /* 1.#QNAN0000000000e+000 */ },
27
27
+
{ 0x7ff7ffffffffffff /* 1.#QNAN0000000000e+000 */, 0x7fffffffffffffff /* 1.#QNAN0000000000e+000 */ },
28
28
+
{ 0x7ff8000000000000 /* 1.#QNAN0000000000e+000 */, 0x7ff8000000000000 /* 1.#QNAN0000000000e+000 */ },
29
29
+
{ 0x7ff8000000000001 /* 1.#QNAN0000000000e+000 */, 0x7ff8000000000001 /* 1.#QNAN0000000000e+000 */ },
30
30
+
{ 0x7fffffffffffffff /* 1.#QNAN0000000000e+000 */, 0x7fffffffffffffff /* 1.#QNAN0000000000e+000 */ },
31
31
+
{ 0xfff0000000000000 /* -1.#INF00000000000e+000 */, 0xfff0000000000000 /* -1.#INF00000000000e+000 */ },
32
32
+
{ 0xfff0000000000001 /* -1.#QNAN0000000000e+000 */, 0xfff8000000000001 /* -1.#QNAN0000000000e+000 */ },
33
33
+
{ 0xfff7ffffffffffff /* -1.#QNAN0000000000e+000 */, 0xffffffffffffffff /* -1.#QNAN0000000000e+000 */ },
34
34
+
{ 0xfff8000000000000 /* -1.#IND00000000000e+000 */, 0xfff8000000000000 /* -1.#IND00000000000e+000 */ },
35
35
+
{ 0xfff8000000000001 /* -1.#QNAN0000000000e+000 */, 0xfff8000000000001 /* -1.#QNAN0000000000e+000 */ },
36
36
+
{ 0xffffffffffffffff /* -1.#QNAN0000000000e+000 */, 0xffffffffffffffff /* -1.#QNAN0000000000e+000 */ },
37
37
+
38
38
+
/* Some random doubles */
39
39
+
{ 0x386580c747a3402b /* 5.055340589883462e-037 */, 0x0000000000000000 /* 0.000000000000000e+000 */ },
40
40
+
{ 0xb74298e6627fb9ed /* -1.667860443847725e-042 */, 0xbff0000000000000 /* -1.000000000000000e+000 */ },
41
41
+
{ 0x0ef25f06e414aa2d /* 1.128498317470960e-236 */, 0x0000000000000000 /* 0.000000000000000e+000 */ },
42
42
+
{ 0x24002a37167638b5 /* 2.780001692929186e-135 */, 0x0000000000000000 /* 0.000000000000000e+000 */ },
43
43
+
{ 0x44258d1be62a0d22 /* 1.987747995999515e+020 */, 0x44258d1be62a0d22 /* 1.987747995999515e+020 */ },
44
44
+
{ 0x9ed4e46a65aad464 /* -3.715074250469020e-160 */, 0xbff0000000000000 /* -1.000000000000000e+000 */ },
45
45
+
{ 0xc5afcd6f4ae4bf41 /* -4.921195330852160e+027 */, 0xc5afcd6f4ae4bf41 /* -4.921195330852160e+027 */ },
46
46
+
{ 0x330fac896cbb01d2 /* 9.624395081137827e-063 */, 0x0000000000000000 /* 0.000000000000000e+000 */ },
47
47
+
{ 0xc18026ab4c845405 /* -3.387120956461338e+007 */, 0xc18026ab50000000 /* -3.387121000000000e+007 */ },
48
48
+
{ 0x2f42a7dc898a741a /* 4.916804395045249e-081 */, 0x0000000000000000 /* 0.000000000000000e+000 */ },
49
49
+
};
50
50
+
51
51
+
52
52
+
void Test_floor(void)
53
53
+
{
54
54
+
int i;
55
55
+
56
56
+
for (i = 0; i < _countof(s_floor_tests); i++)
57
57
+
{
58
58
+
double x = u64_to_dbl(s_floor_tests[i].x);
59
59
+
double z = floor(x);
60
60
+
ok_eq_dbl_exact("floor", s_floor_tests[i].x, z, s_floor_tests[i].result);
61
61
+
}
62
62
+
}
63
63
+
64
64
+
static TESTENTRY_FLT s_floorf_tests[] =
65
65
+
{
66
66
+
/* Special values */
67
67
+
{ 0x00000000 /* 0.000000e+000 */, 0x00000000 /* 0.000000e+000 */ },
68
68
+
{ 0x00000000 /* 0.000000e+000 */, 0x00000000 /* 0.000000e+000 */ },
69
69
+
{ 0x00000000 /* 0.000000e+000 */, 0x00000000 /* 0.000000e+000 */ },
70
70
+
{ 0x00000001 /* 1.401298e-045 */, 0x00000000 /* 0.000000e+000 */ },
71
71
+
{ 0xffffffff /* -1.#QNAN0e+000 */, 0xffffffff /* -1.#QNAN0e+000 */ },
72
72
+
{ 0x00000000 /* 0.000000e+000 */, 0x00000000 /* 0.000000e+000 */ },
73
73
+
{ 0x00000001 /* 1.401298e-045 */, 0x00000000 /* 0.000000e+000 */ },
74
74
+
{ 0xffffffff /* -1.#QNAN0e+000 */, 0xffffffff /* -1.#QNAN0e+000 */ },
75
75
+
{ 0x00000000 /* 0.000000e+000 */, 0x00000000 /* 0.000000e+000 */ },
76
76
+
{ 0x00000001 /* 1.401298e-045 */, 0x00000000 /* 0.000000e+000 */ },
77
77
+
{ 0xffffffff /* -1.#QNAN0e+000 */, 0xffffffff /* -1.#QNAN0e+000 */ },
78
78
+
{ 0x00000000 /* 0.000000e+000 */, 0x00000000 /* 0.000000e+000 */ },
79
79
+
{ 0x00000001 /* 1.401298e-045 */, 0x00000000 /* 0.000000e+000 */ },
80
80
+
{ 0xffffffff /* -1.#QNAN0e+000 */, 0xffffffff /* -1.#QNAN0e+000 */ },
81
81
+
82
82
+
/* Some random floats */
83
83
+
{ 0x386580c7 /* 5.471779e-005 */, 0x00000000 /* 0.000000e+000 */ },
84
84
+
{ 0x47a3402b /* 8.358434e+004 */, 0x47a34000 /* 8.358400e+004 */ },
85
85
+
{ 0xb74298e6 /* -1.159890e-005 */, 0xbf800000 /* -1.000000e+000 */ },
86
86
+
{ 0x627fb9ed /* 1.179329e+021 */, 0x627fb9ed /* 1.179329e+021 */ },
87
87
+
{ 0x0ef25f06 /* 5.974911e-030 */, 0x00000000 /* 0.000000e+000 */ },
88
88
+
{ 0xe414aa2d /* -1.096952e+022 */, 0xe414aa2d /* -1.096952e+022 */ },
89
89
+
{ 0x24002a37 /* 2.779133e-017 */, 0x00000000 /* 0.000000e+000 */ },
90
90
+
{ 0x167638b5 /* 1.988962e-025 */, 0x00000000 /* 0.000000e+000 */ },
91
91
+
{ 0x44258d1b /* 6.622048e+002 */, 0x44258000 /* 6.620000e+002 */ },
92
92
+
{ 0xe62a0d22 /* -2.007611e+023 */, 0xe62a0d22 /* -2.007611e+023 */ },
93
93
+
};
94
94
+
95
95
+
void Test_floorf(void)
96
96
+
{
97
97
+
int i;
98
98
+
99
99
+
for (i = 0; i < _countof(s_floorf_tests); i++)
100
100
+
{
101
101
+
float x = u32_to_flt(s_floorf_tests[i].x);
102
102
+
float z = floorf(x);
103
103
+
ok_eq_flt_exact("floorf", s_floorf_tests[i].x, z, s_floorf_tests[i].result);
104
104
+
}
105
105
+
}
106
106
+
107
107
+
START_TEST(floor)
108
108
+
{
109
109
+
Test_floor();
110
110
+
Test_floorf();
111
111
+
}
+2
-2
modules/rostests/apitests/crt/msvcrt_crt_apitest.cmake
reviewed
···
1017
1017
# bsearch_s
1018
1018
# btowc.c
1019
1019
# calloc.c
1020
1020
-
# ceil.c
1020
1020
+
ceil.c
1021
1021
# clearerr.c
1022
1022
# clearerr_s
1023
1023
# clock.c
···
1038
1038
# fgets.c
1039
1039
# fgetwc.c
1040
1040
# fgetws.c
1041
1041
-
# floor.c
1041
1041
+
floor.c
1042
1042
# fmod.c
1043
1043
# fopen.c
1044
1044
# fopen_s.c
+3
-1
modules/rostests/apitests/crt/static_crt_apitest.cmake
reviewed
···
7
7
_vsnprintf.c
8
8
_vsnwprintf.c
9
9
atexit.c
10
10
+
ceil.c
10
11
fabs.c
12
12
+
floor.c
11
13
fpcontrol.c
12
14
mbstowcs.c
13
15
mbtowc.c
···
37
39
endif()
38
40
39
41
add_executable(static_crt_apitest EXCLUDE_FROM_ALL testlist.c ${SOURCE_STATIC})
40
40
-
target_compile_definitions(static_crt_apitest PRIVATE TEST_STATIC_CRT wine_dbgstr_an=wine_dbgstr_an_ wine_dbgstr_wn=wine_dbgstr_wn_)
42
42
+
target_compile_definitions(static_crt_apitest PRIVATE TEST_STATIC_CRT _CRTBLD wine_dbgstr_an=wine_dbgstr_an_ wine_dbgstr_wn=wine_dbgstr_wn_)
41
43
target_link_libraries(static_crt_apitest crt wine ${PSEH_LIB})
42
44
set_module_type(static_crt_apitest win32cui)
43
45
add_importlibs(static_crt_apitest kernel32 ntdll)
+6
-2
modules/rostests/apitests/crt/testlist.c
reviewed
···
18
18
#if defined(TEST_NTDLL)
19
19
extern void func__vscwprintf(void);
20
20
#endif
21
21
-
extern void func_fpcontrol(void);
21
21
+
extern void func_ceil(void);
22
22
extern void func_fabs(void);
23
23
+
extern void func_floor(void);
24
24
+
extern void func_fpcontrol(void);
23
25
extern void func_fputc(void);
24
26
extern void func_fputwc(void);
25
27
extern void func__snprintf(void);
···
62
64
// ...
63
65
#endif
64
66
#if defined(TEST_STATIC_CRT) || defined(TEST_MSVCRT)
67
67
+
{ "ceil", func_ceil },
68
68
+
{ "fabs", func_fabs },
69
69
+
{ "floor", func_floor },
65
70
#ifdef _M_AMD64 // x86 / arm need fixing
66
71
{ "fpcontrol", func_fpcontrol },
67
72
#endif
68
68
-
{ "fabs", func_fabs },
69
73
#if defined(_M_ARM)
70
74
{ "__rt_div", func___rt_div },
71
75
{ "__fto64", func___fto64 },