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