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 "stat_core.h"
17
18 #include <gtest/gtest.h>
19
20 namespace OHOS::FileManagement::ModuleFileIO::Test {
21 using namespace testing;
22 using namespace testing::ext;
23 using namespace std;
24
25 class StatCoreTest : public testing::Test {
26 public:
27 static void SetUpTestCase(void);
28 static void TearDownTestCase(void);
29 void SetUp();
30 void TearDown();
31 };
32
SetUpTestCase(void)33 void StatCoreTest::SetUpTestCase(void)
34 {
35 GTEST_LOG_(INFO) << "SetUpTestCase";
36 }
37
TearDownTestCase(void)38 void StatCoreTest::TearDownTestCase(void)
39 {
40 GTEST_LOG_(INFO) << "TearDownTestCase";
41 }
42
SetUp(void)43 void StatCoreTest::SetUp(void)
44 {
45 GTEST_LOG_(INFO) << "SetUp";
46 }
47
TearDown(void)48 void StatCoreTest::TearDown(void)
49 {
50 GTEST_LOG_(INFO) << "TearDown";
51 }
52
53 /**
54 * @tc.name: StatCoreTest_DoStat_001
55 * @tc.desc: Test function of StatCore::DoStat interface for FALSE.
56 * @tc.size: MEDIUM
57 * @tc.type: FUNC
58 * @tc.level Level 1
59 */
60 HWTEST_F(StatCoreTest, StatCoreTest_DoStat_001, testing::ext::TestSize.Level1)
61 {
62 GTEST_LOG_(INFO) << "StatCoreTest-begin StatCoreTest_DoStat_001";
63
64 FileInfo fileinfo;
65
66 auto res = StatCore::DoStat(fileinfo);
67 EXPECT_EQ(res.IsSuccess(), false);
68
69 GTEST_LOG_(INFO) << "StatCoreTest-end StatCoreTest_DoStat_001";
70 }
71
72 /**
73 * @tc.name: StatCoreTest_DoStat_002
74 * @tc.desc: Test function of StatCore::DoStat interface for FALSE.
75 * @tc.size: MEDIUM
76 * @tc.type: FUNC
77 * @tc.level Level 1
78 */
79 HWTEST_F(StatCoreTest, StatCoreTest_DoStat_002, testing::ext::TestSize.Level1)
80 {
81 GTEST_LOG_(INFO) << "StatCoreTest-begin StatCoreTest_DoStat_002";
82
83 FileInfo fileinfo;
84 fileinfo.path = std::make_unique<char[]>(1);
85 fileinfo.fdg = std::make_unique<DistributedFS::FDGuard>(-1);
86 fileinfo.isPath = false;
87
88 auto res = StatCore::DoStat(fileinfo);
89 EXPECT_EQ(res.IsSuccess(), false);
90
91 GTEST_LOG_(INFO) << "StatCoreTest-end StatCoreTest_DoStat_002";
92 }
93
94 } // namespace OHOS::FileManagement::ModuleFileIO::Test