1 #include <gtest/gtest.h> 2 #include <math.h> 3 4 #include "math_data_test.h" 5 #include "math_test_data/tanf_data.h" 6 #include "math_test_data/tan_data.h" 7 8 using namespace testing::ext; 9 10 class MathTanTest : public testing::Test { SetUp()11 void SetUp() override {} TearDown()12 void TearDown() override {} 13 }; 14 15 /** 16 * @tc.name: tan_001 17 * @tc.desc: Obtain test data in sequence and check if it is within the expected error range 18 * of the tan interface. 19 * @tc.type: FUNC 20 */ 21 HWTEST_F(MathTanTest, tan_001, TestSize.Level1) 22 { 23 fesetenv(FE_DFL_ENV); 24 for (int i = 0; i < sizeof(g_tanData) / sizeof(DataDoubleDouble); i++) { 25 bool testResult = DoubleUlpCmp(g_tanData[i].expected, tan(g_tanData[i].input), 1); 26 EXPECT_TRUE(testResult); 27 } 28 } 29 30 /** 31 * @tc.name: tan_002 32 * @tc.desc: When the value is valid, test the return value of the function. 33 * @tc.type: FUNC 34 */ 35 HWTEST_F(MathTanTest, tan_002, TestSize.Level1) 36 { 37 EXPECT_DOUBLE_EQ(0.0, tan(0.0)); 38 } 39 40 /** 41 * @tc.name: tanf_001 42 * @tc.desc: Obtain test data in sequence and check if it is within the expected error range 43 * of the tanf interface. 44 * @tc.type: FUNC 45 */ 46 HWTEST_F(MathTanTest, tanf_001, TestSize.Level1) 47 { 48 fesetenv(FE_DFL_ENV); 49 for (int i = 0; i < sizeof(g_tanfData) / sizeof(DataFloatFloat); i++) { 50 bool testResult = FloatUlpCmp(g_tanfData[i].expected, tanf(g_tanfData[i].input), 1); 51 EXPECT_TRUE(testResult); 52 } 53 } 54 55 /** 56 * @tc.name: tanf_002 57 * @tc.desc: When the float value is valid, test the return value of the function. 58 * @tc.type: FUNC 59 */ 60 HWTEST_F(MathTanTest, tanf_002, TestSize.Level1) 61 { 62 EXPECT_FLOAT_EQ(0.0f, tanf(0.0f)); 63 } 64 65 /** 66 * @tc.name: tanl_001 67 * @tc.desc: When the long double value is valid, test the return value of the function. 68 * @tc.type: FUNC 69 */ 70 HWTEST_F(MathTanTest, tanl_001, TestSize.Level1) 71 { 72 EXPECT_DOUBLE_EQ(0.0L, tanl(0.0L)); 73 }