1 /*
2  * Copyright (C) 2023 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 
16 #include <gtest/gtest.h>
17 
18 #include "dhcp_result.h"
19 #include "dhcp_logger.h"
20 
21 DEFINE_DHCPLOG_DHCP_LABEL("DhcpResultTest");
22 
23 using namespace testing::ext;
24 using namespace OHOS::DHCP;
25 namespace OHOS {
26 namespace DHCP {
27 constexpr int ARRAY_SIZE = 1030;
28 class DhcpResultTest : public testing::Test {
29 public:
SetUpTestCase()30     static void SetUpTestCase()
31     {}
TearDownTestCase()32     static void TearDownTestCase()
33     {}
SetUp()34     virtual void SetUp()
35     {}
TearDown()36     virtual void TearDown()
37     {}
38 };
39 
40 HWTEST_F(DhcpResultTest, PublishDhcpIpv4ResultTest, TestSize.Level1)
41 {
42     DHCP_LOGI("PublishDhcpIpv4ResultTest enter!");
43     struct DhcpIpResult ipResult;
44     bool result = PublishDhcpIpv4Result(ipResult);
45     DHCP_LOGE("PublishDhcpIpv4ResultTest result(%{public}d)", result);
46     EXPECT_EQ(false, result);
47 }
48 
49 HWTEST_F(DhcpResultTest, DhcpIpv6TimerCallbackEventTest, TestSize.Level1)
50 {
51     DHCP_LOGI("DhcpIpv6TimerCallbackEventTest enter!");
52     std::string ifname = "wlan0";
53     EXPECT_EQ(false, DhcpIpv6TimerCallbackEvent(nullptr));
54     EXPECT_EQ(true, DhcpIpv6TimerCallbackEvent(ifname.c_str()));
55 }
56 }
57 }
58