1 #include <gtest/gtest.h> 2 #include <math.h> 3 4 #include "math_data_test.h" 5 #include "math_test_data/fminf_data.h" 6 #include "math_test_data/fmin_data.h" 7 8 using namespace testing::ext; 9 10 class MathFminTest : public testing::Test { SetUp()11 void SetUp() override {} TearDown()12 void TearDown() override {} 13 }; 14 15 /** 16 * @tc.name: fmin_001 17 * @tc.desc: Obtain test data in sequence and check if it is within the expected error range of the fmin interface. 18 * @tc.type: FUNC 19 */ 20 HWTEST_F(MathFminTest, fmin_001, TestSize.Level1) 21 { 22 fesetenv(FE_DFL_ENV); 23 for (int i = 0; i < sizeof(g_fminData) / sizeof(DataDouble3Expected1); i++) { 24 bool testResult = DoubleUlpCmp(g_fminData[i].expected, fmin(g_fminData[i].input1, g_fminData[i].input2), 1); 25 EXPECT_TRUE(testResult); 26 } 27 } 28 29 /** 30 * @tc.name: fmin_002 31 * @tc.desc: When the parameter of fmin is valid, test the return value of the function. 32 * @tc.type: FUNC 33 */ 34 HWTEST_F(MathFminTest, fmin_002, TestSize.Level1) 35 { 36 EXPECT_DOUBLE_EQ(14.0, fmin(15.0, 14.0)); 37 EXPECT_DOUBLE_EQ(11.0, fmin(11.0, nan(""))); 38 EXPECT_DOUBLE_EQ(12.0, fmin(nan(""), 12.0)); 39 } 40 41 /** 42 * @tc.name: fminf_001 43 * @tc.desc: Obtain test data in sequence and check if it is within the expected error range of the fminf interface. 44 * @tc.type: FUNC 45 */ 46 HWTEST_F(MathFminTest, fminf_001, TestSize.Level1) 47 { 48 fesetenv(FE_DFL_ENV); 49 for (int i = 0; i < sizeof(g_fminfData) / sizeof(DataFloat3Expected1); i++) { 50 bool testResult = FloatUlpCmp(g_fminfData[i].expected, fminf(g_fminfData[i].input1, g_fminfData[i].input2), 1); 51 EXPECT_TRUE(testResult); 52 } 53 } 54 55 /** 56 * @tc.name: fminf_002 57 * @tc.desc: When the parameter of fminf is valid, test the return value of the function. 58 * @tc.type: FUNC 59 */ 60 HWTEST_F(MathFminTest, fminf_002, TestSize.Level1) 61 { 62 EXPECT_FLOAT_EQ(14.0f, fminf(15.0f, 14.0f)); 63 EXPECT_FLOAT_EQ(11.0f, fminf(11.0f, nanf(""))); 64 EXPECT_FLOAT_EQ(12.0f, fminf(nanf(""), 12.0f)); 65 } 66 67 /** 68 * @tc.name: fminl_001 69 * @tc.desc: When the parameter of fminl is valid, test the return value of the function. 70 * @tc.type: FUNC 71 */ 72 HWTEST_F(MathFminTest, fminl_001, TestSize.Level1) 73 { 74 EXPECT_DOUBLE_EQ(14.0L, fminl(15.0L, 14.0L)); 75 EXPECT_DOUBLE_EQ(11.0L, fminl(11.0L, nanl(""))); 76 EXPECT_DOUBLE_EQ(12.0L, fminl(nanl(""), 12.0L)); 77 }