@@ -144,21 +144,20 @@ fpequal_tol(long double x, long double y, long double tol,
144144 return (ret );
145145}
146146
147- #define CHECK_FPEQUAL (x , y ) CHECK_FPEQUAL_CS(x, y, true)
148-
149- #define CHECK_FPEQUAL_CS (x , y , checksign ) do { \
147+ #define _fpequal_cs (atf_variant , x , y , checksign ) do { \
150148 long double _x = x; \
151149 long double _y = y; \
152- ATF_CHECK_MSG (fpequal_cs(_x, _y, checksign), \
150+ ATF_##atf_variant##_MSG (fpequal_cs(_x, _y, checksign), \
153151 "%s (%.25Lg) ~= %s (%.25Lg)", #x, _x, #y, _y); \
154152} while (0)
155153
156- #define CHECK_FPEQUAL_TOL ( x , y , tol , flags ) do { \
154+ #define _fpequal_tol ( atf_variant , x , y , tol , flags ) do { \
157155 long double _x = x; \
158156 long double _y = y; \
159157 bool eq = fpequal_tol(_x, _y, tol, flags); \
160158 long double _diff = eq ? 0.0L : fabsl(_x - _y); \
161- ATF_CHECK_MSG(eq, "%s (%.25Lg) ~= %s (%.25Lg), diff=%Lg, maxdiff=%Lg,", \
159+ ATF_##atf_variant##_MSG(eq, \
160+ "%s (%.25Lg) ~= %s (%.25Lg), diff=%Lg, maxdiff=%Lg,", \
162161 #x, _x, #y, _y, _diff, fabsl(_y * tol)); \
163162} while (0)
164163
@@ -170,32 +169,48 @@ cfpequal(long double complex d1, long double complex d2)
170169 fpequal_cs (cimagl (d1 ), cimagl (d2 ), true));
171170}
172171
173- #define CHECK_CFPEQUAL_CS ( x , y , checksign ) do { \
172+ #define _cfpequal_cs ( atf_variant , x , y , checksign ) do { \
174173 long double _x = x; \
175174 long double _y = y; \
176175 bool equal_cs = \
177176 fpequal_cs(creal(_x), creal(_y), (checksign & CS_REAL) != 0) && \
178177 fpequal_cs(cimag(_x), cimag(_y), (checksign & CS_IMAG) != 0); \
179- ATF_CHECK_MSG(equal_cs, "%s (%Lg + %Lg I) ~= %s (%Lg + %Lg I)", \
178+ ATF_##atf_variant##_MSG(equal_cs, \
179+ "%s (%Lg + %Lg I) ~= %s (%Lg + %Lg I)", \
180180 #x, creall(_x), cimagl(_x), #y, creall(_y), cimagl(_y)); \
181181} while (0)
182182
183- #define CHECK_CFPEQUAL_TOL ( x , y , tol , flags ) do { \
183+ #define _cfpequal_tol ( atf_variant , x , y , tol , flags ) do { \
184184 long double _x = x; \
185185 long double _y = y; \
186186 bool equal_tol = (fpequal_tol(creal(_x), creal(_y), tol, flags) && \
187187 fpequal_tol(cimag(_x), cimag(_y), tol, flags)); \
188- ATF_CHECK_MSG(equal_tol, "%s (%Lg + %Lg I) ~= %s (%Lg + %Lg I)", \
188+ ATF_##atf_variant##_MSG(equal_tol, \
189+ "%s (%Lg + %Lg I) ~= %s (%Lg + %Lg I)", \
189190 #x, creall(_x), cimagl(_x), #y, creall(_y), cimagl(_y)); \
190191} while (0)
191192
192- #define CHECK_FP_EXCEPTIONS ( excepts , exceptmask ) \
193- ATF_CHECK_EQ_MSG ((excepts), fetestexcept(exceptmask), \
194- "unexpected exception flags: got %#x not %#x", \
193+ #define _fp_exceptions ( atf_variant , excepts , exceptmask ) \
194+ ATF_##atf_variant##_EQ_MSG ((excepts), fetestexcept(exceptmask), \
195+ "unexpected exception flags: got %#x not %#x", \
195196 fetestexcept(exceptmask), (excepts))
196- #define CHECK_FP_EXCEPTIONS_MSG ( excepts , exceptmask , fmt , ...) \
197- ATF_CHECK_EQ_MSG ((excepts), fetestexcept(exceptmask), \
197+ #define _fp_exceptions_msg ( atf_variant , excepts , exceptmask , fmt , ...) \
198+ ATF_##atf_variant##_EQ_MSG ((excepts), fetestexcept(exceptmask), \
198199 "unexpected exception flags: got %#x not %#x " fmt, \
199200 fetestexcept(exceptmask), (excepts), __VA_ARGS__)
200201
202+ #define CHECK_FP_EXCEPTIONS (excepts , exceptmask ) _fp_exceptions(CHECK, excepts, exceptmask)
203+ #define CHECK_FP_EXCEPTIONS_MSG (excepts , exceptmask , fmt , ...) _fp_exceptions_msg(CHECK, excepts, exceptmask, fmt, __VA_ARGS__)
204+ #define CHECK_CFPEQUAL_TOL (x , y , tol , flags ) _cfpequal_tol(CHECK, x, y, tol, flags)
205+ #define CHECK_CFPEQUAL_CS (x , y , checksign ) _cfpequal_cs(CHECK, x, y, checksign)
206+ #define CHECK_FPEQUAL (x , y ) _fpequal_cs(CHECK, x, y, true)
207+ #define CHECK_FPEQUAL_TOL (x , y , tol , flags ) _fpequal_tol(CHECK, x, y, tol, flags)
208+
209+ #define REQUIRE_FP_EXCEPTIONS (excepts , exceptmask ) _fp_exceptions(REQUIRE, excepts, exceptmask)
210+ #define REQUIRE_FP_EXCEPTIONS_MSG (excepts , exceptmask , fmt , ...) _fp_exceptions_msg(REQUIRE, excepts, exceptmask, fmt, __VA_ARGS__)
211+ #define REQUIRE_CFPEQUAL_TOL (x , y , tol , flags ) _cfpequal_tol(REQUIRE, x, y, tol, flags)
212+ #define REQUIRE_CFPEQUAL_CS (x , y , checksign ) _cfpequal_cs(REQUIRE, x, y, checksign)
213+ #define REQUIRE_FPEQUAL (x , y ) _fpequal_cs(REQUIRE, x, y, true)
214+ #define REQUIRE_FPEQUAL_TOL (x , y , tol , flags ) _fpequal_tol(REQUIRE, x, y, tol, flags)
215+
201216#endif /* _TEST_UTILS_H_ */
0 commit comments