1/*
2 * Copyright (c) 2024-2024 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 <memory>
17#include <gtest/gtest.h>
18#include "extension.h"
19
20namespace OHOS {
21namespace SignatureTools {
22
23 /*
24 * 测试套件,固定写法
25 */
26class ExtensionTest : public testing::Test {
27public:
28    static void SetUpTestCase(void) {};
29    static void TearDownTestCase() {};
30    void SetUp() {};
31    void TearDown() {};
32};
33
34/**
35 * @tc.name: getSize
36 * @tc.desc: Test function of ExtensionTest::getSize() interface for SUCCESS.
37 * @tc.size: MEDIUM
38 * @tc.type: FUNC
39 * @tc.level Level 1
40 * @tc.require: SR000H63TL
41 */
42HWTEST_F(ExtensionTest, getSize, testing::ext::TestSize.Level1)
43{
44    std::shared_ptr<Extension> api = std::make_shared<Extension>();
45
46    int32_t sizeInt = api->GetSize();
47
48    EXPECT_NE(sizeInt, 0);
49}
50
51/**
52 * @tc.name: isType
53 * @tc.desc: The return will be false,because the type is error.
54 * @tc.size: MEDIUM
55 * @tc.type: FUNC
56 * @tc.level Level 1
57 * @tc.require: SR000H63TL
58 */
59HWTEST_F(ExtensionTest, isType, testing::ext::TestSize.Level1)
60{
61    std::shared_ptr<Extension> api = std::make_shared<Extension>();
62
63    int32_t type = 1;
64    bool bIsType = api->IsType(type);
65
66    EXPECT_EQ(bIsType, false);
67}
68
69/**
70 * @tc.name: toByteArray
71 * @tc.desc: Test function of ExtensionTest::toByteArray() interface for SUCCESS.
72 * @tc.size: MEDIUM
73 * @tc.type: FUNC
74 * @tc.level Level 1
75 * @tc.require: SR000H63TL
76 */
77HWTEST_F(ExtensionTest, toByteArray, testing::ext::TestSize.Level1)
78{
79    std::shared_ptr<Extension> api = std::make_shared<Extension>();
80
81    std::vector<int8_t> byteArray;
82    api->ToByteArray(byteArray);
83
84    EXPECT_EQ(byteArray.size(), 8);
85}
86} // namespace SignatureTools
87} // namespace OHOS