• 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/scalbnf_data.h"
6 #include "math_test_data/scalbn_data.h"
7 
8 using namespace testing::ext;
9 
10 class MathScalbnTest : public testing::Test {
SetUp()11     void SetUp() override {}
TearDown()12     void TearDown() override {}
13 };
14 
15 /**
16  * @tc.name: scalbn_001
17  * @tc.desc: Obtain test data in sequence and check if it is within the expected error range of the scalbn interface.
18  * @tc.type: FUNC
19  */
20 HWTEST_F(MathScalbnTest, scalbn_001, TestSize.Level1)
21 {
22     fesetenv(FE_DFL_ENV);
23     for (int i = 0; i < sizeof(g_scalbnData) / sizeof(DataDoubleDoubleInt); i++) {
24         bool testResult = DoubleUlpCmp(g_scalbnData[i].expected,
25             scalbn(g_scalbnData[i].input1, g_scalbnData[i].input2), 1);
26         EXPECT_TRUE(testResult);
27     }
28 }
29 
30 /**
31  * @tc.name: scalbn_002
32  * @tc.desc: When the value is valid, test the return value of the function.
33  * @tc.type: FUNC
34  */
35 HWTEST_F(MathScalbnTest, scalbn_002, TestSize.Level1)
36 {
37     EXPECT_DOUBLE_EQ(40.0, scalbn(5.0, 3));
38 }
39 
40 /**
41  * @tc.name: scalbnf_001
42  * @tc.desc: Obtain test data in sequence and check if it is within the expected error range of the scalbnf interface.
43  * @tc.type: FUNC
44  */
45 HWTEST_F(MathScalbnTest, scalbnf_001, TestSize.Level1)
46 {
47     fesetenv(FE_DFL_ENV);
48     for (int i = 0; i < sizeof(g_scalbnfData) / sizeof(DataFloatFloatInt); i++) {
49         bool testResult = FloatUlpCmp(g_scalbnfData[i].expected,
50             scalbnf(g_scalbnfData[i].input1, g_scalbnfData[i].input2), 1);
51         EXPECT_TRUE(testResult);
52     }
53 }
54 
55 /**
56  * @tc.name: scalbnf_002
57  * @tc.desc: When the float value is valid, test the return value of the function.
58  * @tc.type: FUNC
59  */
60 HWTEST_F(MathScalbnTest, scalbnf_002, TestSize.Level1)
61 {
62     EXPECT_FLOAT_EQ(40.0f, scalbnf(5.0f, 3));
63 }
64 
65 /**
66  * @tc.name: scalbnl_001
67  * @tc.desc: When the long double value is valid, test the return value of the function.
68  * @tc.type: FUNC
69  */
70 HWTEST_F(MathScalbnTest, scalbnl_001, TestSize.Level1)
71 {
72     EXPECT_DOUBLE_EQ(40.0L, scalbnl(5.0L, 3));
73 }