• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #define LOG_TAG "EndianConverterTest"
16 
17 #include <unistd.h>
18 #include <gtest/gtest.h>
19 #include <string>
20 
21 #include "logger.h"
22 #include "endian_converter.h"
23 
24 using namespace testing::ext;
25 using namespace OHOS::UDMF;
26 using namespace OHOS;
27 namespace OHOS::Test {
28 using namespace std;
29 
30 class EndianConverterTest : public testing::Test {
31 public:
32     static void SetUpTestCase();
33     static void TearDownTestCase();
34     void SetUp() override;
35     void TearDown() override;
36 };
37 
SetUpTestCase()38 void EndianConverterTest::SetUpTestCase()
39 {
40 }
41 
TearDownTestCase()42 void EndianConverterTest::TearDownTestCase()
43 {
44 }
45 
SetUp()46 void EndianConverterTest::SetUp()
47 {
48 }
49 
TearDown()50 void EndianConverterTest::TearDown()
51 {
52 }
53 
54 /**
55 * @tc.name: HostToNet001
56 * @tc.desc: Normal testcase of HostToNet
57 * @tc.type: FUNC
58 */
59 HWTEST_F(EndianConverterTest, HostToNet001, TestSize.Level1)
60 {
61     LOG_INFO(UDMF_TEST, "HostToNet001 begin.");
62     float value = 3.1415926;
63     float ret = HostToNet(value);
64     EXPECT_EQ(ret, value);
65     LOG_INFO(UDMF_TEST, "HostToNet001 end.");
66 }
67 
68 /**
69 * @tc.name: NetToHost001
70 * @tc.desc: Normal testcase of NetToHost
71 * @tc.type: FUNC
72 */
73 HWTEST_F(EndianConverterTest, NetToHost001, TestSize.Level1)
74 {
75     LOG_INFO(UDMF_TEST, "NetToHost001 begin.");
76     float value = 3.1415926;
77     float ret = NetToHost(value);
78     EXPECT_EQ(ret, value);
79     LOG_INFO(UDMF_TEST, "NetToHost001 end.");
80 }
81 
82 /**
83 * @tc.name: HostToNet002
84 * @tc.desc: Normal testcase of HostToNet
85 * @tc.type: FUNC
86 */
87 HWTEST_F(EndianConverterTest, HostToNet002, TestSize.Level1)
88 {
89     LOG_INFO(UDMF_TEST, "HostToNet002 begin.");
90     double value = 3.14;
91     double ret = HostToNet(value);
92     EXPECT_EQ(ret, value);
93     LOG_INFO(UDMF_TEST, "HostToNet002 end.");
94 }
95 
96 /**
97 * @tc.name: NetToHost002
98 * @tc.desc: Normal testcase of NetToHost
99 * @tc.type: FUNC
100 */
101 HWTEST_F(EndianConverterTest, NetToHost002, TestSize.Level1)
102 {
103     LOG_INFO(UDMF_TEST, "NetToHost002 begin.");
104     double value = 3.14;
105     double ret = NetToHost(value);
106     EXPECT_EQ(ret, value);
107     LOG_INFO(UDMF_TEST, "NetToHost002 end.");
108 }
109 } // OHOS::Test