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 <securec.h>
16 #include "gtest/gtest.h"
17 
18 #include "softbus_errcode.h"
19 #include "softbus_adapter_range.h"
20 
21 using namespace std;
22 using namespace testing::ext;
23 
24 namespace OHOS {
25 class AdapterDsoftbusRangeTest : public testing::Test {
26 protected:
27     static void SetUpTestCase(void);
28     static void TearDownTestCase(void);
29     void SetUp();
30     void TearDown();
31 };
SetUpTestCase(void)32 void AdapterDsoftbusRangeTest::SetUpTestCase(void)
33 {
34 }
TearDownTestCase(void)35 void AdapterDsoftbusRangeTest::TearDownTestCase(void)
36 {
37 }
SetUp()38 void AdapterDsoftbusRangeTest::SetUp()
39 {
40 }
TearDown()41 void AdapterDsoftbusRangeTest::TearDown()
42 {
43 }
44 /*
45 * @tc.name: SoftBusBleRange001
46 * @tc.desc: parameters is Legal and illegal
47 * @tc.type: FUNC
48 * @tc.require: I5OHDE
49 */
50 HWTEST_F(AdapterDsoftbusRangeTest, SoftBusBleRange001, TestSize.Level0)
51 {
52     int32_t range = -1;
53     SoftBusRangeParam param = {
54         .rssi = 5,
55         .power = 1,
56         .identity = {"test"}
57     };
58     int32_t ret = SoftBusBleRange(nullptr, nullptr);
59     EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
60     ret = SoftBusBleRange(nullptr, &range);
61     EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
62     ret = SoftBusBleRange(&param, nullptr);
63     EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
64     ret = SoftBusBleRange(&param, &range);
65     EXPECT_EQ(0, ret);
66 }
67 
68 /*
69 * @tc.name: SoftBusGetBlePower001
70 * @tc.desc: parameter is Legal and illegal
71 * @tc.type: FUNC
72 * @tc.require: I5OHDE
73 */
74 HWTEST_F(AdapterDsoftbusRangeTest, SoftBusGetBlePower001, TestSize.Level0)
75 {
76     int8_t power = 0;
77     int ret = SoftBusGetBlePower(nullptr);
78     EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
79     ret = SoftBusGetBlePower(&power);
80     EXPECT_EQ(0, ret);
81 }
82 }