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 <securec.h>
17
18 #include "softbus_adapter_range.h"
19 #include "softbus_error_code.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) { }
TearDownTestCase(void)33 void AdapterDsoftbusRangeTest::TearDownTestCase(void) { }
SetUp()34 void AdapterDsoftbusRangeTest::SetUp() { }
TearDown()35 void AdapterDsoftbusRangeTest::TearDown() { }
36 /*
37 * @tc.name: SoftBusBleRange001
38 * @tc.desc: parameters is Legal and illegal
39 * @tc.type: FUNC
40 * @tc.require: I5OHDE
41 */
42 HWTEST_F(AdapterDsoftbusRangeTest, SoftBusBleRange001, TestSize.Level0)
43 {
44 int32_t range = -1;
45 SoftBusRangeParam param = { .rssi = 5, .power = 1, .identity = { "test" } };
46 int32_t ret = SoftBusBleRange(nullptr, nullptr);
47 EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
48 ret = SoftBusBleRange(nullptr, &range);
49 EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
50 ret = SoftBusBleRange(¶m, nullptr);
51 EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
52 ret = SoftBusBleRange(¶m, &range);
53 EXPECT_EQ(0, ret);
54 }
55
56 /*
57 * @tc.name: SoftBusGetBlePower001
58 * @tc.desc: parameter is Legal and illegal
59 * @tc.type: FUNC
60 * @tc.require: I5OHDE
61 */
62 HWTEST_F(AdapterDsoftbusRangeTest, SoftBusGetBlePower001, TestSize.Level0)
63 {
64 int8_t power = 0;
65 int32_t ret = SoftBusGetBlePower(nullptr);
66 EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
67 ret = SoftBusGetBlePower(&power);
68 EXPECT_EQ(0, ret);
69 }
70 } // namespace OHOS