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