1/* Test narrowing add.
2   Copyright (C) 2018-2022 Free Software Foundation, Inc.
3   This file is part of the GNU C Library.
4
5   The GNU C Library is free software; you can redistribute it and/or
6   modify it under the terms of the GNU Lesser General Public
7   License as published by the Free Software Foundation; either
8   version 2.1 of the License, or (at your option) any later version.
9
10   The GNU C Library is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   Lesser General Public License for more details.
14
15   You should have received a copy of the GNU Lesser General Public
16   License along with the GNU C Library; if not, see
17   <https://www.gnu.org/licenses/>.  */
18
19#include "libm-test-driver.c"
20
21static const struct test_aa_f_data add_test_data[] =
22  {
23    TEST_aa_f (add, arg_qnan_value, arg_qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
24    TEST_aa_f (add, arg_qnan_value, -arg_qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
25    TEST_aa_f (add, -arg_qnan_value, arg_qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
26    TEST_aa_f (add, -arg_qnan_value, -arg_qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
27    TEST_aa_f (add, arg_qnan_value, arg_snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
28    TEST_aa_f (add, arg_qnan_value, -arg_snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
29    TEST_aa_f (add, -arg_qnan_value, arg_snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
30    TEST_aa_f (add, -arg_qnan_value, -arg_snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
31    TEST_aa_f (add, arg_snan_value, arg_qnan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
32    TEST_aa_f (add, arg_snan_value, -arg_qnan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
33    TEST_aa_f (add, -arg_snan_value, arg_qnan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
34    TEST_aa_f (add, -arg_snan_value, -arg_qnan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
35    TEST_aa_f (add, arg_snan_value, arg_snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
36    TEST_aa_f (add, arg_snan_value, -arg_snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
37    TEST_aa_f (add, -arg_snan_value, arg_snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
38    TEST_aa_f (add, -arg_snan_value, -arg_snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
39
40    TEST_aa_f (add, arg_qnan_value, arg_plus_zero, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
41    TEST_aa_f (add, arg_qnan_value, arg_minus_zero, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
42    TEST_aa_f (add, arg_qnan_value, arg_plus_infty, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
43    TEST_aa_f (add, arg_qnan_value, arg_minus_infty, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
44    TEST_aa_f (add, arg_qnan_value, arg_min_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
45    TEST_aa_f (add, arg_qnan_value, -arg_min_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
46    TEST_aa_f (add, arg_qnan_value, arg_min_subnorm_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
47    TEST_aa_f (add, arg_qnan_value, -arg_min_subnorm_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
48    TEST_aa_f (add, arg_qnan_value, arg_max_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
49    TEST_aa_f (add, arg_qnan_value, -arg_max_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
50    TEST_aa_f (add, arg_plus_zero, arg_qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
51    TEST_aa_f (add, arg_minus_zero, arg_qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
52    TEST_aa_f (add, arg_plus_infty, arg_qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
53    TEST_aa_f (add, arg_minus_infty, arg_qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
54    TEST_aa_f (add, arg_min_value, arg_qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
55    TEST_aa_f (add, -arg_min_value, arg_qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
56    TEST_aa_f (add, arg_min_subnorm_value, arg_qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
57    TEST_aa_f (add, -arg_min_subnorm_value, arg_qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
58    TEST_aa_f (add, arg_max_value, arg_qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
59    TEST_aa_f (add, -arg_max_value, arg_qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
60    TEST_aa_f (add, -arg_qnan_value, arg_plus_zero, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
61    TEST_aa_f (add, -arg_qnan_value, arg_minus_zero, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
62    TEST_aa_f (add, -arg_qnan_value, arg_plus_infty, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
63    TEST_aa_f (add, -arg_qnan_value, arg_minus_infty, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
64    TEST_aa_f (add, -arg_qnan_value, arg_min_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
65    TEST_aa_f (add, -arg_qnan_value, -arg_min_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
66    TEST_aa_f (add, -arg_qnan_value, arg_min_subnorm_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
67    TEST_aa_f (add, -arg_qnan_value, -arg_min_subnorm_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
68    TEST_aa_f (add, -arg_qnan_value, arg_max_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
69    TEST_aa_f (add, -arg_qnan_value, -arg_max_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
70    TEST_aa_f (add, arg_plus_zero, -arg_qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
71    TEST_aa_f (add, arg_minus_zero, -arg_qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
72    TEST_aa_f (add, arg_plus_infty, -arg_qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
73    TEST_aa_f (add, arg_minus_infty, -arg_qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
74    TEST_aa_f (add, arg_min_value, -arg_qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
75    TEST_aa_f (add, -arg_min_value, -arg_qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
76    TEST_aa_f (add, arg_min_subnorm_value, -arg_qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
77    TEST_aa_f (add, -arg_min_subnorm_value, -arg_qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
78    TEST_aa_f (add, arg_max_value, -arg_qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
79    TEST_aa_f (add, -arg_max_value, -arg_qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
80
81    TEST_aa_f (add, arg_snan_value, arg_plus_zero, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
82    TEST_aa_f (add, arg_snan_value, arg_minus_zero, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
83    TEST_aa_f (add, arg_snan_value, arg_plus_infty, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
84    TEST_aa_f (add, arg_snan_value, arg_minus_infty, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
85    TEST_aa_f (add, arg_snan_value, arg_min_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
86    TEST_aa_f (add, arg_snan_value, -arg_min_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
87    TEST_aa_f (add, arg_snan_value, arg_min_subnorm_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
88    TEST_aa_f (add, arg_snan_value, -arg_min_subnorm_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
89    TEST_aa_f (add, arg_snan_value, arg_max_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
90    TEST_aa_f (add, arg_snan_value, -arg_max_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
91    TEST_aa_f (add, arg_plus_zero, arg_snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
92    TEST_aa_f (add, arg_minus_zero, arg_snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
93    TEST_aa_f (add, arg_plus_infty, arg_snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
94    TEST_aa_f (add, arg_minus_infty, arg_snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
95    TEST_aa_f (add, arg_min_value, arg_snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
96    TEST_aa_f (add, -arg_min_value, arg_snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
97    TEST_aa_f (add, arg_min_subnorm_value, arg_snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
98    TEST_aa_f (add, -arg_min_subnorm_value, arg_snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
99    TEST_aa_f (add, arg_max_value, arg_snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
100    TEST_aa_f (add, -arg_max_value, arg_snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
101    TEST_aa_f (add, -arg_snan_value, arg_plus_zero, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
102    TEST_aa_f (add, -arg_snan_value, arg_minus_zero, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
103    TEST_aa_f (add, -arg_snan_value, arg_plus_infty, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
104    TEST_aa_f (add, -arg_snan_value, arg_minus_infty, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
105    TEST_aa_f (add, -arg_snan_value, arg_min_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
106    TEST_aa_f (add, -arg_snan_value, -arg_min_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
107    TEST_aa_f (add, -arg_snan_value, arg_min_subnorm_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
108    TEST_aa_f (add, -arg_snan_value, -arg_min_subnorm_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
109    TEST_aa_f (add, -arg_snan_value, arg_max_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
110    TEST_aa_f (add, -arg_snan_value, -arg_max_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
111    TEST_aa_f (add, arg_plus_zero, -arg_snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
112    TEST_aa_f (add, arg_minus_zero, -arg_snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
113    TEST_aa_f (add, arg_plus_infty, -arg_snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
114    TEST_aa_f (add, arg_minus_infty, -arg_snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
115    TEST_aa_f (add, arg_min_value, -arg_snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
116    TEST_aa_f (add, -arg_min_value, -arg_snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
117    TEST_aa_f (add, arg_min_subnorm_value, -arg_snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
118    TEST_aa_f (add, -arg_min_subnorm_value, -arg_snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
119    TEST_aa_f (add, arg_max_value, -arg_snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
120    TEST_aa_f (add, -arg_max_value, -arg_snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
121
122    TEST_aa_f (add, arg_plus_infty, arg_plus_infty, plus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
123    TEST_aa_f (add, arg_plus_infty, arg_minus_infty, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION|ERRNO_EDOM),
124    TEST_aa_f (add, arg_minus_infty, arg_plus_infty, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION|ERRNO_EDOM),
125    TEST_aa_f (add, arg_minus_infty, arg_minus_infty, minus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
126
127    TEST_aa_f (add, arg_plus_infty, arg_plus_zero, plus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
128    TEST_aa_f (add, arg_plus_infty, arg_minus_zero, plus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
129    TEST_aa_f (add, arg_plus_infty, arg_min_value, plus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
130    TEST_aa_f (add, arg_plus_infty, -arg_min_value, plus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
131    TEST_aa_f (add, arg_plus_infty, arg_min_subnorm_value, plus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
132    TEST_aa_f (add, arg_plus_infty, -arg_min_subnorm_value, plus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
133    TEST_aa_f (add, arg_plus_infty, arg_max_value, plus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED|XFAIL_ROUNDING_IBM128_LIBGCC),
134    TEST_aa_f (add, arg_plus_infty, -arg_max_value, plus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED|XFAIL_ROUNDING_IBM128_LIBGCC),
135    TEST_aa_f (add, arg_plus_zero, arg_plus_infty, plus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
136    TEST_aa_f (add, arg_minus_zero, arg_plus_infty, plus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
137    TEST_aa_f (add, arg_min_value, arg_plus_infty, plus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
138    TEST_aa_f (add, -arg_min_value, arg_plus_infty, plus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
139    TEST_aa_f (add, arg_min_subnorm_value, arg_plus_infty, plus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
140    TEST_aa_f (add, -arg_min_subnorm_value, arg_plus_infty, plus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
141    TEST_aa_f (add, arg_max_value, arg_plus_infty, plus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
142    TEST_aa_f (add, -arg_max_value, arg_plus_infty, plus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
143    TEST_aa_f (add, arg_minus_infty, arg_plus_zero, minus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
144    TEST_aa_f (add, arg_minus_infty, arg_minus_zero, minus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
145    TEST_aa_f (add, arg_minus_infty, arg_min_value, minus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
146    TEST_aa_f (add, arg_minus_infty, -arg_min_value, minus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
147    TEST_aa_f (add, arg_minus_infty, arg_min_subnorm_value, minus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
148    TEST_aa_f (add, arg_minus_infty, -arg_min_subnorm_value, minus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
149    TEST_aa_f (add, arg_minus_infty, arg_max_value, minus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED|XFAIL_ROUNDING_IBM128_LIBGCC),
150    TEST_aa_f (add, arg_minus_infty, -arg_max_value, minus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED|XFAIL_ROUNDING_IBM128_LIBGCC),
151    TEST_aa_f (add, arg_plus_zero, arg_minus_infty, minus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
152    TEST_aa_f (add, arg_minus_zero, arg_minus_infty, minus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
153    TEST_aa_f (add, arg_min_value, arg_minus_infty, minus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
154    TEST_aa_f (add, -arg_min_value, arg_minus_infty, minus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
155    TEST_aa_f (add, arg_min_subnorm_value, arg_minus_infty, minus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
156    TEST_aa_f (add, -arg_min_subnorm_value, arg_minus_infty, minus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
157    TEST_aa_f (add, arg_max_value, arg_minus_infty, minus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
158    TEST_aa_f (add, -arg_max_value, arg_minus_infty, minus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
159
160    AUTO_TESTS_aa_f (add),
161  };
162
163static void
164add_test (void)
165{
166  ALL_RM_TEST (add, 1, add_test_data, RUN_TEST_LOOP_aa_f, END);
167}
168
169static void
170do_test (void)
171{
172  add_test ();
173}
174
175/*
176 * Local Variables:
177 * mode:c
178 * End:
179 */
180