1 /*
2 * Copyright (c) 2025 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_mem_wrapper_test.h"
17
18 #include <cstring>
19 #include <gtest/gtest.h>
20
21 #include "asset_mem.h"
22
23 using namespace testing::ext;
24 namespace UnitTest::AssetMemWrapperTest {
25 class AssetMemWrapperTest : public testing::Test {
26 public:
27 static void SetUpTestCase(void);
28
29 static void TearDownTestCase(void);
30
31 void SetUp(void);
32
33 void TearDown(void);
34 };
35
SetUpTestCase(void)36 void AssetMemWrapperTest::SetUpTestCase(void)
37 {
38 }
39
TearDownTestCase(void)40 void AssetMemWrapperTest::TearDownTestCase(void)
41 {
42 }
43
SetUp(void)44 void AssetMemWrapperTest::SetUp(void)
45 {
46 }
47
TearDown(void)48 void AssetMemWrapperTest::TearDown(void)
49 {
50 }
51
52 /**
53 * @tc.name: AssetMemWrapperTest.AssetMemWrapperTest001
54 * @tc.desc: Test asset func AssetMalloc, expect nullptr
55 * @tc.type: FUNC
56 * @tc.result:0
57 */
58 HWTEST_F(AssetMemWrapperTest, AssetMemWrapperTest001, TestSize.Level0)
59 {
60 ASSERT_EQ(nullptr, AssetMalloc(0));
61 }
62
63 /**
64 * @tc.name: AssetMemWrapperTest.AssetMemWrapperTest002
65 * @tc.desc: Test asset func AssetFree
66 * @tc.type: FUNC
67 * @tc.result:0
68 */
69 HWTEST_F(AssetMemWrapperTest, AssetMemWrapperTest002, TestSize.Level0)
70 {
71 AssetFree(nullptr);
72 }
73
74 /**
75 * @tc.name: AssetMemWrapperTest.AssetMemWrapperTest003
76 * @tc.desc: Test asset func AssetMemCmp, expect 0
77 * @tc.type: FUNC
78 * @tc.result:0
79 */
80 HWTEST_F(AssetMemWrapperTest, AssetMemWrapperTest003, TestSize.Level0)
81 {
82 const uint32_t size = 5;
83 uint8_t array1[size] = {1, 2, 3, 4, 5};
84 uint8_t array2[size] = {1, 2, 3, 4, 5};
85 ASSERT_EQ(0, AssetMemCmp(array1, array2, size));
86 }
87 }
88