1 #include <fenv.h> 2 #include <gtest/gtest.h> 3 4 using namespace testing::ext; 5 6 class FenvFegetroundTest : public testing::Test { SetUp()7 void SetUp() override {} TearDown()8 void TearDown() override {} 9 }; 10 11 /** 12 * @tc.name: fegetround_001 13 * @tc.desc: Set the floating-point rounding mode to "nearest mode" using fesetround, retrieves the current rounding 14 * mode using fegetround, and verifies whether it is correct. Then, it performs some floating-point 15 * calculations and verifies whether the results are as expected. 16 * @tc.type: FUNC 17 */ 18 HWTEST_F(FenvFegetroundTest, fegetround_001, TestSize.Level1) 19 { 20 fesetround(FE_TONEAREST); 21 EXPECT_TRUE(FE_TONEAREST == fegetround()); 22 float x = 1.968750f + 0x1.0p23f; 23 EXPECT_FLOAT_EQ(8388610.0f, x); 24 x -= 0x1.0p23f; 25 EXPECT_FLOAT_EQ(2.0f, x); 26 }