1 #include <gtest/gtest.h> 2 #include <math.h> 3 4 #include "math_data_test.h" 5 #include "math_test_data/atan2f_data.h" 6 #include "math_test_data/atan2_data.h" 7 8 using namespace testing::ext; 9 10 class MathAtan2Test : public testing::Test { SetUp()11 void SetUp() override {} TearDown()12 void TearDown() override {} 13 }; 14 15 /** 16 * @tc.name: atan2_001 17 * @tc.desc: Obtain test data in sequence and check if it is within the expected error range of the atan2 interface. 18 * @tc.type: FUNC 19 */ 20 HWTEST_F(MathAtan2Test, atan2_001, TestSize.Level1) 21 { 22 fesetenv(FE_DFL_ENV); 23 for (int i = 0; i < sizeof(g_atan2Data) / sizeof(DataDouble3Expected1); i++) { 24 bool testResult = DoubleUlpCmp(g_atan2Data[i].expected, atan2(g_atan2Data[i].input1, g_atan2Data[i].input2), 2); 25 EXPECT_TRUE(testResult); 26 } 27 } 28 29 /** 30 * @tc.name: atan2_002 31 * @tc.desc: When the parameter of atan2 is valid, test the return value of the function. 32 * @tc.type: FUNC 33 */ 34 HWTEST_F(MathAtan2Test, atan2_002, TestSize.Level1) 35 { 36 EXPECT_DOUBLE_EQ(0.0, atan2(0.0, 0.0)); 37 } 38 39 /** 40 * @tc.name: atan2f_001 41 * @tc.desc: Obtain test data in sequence and check if it is within the expected error range of the atan2f interface. 42 * @tc.type: FUNC 43 */ 44 HWTEST_F(MathAtan2Test, atan2f_001, TestSize.Level1) 45 { 46 fesetenv(FE_DFL_ENV); 47 for (int i = 0; i < sizeof(g_atan2fData) / sizeof(DataFloat3Expected1); i++) { 48 bool testResult = FloatUlpCmp(g_atan2fData[i].expected, atan2f(g_atan2fData[i].input1, g_atan2fData[i].input2), 2); 49 EXPECT_TRUE(testResult); 50 } 51 } 52 53 /** 54 * @tc.name: atan2f_002 55 * @tc.desc: When the parameter of atan2f is valid, test the return value of the function. 56 * @tc.type: FUNC 57 */ 58 HWTEST_F(MathAtan2Test, atan2f_002, TestSize.Level1) 59 { 60 EXPECT_FLOAT_EQ(0.0f, atan2f(0.0f, 0.0f)); 61 } 62 63 /** 64 * @tc.name: atan2l_001 65 * @tc.desc: When the parameter of atan2l is valid, test the return value of the function. 66 * @tc.type: FUNC 67 */ 68 HWTEST_F(MathAtan2Test, atan2l_001, TestSize.Level1) 69 { 70 EXPECT_DOUBLE_EQ(0.0L, atan2l(0.0L, 0.0L)); 71 }