• 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 
16 #include <gtest/gtest.h>
17 #include <securec.h>
18 
19 #include "lnn_node_weight.h"
20 #include "softbus_errcode.h"
21 #include "softbus_log.h"
22 
23 namespace OHOS {
24 using namespace testing;
25 using namespace testing::ext;
26 
27 constexpr char UDID1[] = "123456789AB";
28 constexpr char UDID2[] = "123456789ab";
29 constexpr int32_t WEIGHT = 10;
30 constexpr int32_t WEIGHT2 = 5;
31 constexpr int32_t WEIGHT3 = 5;
32 
33 class LnnNodeWeightTest : public testing::Test {
34 public:
35     static void SetUpTestCase();
36     static void TearDownTestCase();
37     void SetUp();
38     void TearDown();
39 };
40 
SetUpTestCase()41 void LnnNodeWeightTest::SetUpTestCase()
42 {
43 }
44 
TearDownTestCase()45 void LnnNodeWeightTest::TearDownTestCase()
46 {
47 }
48 
SetUp()49 void LnnNodeWeightTest::SetUp()
50 {
51 }
52 
TearDown()53 void LnnNodeWeightTest::TearDown()
54 {
55 }
56 
57 /*
58 * @tc.name: LNN_COMPARE_NODE_WEIGHT_TEST_001
59 * @tc.desc: test LnnCompareNodeWeight
60 * @tc.type: FUNC
61 * @tc.require: I5OMIK
62 */
63 HWTEST_F(LnnNodeWeightTest, LNN_COMPARE_NODE_WEIGHT_TEST_001, TestSize.Level1)
64 {
65     char *masterUdid = nullptr;
66     int32_t ret = LnnCompareNodeWeight(WEIGHT, UDID1, WEIGHT2, UDID2);
67     EXPECT_TRUE(ret == (WEIGHT - WEIGHT2));
68     ret = LnnCompareNodeWeight(WEIGHT, masterUdid, WEIGHT2, UDID2);
69     EXPECT_TRUE(ret == (WEIGHT - WEIGHT2));
70     ret = LnnCompareNodeWeight(WEIGHT2, UDID1, WEIGHT3, UDID2);
71     EXPECT_TRUE(ret < 0);
72 }
73 } // namespace OHOS
74