• 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 <iostream>
18 #include <string>
19 
20 #include "secure_data.h"
21 
22 namespace OHOS {
23 namespace NetStack {
24 namespace {
25 using namespace testing::ext;
26 } // namespace
27 
28 class SecureDataTest : public testing::Test {
29 public:
SetUpTestCase()30     static void SetUpTestCase() {}
31 
TearDownTestCase()32     static void TearDownTestCase() {}
33 
SetUp()34     virtual void SetUp() {}
35 
TearDown()36     virtual void TearDown() {}
37 };
38 
39 HWTEST_F(SecureDataTest, stringData, TestSize.Level2)
40 {
41     std::string testString = "Secure Data string Test";
42     SecureData structureData(testString);
43     EXPECT_STREQ(structureData.Data(), "Secure Data string Test");
44 
45     SecureData copyData = structureData;
46     EXPECT_STREQ(copyData.Data(), "Secure Data string Test");
47 
48     SecureData equalData;
49     equalData = structureData;
50     EXPECT_STREQ(equalData.Data(), "Secure Data string Test");
51 
52     SecureData defaultData;
53     EXPECT_EQ(defaultData.Length(), 0);
54 }
55 } // namespace NetStack
56 } // namespace OHOS