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 <iostream>
17
18#include "udid.h"
19#include "param_stub.h"
20#include "sysparam_errno.h"
21#include "securec.h"
22
23using namespace std;
24using namespace testing::ext;
25
26namespace init_ut {
27extern "C" {
28int GetSha256Value(const char *input, char *udid, uint32_t udidSize);
29void SetDevUdid();
30int CalcDevUdid(char *udid, uint32_t size);
31}
32
33class UdidUnitTest : public testing::Test {
34public:
35    static void SetUpTestCase(void) {};
36    static void TearDownTestCase(void) {};
37    void SetUp() {};
38    void TearDown() {};
39};
40
41HWTEST_F(UdidUnitTest, TestUDID_001, TestSize.Level1)
42{
43    SetDevUdid();
44}
45
46HWTEST_F(UdidUnitTest, TestUDID_002, TestSize.Level1)
47{
48    int ret = GetSha256Value(nullptr, nullptr, 0);
49    EXPECT_EQ(ret, EC_FAILURE);
50}
51
52HWTEST_F(UdidUnitTest, TestUDID_003, TestSize.Level1)
53{
54    char udid[66] = {0};
55    int ret = CalcDevUdid(udid, 6);
56    EXPECT_EQ(ret, EC_FAILURE);
57    ret = CalcDevUdid(udid, 66);
58    EXPECT_EQ(ret, EC_SUCCESS);
59}
60} // namespace init_ut
61