1 //===-- Unittests for fegetround and fesetround ---------------------------===// 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/fegetround.h" 10 #include "src/fenv/fesetround.h" 11 12 #include "utils/UnitTest/Test.h" 13 14 #include <fenv.h> 15 16 TEST(LlvmLibcRoundingModeTest, SetAndGet) { 17 int s = __llvm_libc::fesetround(FE_TONEAREST); 18 EXPECT_EQ(s, 0); 19 int rm = __llvm_libc::fegetround(); 20 EXPECT_EQ(rm, FE_TONEAREST); 21 22 s = __llvm_libc::fesetround(FE_UPWARD); 23 EXPECT_EQ(s, 0); 24 rm = __llvm_libc::fegetround(); 25 EXPECT_EQ(rm, FE_UPWARD); 26 27 s = __llvm_libc::fesetround(FE_DOWNWARD); 28 EXPECT_EQ(s, 0); 29 rm = __llvm_libc::fegetround(); 30 EXPECT_EQ(rm, FE_DOWNWARD); 31 32 s = __llvm_libc::fesetround(FE_TOWARDZERO); 33 EXPECT_EQ(s, 0); 34 rm = __llvm_libc::fegetround(); 35 EXPECT_EQ(rm, FE_TOWARDZERO); 36 } 37