1 #include <gtest/gtest.h> 2 #include <math.h> 3 4 using namespace testing::ext; 5 6 class MathLgammarTest : public testing::Test { SetUp()7 void SetUp() override {} TearDown()8 void TearDown() override {} 9 }; 10 11 /** 12 * @tc.name: lgamma_r_001 13 * @tc.desc: The goal of this test case is to validate lgamma_r function can correctly 14 * calculate the logarithm of the lgamma_r function and store the symbols in sign. 15 * @tc.type: FUNC 16 */ 17 HWTEST_F(MathLgammarTest, lgamma_r_001, TestSize.Level1) 18 { 19 int signResult = 0; 20 EXPECT_DOUBLE_EQ(log(1.0), lgamma_r(2.0, &signResult)); 21 EXPECT_EQ(1, signResult); 22 } 23 24 /** 25 * @tc.name: lgamma_r_002 26 * @tc.desc: This test is used to detect whether the set parameters meet expectations when 27 * they are positive. 28 * @tc.type: FUNC 29 */ 30 HWTEST_F(MathLgammarTest, lgamma_r_002, TestSize.Level1) 31 { 32 int signResult = 0; 33 EXPECT_DOUBLE_EQ(HUGE_VAL, lgamma_r(0.0, &signResult)); 34 EXPECT_EQ(1, signResult); 35 } 36 37 /** 38 * @tc.name: lgamma_r_003 39 * @tc.desc: This test is used to detect whether the set parameter meets expectations when 40 * it is negative. 41 * @tc.type: FUNC 42 */ 43 HWTEST_F(MathLgammarTest, lgamma_r_003, TestSize.Level1) 44 { 45 int signResult = 0; 46 EXPECT_DOUBLE_EQ(HUGE_VAL, lgamma_r(-0.0, &signResult)); 47 EXPECT_EQ(-1, signResult); 48 } 49 50 /** 51 * @tc.name: lgammaf_r_001 52 * @tc.desc: The goal of this test case is to validate lgammaf_r function can correctly 53 * calculate the logarithm of the lgammaf_r function and store the symbols in sign. 54 * @tc.type: FUNC 55 */ 56 HWTEST_F(MathLgammarTest, lgammaf_r_001, TestSize.Level1) 57 { 58 int signResult = 0; 59 EXPECT_DOUBLE_EQ(log(1.0f), lgammaf_r(2.0f, &signResult)); 60 EXPECT_EQ(1, signResult); 61 } 62 63 /** 64 * @tc.name: lgammaf_r_002 65 * @tc.desc: This test is used to detect whether the set parameters meet expectations when 66 * they are positive. 67 * @tc.type: FUNC 68 */ 69 HWTEST_F(MathLgammarTest, lgammaf_r_002, TestSize.Level1) 70 { 71 int signResult = 0; 72 EXPECT_DOUBLE_EQ(HUGE_VAL, lgammaf_r(0.0f, &signResult)); 73 EXPECT_EQ(1, signResult); 74 } 75 76 /** 77 * @tc.name: lgammaf_r_003 78 * @tc.desc: This test is used to detect whether the set parameter meets expectations when 79 * it is negative. 80 * @tc.type: FUNC 81 */ 82 HWTEST_F(MathLgammarTest, lgammaf_r_003, TestSize.Level1) 83 { 84 int signResult = 0; 85 EXPECT_DOUBLE_EQ(HUGE_VAL, lgammaf_r(-0.0f, &signResult)); 86 EXPECT_EQ(-1, signResult); 87 } 88 89 /** 90 * @tc.name: lgammal_r_001 91 * @tc.desc: The goal of this test case is to validate lgammal_r function can correctly 92 * calculate the logarithm of the lgammal_r function and store the symbols in sign. 93 * @tc.type: FUNC 94 */ 95 HWTEST_F(MathLgammarTest, lgammal_r_001, TestSize.Level1) 96 { 97 int signResult = 0; 98 EXPECT_DOUBLE_EQ(log(1.0L), lgamma_r(2.0L, &signResult)); 99 EXPECT_EQ(1, signResult); 100 } 101 102 /** 103 * @tc.name: lgammal_r_002 104 * @tc.desc: This test is used to detect whether the set parameters meet expectations when 105 * they are positive. 106 * @tc.type: FUNC 107 */ 108 HWTEST_F(MathLgammarTest, lgammal_r_002, TestSize.Level1) 109 { 110 int signResult = 0; 111 EXPECT_DOUBLE_EQ(HUGE_VAL, lgammal_r(0.0L, &signResult)); 112 EXPECT_EQ(1, signResult); 113 } 114 115 /** 116 * @tc.name: lgammal_r_003 117 * @tc.desc: This test is used to detect whether the set parameter meets expectations when 118 * it is negative. 119 * @tc.type: FUNC 120 */ 121 HWTEST_F(MathLgammarTest, lgammal_r_003, TestSize.Level1) 122 { 123 int signResult = 0; 124 EXPECT_DOUBLE_EQ(HUGE_VAL, lgammal_r(-0.0L, &signResult)); 125 EXPECT_EQ(-1, signResult); 126 }