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