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