1 #include <gtest/gtest.h> 2 #include <math.h> 3 4 #include "math_data_test.h" 5 #include "math_test_data/nearbyintf_data.h" 6 #include "math_test_data/nearbyint_data.h" 7 8 using namespace testing::ext; 9 10 class MathNearbyintTest : public testing::Test { SetUp()11 void SetUp() override {} TearDown()12 void TearDown() override {} 13 }; 14 15 /** 16 * @tc.name: nearbyint_001 17 * @tc.desc: Obtain test data in sequence and check if it is within the expected error range of the nearbyint interface. 18 * @tc.type: FUNC 19 */ 20 HWTEST_F(MathNearbyintTest, nearbyint_001, TestSize.Level1) 21 { 22 fesetenv(FE_DFL_ENV); 23 for (int i = 0; i < sizeof(g_nearbyintData) / sizeof(DataDoubleDouble); i++) { 24 bool testResult = DoubleUlpCmp(g_nearbyintData[i].expected, nearbyint(g_nearbyintData[i].input), 1); 25 EXPECT_TRUE(testResult); 26 } 27 } 28 29 /** 30 * @tc.name: nearbyintf_001 31 * @tc.desc: Obtain test data in sequence and check if it is within the expected error range of the nearbyintf interface. 32 * @tc.type: FUNC 33 */ 34 HWTEST_F(MathNearbyintTest, nearbyintf_001, TestSize.Level1) 35 { 36 fesetenv(FE_DFL_ENV); 37 for (int i = 0; i < sizeof(g_nearbyintfData) / sizeof(DataFloatFloat); i++) { 38 bool testResult = FloatUlpCmp(g_nearbyintfData[i].expected, nearbyintf(g_nearbyintfData[i].input), 1); 39 EXPECT_TRUE(testResult); 40 } 41 }