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