• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "cloud_daemon_statistic.cpp"
17 
18 #include <gmock/gmock.h>
19 #include <gtest/gtest.h>
20 
21 namespace OHOS::FileManagement::CloudFile::test {
22 using namespace testing;
23 using namespace testing::ext;
24 using namespace std;
25 
26 class CloudDaemonStatisticStaticTest : public testing::Test {
27 public:
28     static void SetUpTestCase(void);
29     static void TearDownTestCase(void);
30     void SetUp();
31     void TearDown();
32 };
33 
SetUpTestCase(void)34 void CloudDaemonStatisticStaticTest::SetUpTestCase(void)
35 {
36     GTEST_LOG_(INFO) << "SetUpTestCase";
37 }
38 
TearDownTestCase(void)39 void CloudDaemonStatisticStaticTest::TearDownTestCase(void)
40 {
41     GTEST_LOG_(INFO) << "TearDownTestCase";
42 }
43 
SetUp(void)44 void CloudDaemonStatisticStaticTest::SetUp(void)
45 {
46     GTEST_LOG_(INFO) << "SetUp";
47 }
48 
TearDown(void)49 void CloudDaemonStatisticStaticTest::TearDown(void)
50 {
51     GTEST_LOG_(INFO) << "TearDown";
52 }
53 
54 HWTEST_F(CloudDaemonStatisticStaticTest, CheckOverflow_001, TestSize.Level1)
55 {
56     GTEST_LOG_(INFO) << "CheckOverflow_001 Start";
57     uint32_t data = 0;
58 
59     try {
60         CheckOverflow(data, 1);
61         EXPECT_EQ(data, 1);
62     } catch(...) {
63         EXPECT_TRUE(false);
64         GTEST_LOG_(INFO) << "CheckOverflow_001 ERROR";
65     }
66     GTEST_LOG_(INFO) << "CheckOverflow_001 End";
67 }
68 
69 HWTEST_F(CloudDaemonStatisticStaticTest, CheckOverflow_002, TestSize.Level1)
70 {
71     GTEST_LOG_(INFO) << "CheckOverflow_002 Start";
72     uint32_t data = UINT32_MAX;
73 
74     try {
75         CheckOverflow(data, 1);
76         EXPECT_EQ(data, UINT32_MAX);
77     } catch(...) {
78         EXPECT_TRUE(false);
79         GTEST_LOG_(INFO) << "CheckOverflow_002 ERROR";
80     }
81     GTEST_LOG_(INFO) << "CheckOverflow_002 End";
82 }
83 }