#include "src/fenv/feclearexcept.h"
#include "src/__support/FPUtil/FEnvImpl.h"
#include "utils/UnitTest/Test.h"
#include <fenv.h>
#include <stdint.h>
TEST(LlvmLibcFEnvTest, ClearTest) {
uint16_t excepts[] = {FE_DIVBYZERO, FE_INVALID, FE_INEXACT, FE_OVERFLOW,
FE_UNDERFLOW};
__llvm_libc::fputil::disable_except(FE_ALL_EXCEPT);
__llvm_libc::fputil::clear_except(FE_ALL_EXCEPT);
for (uint16_t e : excepts)
ASSERT_EQ(__llvm_libc::fputil::test_except(e), 0);
__llvm_libc::fputil::raise_except(FE_ALL_EXCEPT);
for (uint16_t e1 : excepts) {
for (uint16_t e2 : excepts) {
for (uint16_t e3 : excepts) {
for (uint16_t e4 : excepts) {
for (uint16_t e5 : excepts) {
__llvm_libc::feclearexcept(e1 | e2 | e3 | e4 | e5);
ASSERT_EQ(__llvm_libc::fputil::test_except(e1 | e2 | e3 | e4 | e5),
0);
__llvm_libc::fputil::raise_except(e1 | e2 | e3 | e4 | e5);
}
}
}
}
}
}