Make test more lenient for custom clang version strings
[llvm-project.git] / libc / test / src / fenv / feclearexcept_test.cpp
blob52adda46adf2f09545875bad5017f77e62cc837c
1 //===-- Unittests for feclearexcept with exceptions enabled ---------------===//
2 //
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
6 //
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"
16 #include <stdint.h>
18 #include "excepts.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);
26 for (int e : EXCEPTS)
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);
38 ASSERT_EQ(
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);