19474ddc3SSiva Chandra Reddy //===-- Unittests for feclearexcept with exceptions enabled ---------------===// 29474ddc3SSiva Chandra Reddy // 39474ddc3SSiva Chandra Reddy // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 49474ddc3SSiva Chandra Reddy // See https://llvm.org/LICENSE.txt for license information. 59474ddc3SSiva Chandra Reddy // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 69474ddc3SSiva Chandra Reddy // 79474ddc3SSiva Chandra Reddy //===----------------------------------------------------------------------===// 89474ddc3SSiva Chandra Reddy 99474ddc3SSiva Chandra Reddy #include "src/fenv/feclearexcept.h" 109474ddc3SSiva Chandra Reddy 1176ec69a9STue Ly #include "src/__support/FPUtil/FEnvImpl.h" 12*837dab96SRoland McGrath #include "test/UnitTest/FEnvSafeTest.h" 13af1315c2SSiva Chandra Reddy #include "test/UnitTest/Test.h" 149474ddc3SSiva Chandra Reddy 1549561181SJob Henandez Lara #include "hdr/fenv_macros.h" 169474ddc3SSiva Chandra Reddy #include <stdint.h> 179474ddc3SSiva Chandra Reddy 18*837dab96SRoland McGrath #include "excepts.h" 19*837dab96SRoland McGrath 20*837dab96SRoland McGrath using LlvmLibcFEnvTest = LIBC_NAMESPACE::testing::FEnvSafeTest; 21*837dab96SRoland McGrath TEST_F(LlvmLibcFEnvTest,ClearTest)22*837dab96SRoland McGrathTEST_F(LlvmLibcFEnvTest, ClearTest) { 23b6bc9d72SGuillaume Chatelet LIBC_NAMESPACE::fputil::disable_except(FE_ALL_EXCEPT); 24b6bc9d72SGuillaume Chatelet LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT); 259474ddc3SSiva Chandra Reddy 26*837dab96SRoland McGrath for (int e : EXCEPTS) 27b6bc9d72SGuillaume Chatelet ASSERT_EQ(LIBC_NAMESPACE::fputil::test_except(e), 0); 289474ddc3SSiva Chandra Reddy 29b6bc9d72SGuillaume Chatelet LIBC_NAMESPACE::fputil::raise_except(FE_ALL_EXCEPT); 309474ddc3SSiva Chandra Reddy 31*837dab96SRoland McGrath for (int e1 : EXCEPTS) { 32*837dab96SRoland McGrath for (int e2 : EXCEPTS) { 33*837dab96SRoland McGrath for (int e3 : EXCEPTS) { 34*837dab96SRoland McGrath for (int e4 : EXCEPTS) { 35*837dab96SRoland McGrath for (int e5 : EXCEPTS) { 36db46c777STue Ly // We clear one exception and test to verify that it was cleared. 37b6bc9d72SGuillaume Chatelet LIBC_NAMESPACE::feclearexcept(e1 | e2 | e3 | e4 | e5); 38b6bc9d72SGuillaume Chatelet ASSERT_EQ( 39b6bc9d72SGuillaume Chatelet LIBC_NAMESPACE::fputil::test_except(e1 | e2 | e3 | e4 | e5), 0); 40db46c777STue Ly // After clearing, we raise the exception again. 41b6bc9d72SGuillaume Chatelet LIBC_NAMESPACE::fputil::raise_except(e1 | e2 | e3 | e4 | e5); 429474ddc3SSiva Chandra Reddy } 439474ddc3SSiva Chandra Reddy } 449474ddc3SSiva Chandra Reddy } 459474ddc3SSiva Chandra Reddy } 469474ddc3SSiva Chandra Reddy } 479474ddc3SSiva Chandra Reddy } 48