• 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/lrintf_data.h"
6 #include "math_test_data/lrint_data.h"
7 
8 using namespace testing::ext;
9 
10 class MathLrintTest : public testing::Test {
SetUp()11     void SetUp() override {}
TearDown()12     void TearDown() override {}
13 };
14 
15 /**
16  * @tc.name: lrint_001
17  * @tc.desc: Obtain test data in sequence and check if it is within the expected error range of the lrint interface.
18  * @tc.type: FUNC
19  */
20 HWTEST_F(MathLrintTest, lrint_001, TestSize.Level1)
21 {
22     fesetenv(FE_DFL_ENV);
23     for (int i = 0; i < sizeof(g_lrintData) / sizeof(DataLongDouble); i++) {
24         bool testResult = DoubleUlpCmp(g_lrintData[i].expected, lrint(g_lrintData[i].input), 1);
25         EXPECT_TRUE(testResult);
26     }
27 }
28 /**
29  * @tc.name: lrintf_001
30  * @tc.desc: Obtain test data in sequence and check if it is within the expected error range of the lrintf interface.
31  * @tc.type: FUNC
32  */
33 HWTEST_F(MathLrintTest, lrintf_001, TestSize.Level1)
34 {
35     fesetenv(FE_DFL_ENV);
36     for (int i = 0; i < sizeof(g_lrintfData) / sizeof(DataLongFloat); i++) {
37         bool testResult = FloatUlpCmp(g_lrintfData[i].expected, lrintf(g_lrintfData[i].input), 1);
38         EXPECT_TRUE(testResult);
39     }
40 }