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 <gmock/gmock.h>
17 #include <gtest/gtest.h>
18
19 #include "dk_error.h"
20
21 namespace OHOS::FileManagement::CloudSync::Test {
22 using namespace testing;
23 using namespace testing::ext;
24 using namespace std;
25 using namespace DriveKit;
26
27 class DKErrorTest : public testing::Test {
28 public:
29 static void SetUpTestCase(void);
30 static void TearDownTestCase(void);
31 void SetUp();
32 void TearDown();
33 };
SetUpTestCase(void)34 void DKErrorTest::SetUpTestCase(void)
35 {
36 GTEST_LOG_(INFO) << "SetUpTestCase";
37 }
38
TearDownTestCase(void)39 void DKErrorTest::TearDownTestCase(void)
40 {
41 GTEST_LOG_(INFO) << "TearDownTestCase";
42 }
43
SetUp(void)44 void DKErrorTest::SetUp(void)
45 {
46 GTEST_LOG_(INFO) << "SetUp";
47 }
48
TearDown(void)49 void DKErrorTest::TearDown(void)
50 {
51 GTEST_LOG_(INFO) << "TearDown";
52 }
53
54 /**
55 * @tc.name: HasError
56 * @tc.desc: Verify the DKError::HasError function
57 * @tc.type: FUNC
58 * @tc.require: SR000HRKKA
59 */
60 HWTEST_F(DKErrorTest, HasError, TestSize.Level1)
61 {
62 DKError dkError;
63 bool ret = dkError.HasError();
64 EXPECT_EQ(ret, false);
65 }
66
67 /**
68 * @tc.name: SetLocalError
69 * @tc.desc: Verify the DKError::SetLocalError function
70 * @tc.type: FUNC
71 * @tc.require: SR000HRKKA
72 */
73 HWTEST_F(DKErrorTest, SetLocalError, TestSize.Level1)
74 {
75 DKLocalErrorCode code = DKLocalErrorCode::NO_ERROR;
76 DKError dkError;
77 dkError.SetLocalError(code);
78 EXPECT_EQ(dkError.dkErrorCode, DKLocalErrorCode::NO_ERROR);
79 }
80
81 /**
82 * @tc.name: SetServerError
83 * @tc.desc: Verify the DKError::SetServerError function
84 * @tc.type: FUNC
85 * @tc.require: SR000HRKKA
86 */
87 HWTEST_F(DKErrorTest, SetServerError, TestSize.Level1)
88 {
89 int code = 0;
90 DKError dkError;
91 dkError.SetServerError(code);
92 EXPECT_EQ(dkError.serverErrorCode, code);
93 }
94 } // namespace OHOS::FileManagement::CloudSync::Test
95