1 //===-- Unittests for feupdateenv -----------------------------------------===//
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 //===----------------------------------------------------------------------===//
8 
9 #include "src/fenv/feupdateenv.h"
10 
11 #include "src/__support/FPUtil/FEnvImpl.h"
12 #include "utils/UnitTest/Test.h"
13 
14 #include <fenv.h>
15 #include <signal.h>
16 
17 TEST(LlvmLibcFEnvTest, UpdateEnvTest) {
18   __llvm_libc::fputil::disable_except(FE_ALL_EXCEPT);
19   __llvm_libc::fputil::clear_except(FE_ALL_EXCEPT);
20 
21   fenv_t env;
22   ASSERT_EQ(__llvm_libc::fputil::get_env(&env), 0);
23   __llvm_libc::fputil::set_except(FE_INVALID | FE_INEXACT);
24   ASSERT_EQ(__llvm_libc::feupdateenv(&env), 0);
25   ASSERT_EQ(__llvm_libc::fputil::test_except(FE_INVALID | FE_INEXACT),
26             FE_INVALID | FE_INEXACT);
27 }
28