1 /*
2 * Copyright (c) 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 "asset_operation_test.h"
17
18 #include <string>
19 #include <gtest/gtest.h>
20
21 #include "asset_api.h"
22 #include "asset_test_common.h"
23
24 using namespace testing::ext;
25 namespace UnitTest::AssetOperationTest {
26 class AssetOperationTest : public testing::Test {
27 public:
28 static void SetUpTestCase(void);
29
30 static void TearDownTestCase(void);
31
32 void SetUp(void);
33
34 void TearDown(void);
35 };
36
SetUpTestCase(void)37 void AssetOperationTest::SetUpTestCase(void)
38 {
39 }
40
TearDownTestCase(void)41 void AssetOperationTest::TearDownTestCase(void)
42 {
43 }
44
SetUp(void)45 void AssetOperationTest::SetUp(void)
46 {
47 }
48
TearDown(void)49 void AssetOperationTest::TearDown(void)
50 {
51 }
52
53 /**
54 * @tc.name: AssetOperationTest.AssetOperationTest001
55 * @tc.desc: Free blob with nullptr, expect non-crsh
56 * @tc.type: FUNC
57 * @tc.result:0
58 */
59 HWTEST_F(AssetOperationTest, AssetOperationTest001, TestSize.Level0)
60 {
61 OH_Asset_FreeBlob(nullptr);
62 }
63
64 /**
65 * @tc.name: AssetOperationTest.AssetOperationTest002
66 * @tc.desc: Free blob with nullptr data, expect non-crsh
67 * @tc.type: FUNC
68 * @tc.result:0
69 */
70 HWTEST_F(AssetOperationTest, AssetOperationTest002, TestSize.Level0)
71 {
72 Asset_Blob blob = { .size = 0, .data = nullptr };
73 OH_Asset_FreeBlob(&blob);
74 }
75
76 /**
77 * @tc.name: AssetOperationTest.AssetOperationTest003
78 * @tc.desc: Free blob with nullptr data, expect non-crsh
79 * @tc.type: FUNC
80 * @tc.result:0
81 */
82 HWTEST_F(AssetOperationTest, AssetOperationTest003, TestSize.Level0)
83 {
84 Asset_Blob blob = { .size = 0, .data = reinterpret_cast<uint8_t*>(const_cast<char*>(__func__)) };
85 OH_Asset_FreeBlob(&blob);
86 }
87
88 /**
89 * @tc.name: AssetOperationTest.AssetOperationTest004
90 * @tc.desc: Free result set with nullptr, expect non-crsh
91 * @tc.type: FUNC
92 * @tc.result:0
93 */
94 HWTEST_F(AssetOperationTest, AssetOperationTest004, TestSize.Level0)
95 {
96 OH_Asset_FreeResultSet(nullptr);
97 }
98
99 /**
100 * @tc.name: AssetOperationTest.AssetOperationTest005
101 * @tc.desc: Free result set with nullptr, expect non-crsh
102 * @tc.type: FUNC
103 * @tc.result:0
104 */
105 HWTEST_F(AssetOperationTest, AssetOperationTest005, TestSize.Level0)
106 {
107 Asset_ResultSet resultSet = { .count = 0, .results = nullptr };
108 OH_Asset_FreeResultSet(&resultSet);
109 }
110 }