• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 #include <gtest/gtest.h>
16 #include <gmock/gmock.h>
17 #include <cstddef>
18 #include <cstdint>
19 #include "securec.h"
20 #include "c_adapter/inc/wifi_c_utils.h"
21 
22 using ::testing::_;
23 using ::testing::AtLeast;
24 using ::testing::DoAll;
25 using ::testing::Eq;
26 using ::testing::Ref;
27 using ::testing::Return;
28 using ::testing::SetArgReferee;
29 using ::testing::StrEq;
30 using ::testing::TypedEq;
31 using ::testing::ext::TestSize;
32 
33 namespace OHOS {
34 namespace Wifi {
35 class WifiCUtilsTest : public testing::Test {
36 public:
SetUpTestCase()37     static void SetUpTestCase() {}
TearDownTestCase()38     static void TearDownTestCase() {}
SetUp()39     virtual void SetUp() {}
TearDown()40     virtual void TearDown() {}
41 
IpStrToArraySuccess()42     void IpStrToArraySuccess()
43     {
44         unsigned int ipAddr[IPV4_ARRAY_LEN] = {0};
45         std::string str = "192.168.1.23";
46         EXPECT_TRUE(IpStrToArray(str, ipAddr) == WIFI_SUCCESS);
47     }
48 
IpStrToArrayFail()49     void IpStrToArrayFail()
50     {
51         unsigned int ipAddr[IPV4_ARRAY_LEN] = {0};
52         std::string str = "192.168.1";
53         EXPECT_TRUE(IpStrToArray(str, ipAddr) == ERROR_WIFI_INVALID_ARGS);
54     }
55 
IpArrayToStrSuccess()56     void IpArrayToStrSuccess()
57     {
58         unsigned int ipAddr[IPV4_ARRAY_LEN] = {192, 168, 1, 23};
59         EXPECT_EQ(IpArrayToStr(ipAddr), "192.168.1.23");
60     }
61 };
62 
63 HWTEST_F(WifiCUtilsTest, IpStrToArraySuccess, TestSize.Level1)
64 {
65     IpStrToArraySuccess();
66 }
67 
68 HWTEST_F(WifiCUtilsTest, IpStrToArrayFail, TestSize.Level1)
69 {
70     IpStrToArrayFail();
71 }
72 
73 HWTEST_F(WifiCUtilsTest, IpArrayToStrSuccess, TestSize.Level1)
74 {
75     IpArrayToStrSuccess();
76 }
77 } // namespace Wifi
78 } // namespace OHOS