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