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 <gtest/gtest.h>
17 
18 #include "dfs_error.h"
19 
20 namespace OHOS::FileManagement::Test {
21 using namespace testing;
22 using namespace testing::ext;
23 using namespace std;
24 
25 class DfsErrorTest : public testing::Test {
26 public:
27     static void SetUpTestCase(void);
28     static void TearDownTestCase(void);
29     void SetUp();
30     void TearDown();
31 };
SetUpTestCase(void)32 void DfsErrorTest::SetUpTestCase(void)
33 {
34     GTEST_LOG_(INFO) << "SetUpTestCase";
35 }
36 
TearDownTestCase(void)37 void DfsErrorTest::TearDownTestCase(void)
38 {
39     GTEST_LOG_(INFO) << "TearDownTestCase";
40 }
41 
SetUp(void)42 void DfsErrorTest::SetUp(void)
43 {
44     GTEST_LOG_(INFO) << "SetUp";
45 }
46 
TearDown(void)47 void DfsErrorTest::TearDown(void)
48 {
49     GTEST_LOG_(INFO) << "TearDown";
50 }
51 
52 /**
53  * @tc.name: Convert2JsErrNumTest
54  * @tc.desc: Verify the Convert2JsErrNum function
55  * @tc.type: FUNC
56  * @tc.require: SR000HRKKAs
57  */
58 HWTEST_F(DfsErrorTest, Convert2JsErrNumTest, TestSize.Level1)
59 {
60     GTEST_LOG_(INFO) << "Convert2JsErrNumTest Start";
61     try {
62         int32_t errNum = -1;
63         int32_t ret = Convert2JsErrNum(errNum);
64         EXPECT_EQ(ret, errNum);
65         errNum = E_PERMISSION_DENIED;
66         ret = Convert2JsErrNum(errNum);
67         EXPECT_EQ(ret, E_PERMISSION);
68     } catch (...) {
69         EXPECT_TRUE(false);
70         GTEST_LOG_(INFO) << "Convert2JsErrNumTest FAILED";
71     }
72     GTEST_LOG_(INFO) << "Convert2JsErrNumTest End";
73 }
74 } // namespace OHOS::FileManagement::Test
75