• 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 
18 #include "subscribe_info.h"
19 #include "utils.h"
20 
21 namespace OHOS {
22 namespace DeviceProfile {
23 using namespace testing;
24 using namespace testing::ext;
25 
26 class SubscribeInfoTest : public testing::Test {
27 public:
28     static void SetUpTestCase();
29     static void TearDownTestCase();
30     void SetUp();
31     void TearDown();
32 };
33 
SetUpTestCase()34 void SubscribeInfoTest::SetUpTestCase()
35 {
36     DTEST_LOG << "SetUpTestCase" << std::endl;
37 }
38 
TearDownTestCase()39 void SubscribeInfoTest::TearDownTestCase()
40 {
41     DTEST_LOG << "TearDownTestCase" << std::endl;
42 }
43 
SetUp()44 void SubscribeInfoTest::SetUp()
45 {
46     DTEST_LOG << "SetUp" << std::endl;
47 }
48 
TearDown()49 void SubscribeInfoTest::TearDown()
50 {
51     DTEST_LOG << "TearDown" << std::endl;
52 }
53 
54 /**
55  * @tc.name: Unmarshalling_001
56  * @tc.desc: unmarshalling
57  * @tc.type: FUNC
58  * @tc.require: I4NY1T
59  */
60 HWTEST_F(SubscribeInfoTest, Unmarshalling_001, TestSize.Level3)
61 {
62     Parcel parcel;
63     SubscribeInfo subInfo;
64     bool result = subInfo.Unmarshalling(parcel);
65     EXPECT_NE(true, result);
66 }
67 
68 /**
69  * @tc.name: Unmarshalling_001
70  * @tc.desc: unmarshalling
71  * @tc.type: FUNC
72  * @tc.require: I4NY1T
73  */
74 HWTEST_F(SubscribeInfoTest, Unmarshalling_002, TestSize.Level3)
75 {
76     Parcel parcel;
77     parcel.WriteUint32(1);
78     parcel.WriteString("test");
79     SubscribeInfo subInfo;
80     bool result = subInfo.Unmarshalling(parcel);
81     EXPECT_FALSE(result);
82 }
83 
84 /**
85  * @tc.name: Unmarshalling_001
86  * @tc.desc: unmarshalling
87  * @tc.type: FUNC
88  * @tc.require: I4NY1T
89  */
90 HWTEST_F(SubscribeInfoTest, Unmarshalling_003, TestSize.Level3)
91 {
92     Parcel parcel;
93     parcel.WriteUint32(1);
94     std::string test = R"(
95         {"key": "value"}
96     )";
97     parcel.WriteString(test);
98     SubscribeInfo subInfo;
99     bool result = subInfo.Unmarshalling(parcel);
100     EXPECT_TRUE(result);
101 }
102 
103 /**
104  * @tc.name: operator_001
105  * @tc.desc: operator
106  * @tc.type: FUNC
107  * @tc.require: I4NY1T
108  */
109 HWTEST_F(SubscribeInfoTest, operator_001, TestSize.Level3)
110 {
111     SubscribeInfo rhs;
112     SubscribeInfo subInfo;
113     bool result = subInfo.operator != (rhs);
114     EXPECT_NE(true, result);
115 }
116 }
117 }