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 #include <memory>
16 #include <gtest/gtest.h>
17 #include "block_data.h"
18
19 namespace OHOS {
20 namespace SignatureTools {
21
22 /*
23 * 测试套件,固定写法
24 */
25 class BlockDataTest : public testing::Test {
26 public:
SetUpTestCase(void)27 static void SetUpTestCase(void)
28 {
29 };
TearDownTestCase()30 static void TearDownTestCase()
31 {
32 };
SetUp()33 void SetUp()
34 {
35 };
TearDown()36 void TearDown()
37 {
38 };
39 };
40
41 /**
42 * @tc.name: GetBlockNum
43 * @tc.desc: Test function of BlockDataTest::GetBlockNum() interface for SUCCESS.
44 * @tc.size: MEDIUM
45 * @tc.type: FUNC
46 * @tc.level Level 1
47 * @tc.require: SR000H63TL
48 */
HWTEST_F(BlockDataTest, GetBlockNum, testing::ext::TestSize.Level1)49 HWTEST_F(BlockDataTest, GetBlockNum, testing::ext::TestSize.Level1)
50 {
51 std::shared_ptr<BlockData> api = std::make_shared<BlockData>(2, 0);
52 int32_t blockNum = api->GetBlockNum();
53 EXPECT_EQ(blockNum, 2);
54 }
55
56 /**
57 * @tc.name: GetBlockStart
58 * @tc.desc: Test function of BlockDataTest::GetBlockStart() interface for SUCCESS.
59 * @tc.size: MEDIUM
60 * @tc.type: FUNC
61 * @tc.level Level 1
62 * @tc.require: SR000H63TL
63 */
HWTEST_F(BlockDataTest, GetBlockStart, testing::ext::TestSize.Level1)64 HWTEST_F(BlockDataTest, GetBlockStart, testing::ext::TestSize.Level1)
65 {
66 std::shared_ptr<BlockData> api = std::make_shared<BlockData>(2, 0);
67 int32_t blockStart = api->GetBlockStart();
68 EXPECT_EQ(blockStart, 0);
69 }
70
71 /**
72 * @tc.name: SetBlockNum
73 * @tc.desc: Test function of BlockDataTest::SetBlockNum() interface for SUCCESS.
74 * @tc.size: MEDIUM
75 * @tc.type: FUNC
76 * @tc.level Level 1
77 * @tc.require: SR000H63TL
78 */
HWTEST_F(BlockDataTest, SetBlockNum, testing::ext::TestSize.Level1)79 HWTEST_F(BlockDataTest, SetBlockNum, testing::ext::TestSize.Level1)
80 {
81 std::shared_ptr<BlockData> api = std::make_shared<BlockData>(2, 0);
82 api->SetBlockNum(3);
83 int32_t blockNum = api->GetBlockNum();
84 EXPECT_EQ(blockNum, 3);
85 }
86
87 /**
88 * @tc.name: SetBlockStart
89 * @tc.desc: Test function of BlockDataTest::SetBlockStart() interface for SUCCESS.
90 * @tc.size: MEDIUM
91 * @tc.type: FUNC
92 * @tc.level Level 1
93 * @tc.require: SR000H63TL
94 */
HWTEST_F(BlockDataTest, SetBlockStart, testing::ext::TestSize.Level1)95 HWTEST_F(BlockDataTest, SetBlockStart, testing::ext::TestSize.Level1)
96 {
97 std::shared_ptr<BlockData> api = std::make_shared<BlockData>(2, 0);
98 api->SetBlockStart(1);
99 int32_t blockStart = api->GetBlockStart();
100 EXPECT_EQ(blockStart, 1);
101 }
102 } // namespace SignatureTools
103 } // namespace OHOS