1 /*
2 * Copyright (c) 2022-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 #include <string>
18 #include <vector>
19 #include "ent_info.h"
20
21 using namespace testing::ext;
22
23 namespace OHOS {
24 namespace EDM {
25 namespace TEST {
26 const std::string NAME{"test"};
27 const std::string DESCRIPTION{"this is test"};
28 class EntInfoTest : public testing::Test {
29 protected:
30 void SetUp() override;
31
32 void TearDown() override;
33
34 std::shared_ptr<EntInfo> entInfoTest;
35 };
36
SetUp()37 void EntInfoTest::SetUp()
38 {
39 entInfoTest = std::make_shared<EntInfo>(NAME, DESCRIPTION);
40 }
41
TearDown()42 void EntInfoTest::TearDown()
43 {
44 if (entInfoTest) {
45 entInfoTest.reset();
46 }
47 }
48
49 /**
50 * @tc.name: TestMarshalling
51 * @tc.desc: Test Marshalling func.
52 * @tc.type: FUNC
53 */
54 HWTEST_F(EntInfoTest, TestMarshalling, TestSize.Level1)
55 {
56 Parcel parcel;
57 bool ret = entInfoTest->Marshalling(parcel);
58 EXPECT_TRUE(ret);
59
60 EntInfo entinfo;
61 EntInfo *entinfo1 = entinfo.Unmarshalling(parcel);
62 EXPECT_TRUE(entinfo1 != nullptr);
63
64 EXPECT_STREQ((entinfo1->enterpriseName).c_str(), NAME.c_str());
65 EXPECT_STREQ((entinfo1->description).c_str(), DESCRIPTION.c_str());
66 EXPECT_STREQ((entInfoTest->enterpriseName).c_str(), (entinfo1->enterpriseName).c_str());
67 EXPECT_STREQ((entInfoTest->description).c_str(), (entinfo1->description).c_str());
68
69 if (entinfo1) {
70 delete entinfo1;
71 entinfo1 = nullptr;
72 }
73 }
74 } // namespace TEST
75 } // namespace EDM
76 } // namespace OHOS
77