1 //===-- Unittests for feclearexcept with exceptions enabled ---------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "src/fenv/feclearexcept.h"
11 #include "src/__support/FPUtil/FEnvImpl.h"
12 #include "test/UnitTest/FEnvSafeTest.h"
13 #include "test/UnitTest/Test.h"
15 #include "hdr/fenv_macros.h"
20 using LlvmLibcFEnvTest
= LIBC_NAMESPACE::testing::FEnvSafeTest
;
22 TEST_F(LlvmLibcFEnvTest
, ClearTest
) {
23 LIBC_NAMESPACE::fputil::disable_except(FE_ALL_EXCEPT
);
24 LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT
);
27 ASSERT_EQ(LIBC_NAMESPACE::fputil::test_except(e
), 0);
29 LIBC_NAMESPACE::fputil::raise_except(FE_ALL_EXCEPT
);
31 for (int e1
: EXCEPTS
) {
32 for (int e2
: EXCEPTS
) {
33 for (int e3
: EXCEPTS
) {
34 for (int e4
: EXCEPTS
) {
35 for (int e5
: EXCEPTS
) {
36 // We clear one exception and test to verify that it was cleared.
37 LIBC_NAMESPACE::feclearexcept(e1
| e2
| e3
| e4
| e5
);
39 LIBC_NAMESPACE::fputil::test_except(e1
| e2
| e3
| e4
| e5
), 0);
40 // After clearing, we raise the exception again.
41 LIBC_NAMESPACE::fputil::raise_except(e1
| e2
| e3
| e4
| e5
);