1 /*
2  * Copyright (c) 2024 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 <future>
17 #include <optional>
18 #include <unistd.h>
19 #include <utility>
20 #include <vector>
21 
22 #include <gtest/gtest.h>
23 
24 #include "devicestatus_define.h"
25 #include "devicestatus_errors.h"
26 #include "utility.h"
27 
28 #undef LOG_TAG
29 #define LOG_TAG "UtilityTest"
30 
31 namespace OHOS {
32 namespace Msdp {
33 namespace DeviceStatus {
34 using namespace testing::ext;
35 namespace {
36 constexpr int32_t TIME_WAIT_FOR_OP_MS { 20 };
37 const std::string STR_INFO { "abc12345" };
38 const std::string STR_PREFIX { "abc" };
39 const std::string NETWORK_ID = { "abcd123456ef" };
40 const std::string EXPECT_ID = { "abcd1*****456ef" };
41 const std::string COPY_DRAG_PATH { "/system/etc/device_status/drag_icon/Copy_Drag.svg" };
42 constexpr int32_t FILE_SIZE_MAX { 0x5000 };
43 constexpr size_t SIZE1 {10};
44 constexpr size_t SIZE2 {20};
45 } // namespace
46 
47 class UtilityTest : public testing::Test {
48 public:
49     void SetUp();
50     void TearDown();
51     static void SetUpTestCase();
52     static void TearDownTestCase(void);
53 };
54 
SetUpTestCase()55 void UtilityTest::SetUpTestCase() {}
56 
TearDownTestCase()57 void UtilityTest::TearDownTestCase() {}
58 
SetUp()59 void UtilityTest::SetUp() {}
60 
TearDown()61 void UtilityTest::TearDown()
62 {
63     std::this_thread::sleep_for(std::chrono::milliseconds(TIME_WAIT_FOR_OP_MS));
64 }
65 
66 /**
67  * @tc.name: UtityTest_IsInteger_001
68  * @tc.desc: Checks whether a string is an integer.
69  * @tc.type: FUNC
70  * @tc.require:
71  */
HWTEST_F(UtilityTest, UtityTest_IsInteger_001, TestSize.Level1)72 HWTEST_F(UtilityTest, UtityTest_IsInteger_001, TestSize.Level1)
73 {
74     CALL_TEST_DEBUG;
75     std::string target = "0";
76     bool ret = Utility::IsInteger(target);
77     ASSERT_TRUE(ret);
78 }
79 
80 /**
81  * @tc.name: UtityTest_IsInteger_002
82  * @tc.desc: Checks whether a string is an integer.
83  * @tc.type: FUNC
84  * @tc.require:
85  */
HWTEST_F(UtilityTest, UtityTest_IsInteger_002, TestSize.Level1)86 HWTEST_F(UtilityTest, UtityTest_IsInteger_002, TestSize.Level1)
87 {
88     CALL_TEST_DEBUG;
89     std::string target = "123";
90     bool ret = Utility::IsInteger(target);
91     ASSERT_TRUE(ret);
92 }
93 
94 /**
95  * @tc.name: UtityTest_IsInteger_003
96  * @tc.desc: Checks whether a string is an integer.
97  * @tc.type: FUNC
98  * @tc.require:
99  */
HWTEST_F(UtilityTest, UtityTest_IsInteger_003, TestSize.Level1)100 HWTEST_F(UtilityTest, UtityTest_IsInteger_003, TestSize.Level1)
101 {
102     CALL_TEST_DEBUG;
103     std::string target = " 0";
104     bool ret = Utility::IsInteger(target);
105     ASSERT_TRUE(ret);
106 }
107 
108 /**
109  * @tc.name: UtityTest_IsInteger_004
110  * @tc.desc: Checks whether a string is an integer.
111  * @tc.type: FUNC
112  * @tc.require:
113  */
HWTEST_F(UtilityTest, UtityTest_IsInteger_004, TestSize.Level1)114 HWTEST_F(UtilityTest, UtityTest_IsInteger_004, TestSize.Level1)
115 {
116     CALL_TEST_DEBUG;
117     std::string target = "-0";
118     bool ret = Utility::IsInteger(target);
119     ASSERT_TRUE(ret);
120 }
121 
122 /**
123  * @tc.name: UtityTest_IsInteger_005
124  * @tc.desc: Checks whether a string is an integer.
125  * @tc.type: FUNC
126  * @tc.require:
127  */
HWTEST_F(UtilityTest, UtityTest_IsInteger_005, TestSize.Level1)128 HWTEST_F(UtilityTest, UtityTest_IsInteger_005, TestSize.Level1)
129 {
130     CALL_TEST_DEBUG;
131     std::string target = "-1";
132     bool ret = Utility::IsInteger(target);
133     ASSERT_TRUE(ret);
134 }
135 
136 /**
137  * @tc.name: UtityTest_IsInteger_006
138  * @tc.desc: Checks whether a string is an integer.
139  * @tc.type: FUNC
140  * @tc.require:
141  */
HWTEST_F(UtilityTest, UtityTest_IsInteger_006, TestSize.Level1)142 HWTEST_F(UtilityTest, UtityTest_IsInteger_006, TestSize.Level1)
143 {
144     CALL_TEST_DEBUG;
145     std::string target = "-10";
146     bool ret = Utility::IsInteger(target);
147     ASSERT_TRUE(ret);
148 }
149 
150 /**
151  * @tc.name: UtityTest_IsInteger_007
152  * @tc.desc: Checks whether a string is an integer.
153  * @tc.type: FUNC
154  * @tc.require:
155  */
HWTEST_F(UtilityTest, UtityTest_IsInteger_007, TestSize.Level1)156 HWTEST_F(UtilityTest, UtityTest_IsInteger_007, TestSize.Level1)
157 {
158     CALL_TEST_DEBUG;
159     std::string target = "123";
160     bool ret = Utility::IsInteger(target);
161     ASSERT_TRUE(ret);
162 }
163 
164 /**
165  * @tc.name: UtityTest_IsInteger_008
166  * @tc.desc: Checks whether a string is an integer.
167  * @tc.type: FUNC
168  * @tc.require:
169  */
HWTEST_F(UtilityTest, UtityTest_IsInteger_008, TestSize.Level1)170 HWTEST_F(UtilityTest, UtityTest_IsInteger_008, TestSize.Level1)
171 {
172     CALL_TEST_DEBUG;
173     std::string target = "-123";
174     bool ret = Utility::IsInteger(target);
175     ASSERT_TRUE(ret);
176 }
177 
178 /**
179  * @tc.name: UtityTest_IsInteger_009
180  * @tc.desc: Checks whether a string is an integer.
181  * @tc.type: FUNC
182  * @tc.require:
183  */
HWTEST_F(UtilityTest, UtityTest_IsInteger_009, TestSize.Level1)184 HWTEST_F(UtilityTest, UtityTest_IsInteger_009, TestSize.Level1)
185 {
186     CALL_TEST_DEBUG;
187     std::string target = "0123";
188     bool ret = Utility::IsInteger(target);
189     ASSERT_FALSE(ret);
190 }
191 
192 /**
193  * @tc.name: UtityTest_IsInteger_010
194  * @tc.desc: Checks whether a string is an integer.
195  * @tc.type: FUNC
196  * @tc.require:
197  */
HWTEST_F(UtilityTest, UtityTest_IsInteger_010, TestSize.Level1)198 HWTEST_F(UtilityTest, UtityTest_IsInteger_010, TestSize.Level1)
199 {
200     CALL_TEST_DEBUG;
201     std::string target = "A01";
202     bool ret = Utility::IsInteger(target);
203     ASSERT_FALSE(ret);
204 }
205 
206 /**
207  * @tc.name: UtityTest_IsInteger_011
208  * @tc.desc: Checks whether a string is an integer.
209  * @tc.type: FUNC
210  * @tc.require:
211  */
HWTEST_F(UtilityTest, UtityTest_IsInteger_011, TestSize.Level1)212 HWTEST_F(UtilityTest,  UtityTest_IsInteger_011, TestSize.Level1)
213 {
214     CALL_TEST_DEBUG;
215     std::string target = "A-10";
216     bool ret = Utility::IsInteger(target);
217     ASSERT_FALSE(ret);
218 }
219 
220 /**
221  * @tc.name: UtityTest_IsInteger_012
222  * @tc.desc: Checks whether a string is an integer.
223  * @tc.type: FUNC
224  * @tc.require:
225  */
HWTEST_F(UtilityTest, UtityTest_IsInteger_012, TestSize.Level1)226 HWTEST_F(UtilityTest, UtityTest_IsInteger_012, TestSize.Level1)
227 {
228     CALL_TEST_DEBUG;
229     std::string target = " 123A";
230     bool ret = Utility::IsInteger(target);
231     ASSERT_FALSE(ret);
232 }
233 
234 /**
235  * @tc.name: UtityTest_IsInteger_013
236  * @tc.desc: Checks whether a string is an integer.
237  * @tc.type: FUNC
238  * @tc.require:
239  */
HWTEST_F(UtilityTest, UtityTest_IsInteger_013, TestSize.Level1)240 HWTEST_F(UtilityTest, UtityTest_IsInteger_013, TestSize.Level1)
241 {
242     CALL_TEST_DEBUG;
243     std::string target = " 123 A";
244     bool ret = Utility::IsInteger(target);
245     ASSERT_FALSE(ret);
246 }
247 
248 /**
249  * @tc.name: UtityTest_GetFileSize1_001
250  * @tc.desc: Enter an existing file and read the length.
251  * @tc.type: FUNC
252  * @tc.require:
253  */
HWTEST_F(UtilityTest, UtityTest_GetFileSize1_001, TestSize.Level1)254 HWTEST_F(UtilityTest, UtityTest_GetFileSize1_001, TestSize.Level1)
255 {
256     CALL_TEST_DEBUG;
257     ssize_t fileSize = Utility::GetFileSize(COPY_DRAG_PATH.c_str());
258     if ((fileSize <= 0) || (fileSize > FILE_SIZE_MAX)) {
259         FI_HILOGW("File size out of read range, filseSize: %{public}zd.", fileSize);
260     } else {
261         FI_HILOGI("%{public}d: File is %{public}s, and file size is %{public}zd.",
262             __LINE__, COPY_DRAG_PATH.c_str(), fileSize);
263     }
264     EXPECT_GT(fileSize, 0);
265 }
266 
267 /**
268  * @tc.name: UtityTest_GetFileSize1_002
269  * @tc.desc: Enter a nonexistent file and read the length.
270  * @tc.type: FUNC
271  * @tc.require:
272  */
HWTEST_F(UtilityTest, UtityTest_GetFileSize1_002, TestSize.Level1)273 HWTEST_F(UtilityTest, UtityTest_GetFileSize1_002, TestSize.Level1)
274 {
275     CALL_TEST_DEBUG;
276     const char *filePath = "xxx/not_exist_file.txt";
277     ssize_t fileSize = Utility::GetFileSize(filePath);
278     if ((fileSize <= 0) || (fileSize > FILE_SIZE_MAX)) {
279         FI_HILOGW("File size out of read range, filseSize: %{public}zd.", fileSize);
280     }
281     EXPECT_EQ(fileSize, 0);
282 }
283 
284 /**
285  * @tc.name: UtityTest_GetFileSize1_003
286  * @tc.desc: Enter an empty string and read the length.
287  * @tc.type: FUNC
288  * @tc.require:
289  */
HWTEST_F(UtilityTest, UtityTest_GetFileSize1_003, TestSize.Level1)290 HWTEST_F(UtilityTest, UtityTest_GetFileSize1_003, TestSize.Level1)
291 {
292     CALL_TEST_DEBUG;
293     const char *filePath = "";
294     ssize_t fileSize = Utility::GetFileSize(filePath);
295     if ((fileSize <= 0) || (fileSize > FILE_SIZE_MAX)) {
296         FI_HILOGW("File size out of read range, filseSize: %{public}zd.", fileSize);
297     }
298     EXPECT_EQ(fileSize, 0);
299 }
300 
301 /**
302  * @tc.name: UtityTest_GetFileSize1_004
303  * @tc.desc: Enter a null pointer and read the length.
304  * @tc.type: FUNC
305  * @tc.require:
306  */
HWTEST_F(UtilityTest, UtityTest_GetFileSize1_004, TestSize.Level1)307 HWTEST_F(UtilityTest, UtityTest_GetFileSize1_004, TestSize.Level1)
308 {
309     CALL_TEST_DEBUG;
310     const char *filePath = nullptr;
311     ssize_t fileSize = Utility::GetFileSize(filePath);
312     if ((fileSize <= 0) || (fileSize > FILE_SIZE_MAX)) {
313         FI_HILOGW("File size out of read range, filseSize: %{public}zd.", fileSize);
314     }
315     EXPECT_EQ(fileSize, 0);
316 }
317 
318 /**
319  * @tc.name: UtityTest_GetFileSize2_001
320  * @tc.desc: Enter an existing file and read the length.
321  * @tc.type: FUNC
322  * @tc.require:
323  */
HWTEST_F(UtilityTest, UtityTest_GetFileSize2_001, TestSize.Level1)324 HWTEST_F(UtilityTest, UtityTest_GetFileSize2_001, TestSize.Level1)
325 {
326     CALL_TEST_DEBUG;
327     ssize_t fileSize = Utility::GetFileSize(COPY_DRAG_PATH);
328     if ((fileSize <= 0) || (fileSize > FILE_SIZE_MAX)) {
329         FI_HILOGW("File size out of read range, filseSize: %{public}zd.", fileSize);
330     } else {
331         FI_HILOGI("%{public}d: File is %{public}s, and file size is %{public}zd.",
332             __LINE__, COPY_DRAG_PATH.c_str(), fileSize);
333     }
334     EXPECT_GT(fileSize, 0);
335 }
336 
337 /**
338  * @tc.name: UtityTest_GetFileSize2_002
339  * @tc.desc: Enter a nonexistent file and read the length.
340  * @tc.type: FUNC
341  * @tc.require:
342  */
HWTEST_F(UtilityTest, UtityTest_GetFileSize2_002, TestSize.Level1)343 HWTEST_F(UtilityTest, UtityTest_GetFileSize2_002, TestSize.Level1)
344 {
345     CALL_TEST_DEBUG;
346     std::string filePath = "xxx/not_exist_file.txt";
347     ssize_t fileSize = Utility::GetFileSize(filePath);
348     if ((fileSize <= 0) || (fileSize > FILE_SIZE_MAX)) {
349         FI_HILOGW("File size out of read range, filseSize: %{public}zd.", fileSize);
350     }
351     EXPECT_EQ(fileSize, 0);
352 }
353 
354 /**
355  * @tc.name: UtityTest_GetFileSize_003
356  * @tc.desc: Enter an empty string and read the length.
357  * @tc.type: FUNC
358  * @tc.require:
359  */
HWTEST_F(UtilityTest, UtityTest_GetFileSize2_003, TestSize.Level1)360 HWTEST_F(UtilityTest, UtityTest_GetFileSize2_003, TestSize.Level1)
361 {
362     CALL_TEST_DEBUG;
363     std::string filePath = "";
364     ssize_t fileSize = Utility::GetFileSize(filePath);
365     if ((fileSize <= 0) || (fileSize > FILE_SIZE_MAX)) {
366         FI_HILOGW("File size out of read range, filseSize: %{public}zd.", fileSize);
367     }
368     EXPECT_EQ(fileSize, 0);
369 }
370 
371 /**
372  * @tc.name: UtityTest_Anonymize1_001
373  * @tc.desc: Enter a normal 12-string network ID, anonymising the middle part to 6 '*' in addition to the first
374  *  and last 4 characters.
375  * @tc.type: FUNC
376  * @tc.require:
377  */
HWTEST_F(UtilityTest, UtityTest_Anonymize1_001, TestSize.Level1)378 HWTEST_F(UtilityTest, UtityTest_Anonymize1_001, TestSize.Level1)
379 {
380     CALL_TEST_DEBUG;
381     FI_HILOGI("%{public}d: Before anonymous processing, it is %{public}s, and after processing, it is %{public}s.",
382          __LINE__, NETWORK_ID.c_str(), Utility::Anonymize(NETWORK_ID).c_str());
383     ASSERT_NO_FATAL_FAILURE(Utility::IsEqual(EXPECT_ID.c_str(), Utility::Anonymize(NETWORK_ID).c_str()));
384 }
385 
386 /**
387  * @tc.name: UtityTest_Anonymize1_002
388  * @tc.desc: Enter an empty network ID string, anonymized by 6 digits.
389  * @tc.type: FUNC
390  * @tc.require:
391  */
HWTEST_F(UtilityTest, UtityTest_Anonymize1_002, TestSize.Level1)392 HWTEST_F(UtilityTest, UtityTest_Anonymize1_002, TestSize.Level1)
393 {
394     CALL_TEST_DEBUG;
395     const char *id = "";
396     FI_HILOGI("%{public}d: Before anonymous processing, it is %{public}s, and after processing, it is %{public}s.",
397         __LINE__, id, Utility::Anonymize(id).c_str());
398     ASSERT_NO_FATAL_FAILURE(Utility::IsEqual("**********", Utility::Anonymize(id).c_str()));
399 }
400 
401 /**
402  * @tc.name: UtityTest_Anonymize1_003
403  * @tc.desc: Enter a network ID string less than 12 in length, anonymized to 6 *.
404  * @tc.type: FUNC
405  * @tc.require:
406  */
HWTEST_F(UtilityTest, UtityTest_Anonymize1_003, TestSize.Level1)407 HWTEST_F(UtilityTest, UtityTest_Anonymize1_003, TestSize.Level1)
408 {
409     CALL_TEST_DEBUG;
410     const char *id = "abcd123456";
411     FI_HILOGI("%{public}d: Before anonymous processing, it is %{public}s, and after processing, it is %{public}s.",
412         __LINE__, id, Utility::Anonymize(id).c_str());
413     ASSERT_NO_FATAL_FAILURE(Utility::IsEqual("abcd1*****23456", Utility::Anonymize(id).c_str()));
414 }
415 
416 /**
417  * @tc.name: UtityTest_Anonymize1_004
418  * @tc.desc: Anonymisation of strings longer than 32 characters
419  * @tc.type: FUNC
420  * @tc.require:
421  */
HWTEST_F(UtilityTest, UtityTest_Anonymize1_004, TestSize.Level1)422 HWTEST_F(UtilityTest, UtityTest_Anonymize1_004, TestSize.Level1)
423 {
424     CALL_TEST_DEBUG;
425     const char *id = "abcd123456efghijklmnopqrstuvwxyzabcd";
426     FI_HILOGI("%{public}d: Before anonymous processing, it is %{public}s, and after processing, it is %{public}s.",
427         __LINE__, id, Utility::Anonymize(id).c_str());
428     ASSERT_NO_FATAL_FAILURE(Utility::IsEqual("abcd1*****zabcd", Utility::Anonymize(id).c_str()));
429 }
430 
431 /**
432  * @tc.name: UtityTest_Anonymize1_005
433  * @tc.desc: Enter null pointer network ID, anonymized to 6 '*'.
434  * @tc.type: FUNC
435  * @tc.require:
436  */
HWTEST_F(UtilityTest, UtityTest_Anonymize1_005, TestSize.Level1)437 HWTEST_F(UtilityTest, UtityTest_Anonymize1_005, TestSize.Level1)
438 {
439     CALL_TEST_DEBUG;
440     const char *id = nullptr;
441     FI_HILOGI("%{public}d: Before anonymous processing, it is %{public}s, and after processing, it is %{public}s.",
442         __LINE__, id, Utility::Anonymize(id).c_str());
443     ASSERT_NO_FATAL_FAILURE(Utility::IsEqual("**********", Utility::Anonymize(id).c_str()));
444 }
445 
446 /**
447  * @tc.name: UtityTest_Anonymize2_001
448  * @tc.desc: Enter a normal 12-string network ID, anonymising the middle part to 6 '*' in addition to the first
449  *  and last 4 characters.
450  * @tc.type: FUNC
451  * @tc.require:
452  */
HWTEST_F(UtilityTest, UtityTest_Anonymize2_001, TestSize.Level1)453 HWTEST_F(UtilityTest, UtityTest_Anonymize2_001, TestSize.Level1)
454 {
455     CALL_TEST_DEBUG;
456     FI_HILOGI("%{public}d: Before anonymous processing, it is %{public}s, and after processing, it is %{public}s.",
457         __LINE__, NETWORK_ID.c_str(), Utility::Anonymize(NETWORK_ID).c_str());
458     ASSERT_NO_FATAL_FAILURE(Utility::IsEqual(EXPECT_ID.c_str(), Utility::Anonymize(NETWORK_ID).c_str()));
459 }
460 
461 /**
462  * @tc.name: UtityTest_Anonymize2_002
463  * @tc.desc: Enter an empty network ID string, anonymized by 6 digits.
464  * @tc.type: FUNC
465  * @tc.require:
466  */
HWTEST_F(UtilityTest, UtityTest_Anonymize2_002, TestSize.Level1)467 HWTEST_F(UtilityTest, UtityTest_Anonymize2_002, TestSize.Level1)
468 {
469     CALL_TEST_DEBUG;
470     std::string id = "";
471     FI_HILOGI("%{public}d: Before anonymous processing, it is %{public}s, and after processing, it is %{public}s.",
472         __LINE__, id.c_str(), Utility::Anonymize(id).c_str());
473     ASSERT_NO_FATAL_FAILURE(Utility::IsEqual("**********", Utility::Anonymize(id).c_str()));
474 }
475 
476 /**
477  * @tc.name: UtityTest_Anonymize2_003
478  * @tc.desc: Enter a network ID string less than 12 in length, anonymized to 6 *.
479  * @tc.type: FUNC
480  * @tc.require:
481  */
HWTEST_F(UtilityTest, UtityTest_Anonymize2_003, TestSize.Level1)482 HWTEST_F(UtilityTest, UtityTest_Anonymize2_003, TestSize.Level1)
483 {
484     CALL_TEST_DEBUG;
485     std::string id = "abcd123456";
486     FI_HILOGI("%{public}d: Before anonymous processing, it is %{public}s, and after processing, it is %{public}s.",
487         __LINE__, id.c_str(), Utility::Anonymize(id).c_str());
488     ASSERT_NO_FATAL_FAILURE(Utility::IsEqual("abcd1*****23456", Utility::Anonymize(id).c_str()));
489 }
490 
491 /**
492  * @tc.name: UtityTest_Anonymize2_004
493  * @tc.desc: Anonymisation of strings longer than 32 characters.
494  * @tc.type: FUNC
495  * @tc.require:
496  */
HWTEST_F(UtilityTest, UtityTest_Anonymize2_004, TestSize.Level1)497 HWTEST_F(UtilityTest, UtityTest_Anonymize2_004, TestSize.Level1)
498 {
499     CALL_TEST_DEBUG;
500     std::string id = "abcd123456efghijklmnopqrstuvwxyzabcd";
501     FI_HILOGI("%{public}d: Before anonymous processing, it is %{public}s, and after processing, it is %{public}s.",
502         __LINE__, id.c_str(), Utility::Anonymize(id).c_str());
503     ASSERT_NO_FATAL_FAILURE(Utility::IsEqual("abcd1*****zabcd", Utility::Anonymize(id).c_str()));
504 }
505 
506 /**
507  * @tc.name: UtityTest_DoesFileExist_001
508  * @tc.desc: Check the file is or not exist
509  * @tc.type: FUNC
510  * @tc.require:
511  */
HWTEST_F(UtilityTest, UtityTest_DoesFileExist_001, TestSize.Level1)512 HWTEST_F(UtilityTest, UtityTest_DoesFileExist_001, TestSize.Level1)
513 {
514     CALL_TEST_DEBUG;
515     const char *filePath = "/system/etc/device_status/drag_icon/Copy_Drag.svg";
516     bool isExist = Utility::DoesFileExist(filePath);
517     ASSERT_TRUE(isExist);
518 }
519 
520 /**
521  * @tc.name: UtityTest_DoesFileExist_002
522  * @tc.desc: Check the file is or not exist
523  * @tc.type: FUNC
524  * @tc.require:
525  */
HWTEST_F(UtilityTest, UtityTest_DoesFileExist_002, TestSize.Level1)526 HWTEST_F(UtilityTest, UtityTest_DoesFileExist_002, TestSize.Level1)
527 {
528     CALL_TEST_DEBUG;
529     const char *filePath = "";
530     bool isExist = Utility::DoesFileExist(filePath);
531     ASSERT_FALSE(isExist);
532 }
533 
534 /**
535  * @tc.name: UtityTest_DoesFileExist_003
536  * @tc.desc: Check the file is or not exist
537  * @tc.type: FUNC
538  * @tc.require:
539  */
HWTEST_F(UtilityTest, UtityTest_DoesFileExist_003, TestSize.Level1)540 HWTEST_F(UtilityTest, UtityTest_DoesFileExist_003, TestSize.Level1)
541 {
542     CALL_TEST_DEBUG;
543     const char *filePath = "xxx/not_exist_file.txt";
544     bool isExist = Utility::DoesFileExist(filePath);
545     ASSERT_FALSE(isExist);
546 }
547 
548 /**
549  * @tc.name: UtityTest_DoesFileExist_004
550  * @tc.desc: Check the file is or not exist
551  * @tc.type: FUNC
552  * @tc.require:
553  */
HWTEST_F(UtilityTest, UtityTest_DoesFileExist_004, TestSize.Level1)554 HWTEST_F(UtilityTest, UtityTest_DoesFileExist_004, TestSize.Level1)
555 {
556     CALL_TEST_DEBUG;
557     const char *filePath = nullptr;
558     bool isExist = Utility::DoesFileExist(filePath);
559     ASSERT_FALSE(isExist);
560 }
561 
562 /**
563  * @tc.name: UtityTest_IsEmpty_001
564  * @tc.desc: Check string is or not empty
565  * @tc.type: FUNC
566  * @tc.require:
567  */
HWTEST_F(UtilityTest, UtityTest_IsEmpty_001, TestSize.Level1)568 HWTEST_F(UtilityTest, UtityTest_IsEmpty_001, TestSize.Level1)
569 {
570     CALL_TEST_DEBUG;
571     const char *str = "isempty";
572     bool isEmpty = Utility::IsEmpty(str);
573     ASSERT_FALSE(isEmpty);
574 }
575 
576 /**
577  * @tc.name: UtityTest_IsEmpty_002
578  * @tc.desc: Check string is or not empty
579  * @tc.type: FUNC
580  * @tc.require:
581  */
HWTEST_F(UtilityTest, UtityTest_IsEmpty_002, TestSize.Level1)582 HWTEST_F(UtilityTest, UtityTest_IsEmpty_002, TestSize.Level1)
583 {
584     CALL_TEST_DEBUG;
585     const char *str = "";
586     bool isEmpty = Utility::IsEmpty(str);
587     ASSERT_TRUE(isEmpty);
588 }
589 
590 /**
591  * @tc.name: UtityTest_IsEmpty_003
592  * @tc.desc: Check string is or not empty
593  * @tc.type: FUNC
594  * @tc.require:
595  */
HWTEST_F(UtilityTest, UtityTest_IsEmpty_003, TestSize.Level1)596 HWTEST_F(UtilityTest, UtityTest_IsEmpty_003, TestSize.Level1)
597 {
598     CALL_TEST_DEBUG;
599     const char *str = nullptr;
600     bool isEmpty = Utility::IsEmpty(str);
601     ASSERT_TRUE(isEmpty);
602 }
603 
604 /**
605  * @tc.name: UtityTest_IsEqual_001
606  * @tc.desc: Check string is or not equal
607  * @tc.type: FUNC
608  * @tc.require:
609  */
HWTEST_F(UtilityTest, UtityTest_IsEqual_001, TestSize.Level1)610 HWTEST_F(UtilityTest, UtityTest_IsEqual_001, TestSize.Level1)
611 {
612     CALL_TEST_DEBUG;
613     const char *str1 = "abcde";
614     const char *str2 = "abcde";
615     bool isEqual = Utility::IsEqual(str1, str2);
616     ASSERT_TRUE(isEqual);
617 }
618 
619 /**
620  * @tc.name: UtityTest_IsEqual_002
621  * @tc.desc: Check string is or not equal
622  * @tc.type: FUNC
623  * @tc.require:
624  */
HWTEST_F(UtilityTest, UtityTest_IsEqual_002, TestSize.Level1)625 HWTEST_F(UtilityTest, UtityTest_IsEqual_002, TestSize.Level1)
626 {
627     CALL_TEST_DEBUG;
628     const char *str1 = "abcde";
629     const char *str2 = "edcba";
630     bool isEqual = Utility::IsEqual(str1, str2);
631     ASSERT_FALSE(isEqual);
632 }
633 
634 /**
635  * @tc.name: UtityTest_IsEqual_003
636  * @tc.desc: Check string is or not equal
637  * @tc.type: FUNC
638  * @tc.require:
639  */
HWTEST_F(UtilityTest, UtityTest_IsEqual_003, TestSize.Level1)640 HWTEST_F(UtilityTest, UtityTest_IsEqual_003, TestSize.Level1)
641 {
642     CALL_TEST_DEBUG;
643     const char *str1 = "";
644     const char *str2 = "";
645     bool isEqual = Utility::IsEqual(str1, str2);
646     ASSERT_TRUE(isEqual);
647 }
648 
649 /**
650  * @tc.name: UtityTest_IsEqual_004
651  * @tc.desc: Check string is or not equal
652  * @tc.type: FUNC
653  * @tc.require:
654  */
HWTEST_F(UtilityTest, UtityTest_IsEqual_004, TestSize.Level1)655 HWTEST_F(UtilityTest, UtityTest_IsEqual_004, TestSize.Level1)
656 {
657     CALL_TEST_DEBUG;
658     const char *str1 = "abcde";
659     const char *str2 = "";
660     bool isEqual = Utility::IsEqual(str1, str2);
661     ASSERT_FALSE(isEqual);
662 }
663 
664 /**
665  * @tc.name: UtityTest_IsEqual_005
666  * @tc.desc: Check string is or not equal
667  * @tc.type: FUNC
668  * @tc.require:
669  */
HWTEST_F(UtilityTest, UtityTest_IsEqual_005, TestSize.Level1)670 HWTEST_F(UtilityTest, UtityTest_IsEqual_005, TestSize.Level1)
671 {
672     CALL_TEST_DEBUG;
673     const char *str1 = "";
674     const char *str2 = nullptr;
675     bool isEqual = Utility::IsEqual(str1, str2);
676     ASSERT_TRUE(isEqual);
677 }
678 
679 /**
680  * @tc.name: UtityTest_IsEqual_006
681  * @tc.desc: Check string is or not equal
682  * @tc.type: FUNC
683  * @tc.require:
684  */
HWTEST_F(UtilityTest, UtityTest_IsEqual_006, TestSize.Level1)685 HWTEST_F(UtilityTest, UtityTest_IsEqual_006, TestSize.Level1)
686 {
687     CALL_TEST_DEBUG;
688     const char *str1 = nullptr;
689     const char *str2 = nullptr;
690     bool isEqual = Utility::IsEqual(str1, str2);
691     ASSERT_TRUE(isEqual);
692 }
693 
694 /**
695  * @tc.name: UtityTest_IsEqual_007
696  * @tc.desc: Check string is or not equal
697  * @tc.type: FUNC
698  * @tc.require:
699  */
HWTEST_F(UtilityTest, UtityTest_IsEqual_007, TestSize.Level1)700 HWTEST_F(UtilityTest, UtityTest_IsEqual_007, TestSize.Level1)
701 {
702     CALL_TEST_DEBUG;
703     const char *str1 = "abcde";
704     const char *str2 = nullptr;
705     bool isEqual = Utility::IsEqual(str1, str2);
706     ASSERT_FALSE(isEqual);
707 }
708 
709 /**
710  * @tc.name: UtityTest_ConcatAsString_001
711  * @tc.desc: Splicing strings
712  * @tc.type: FUNC
713  * @tc.require:
714  */
HWTEST_F(UtilityTest, UtityTest_ConcatAsString_001, TestSize.Level1)715 HWTEST_F(UtilityTest, UtityTest_ConcatAsString_001, TestSize.Level1)
716 {
717     CALL_TEST_DEBUG;
718     std::string str1 = "abcde";
719     std::string str = Utility::ConcatAsString(str1);
720     EXPECT_STREQ(str.c_str(), str1.c_str());
721 }
722 
723 /**
724  * @tc.name: UtityTest_ConcatAsString_002
725  * @tc.desc: Splicing strings
726  * @tc.type: FUNC
727  * @tc.require:
728  */
HWTEST_F(UtilityTest, UtityTest_ConcatAsString_002, TestSize.Level1)729 HWTEST_F(UtilityTest, UtityTest_ConcatAsString_002, TestSize.Level1)
730 {
731     CALL_TEST_DEBUG;
732     std::string str1 = "abcde";
733     std::string str2 = "fghij";
734     std::string str = Utility::ConcatAsString(str1, str2);
735     EXPECT_STREQ(str.c_str(), "abcdefghij");
736 }
737 
738 /**
739  * @tc.name: UtityTest_ConcatAsString_003
740  * @tc.desc: Splicing strings
741  * @tc.type: FUNC
742  * @tc.require:
743  */
HWTEST_F(UtilityTest, UtityTest_ConcatAsString_003, TestSize.Level1)744 HWTEST_F(UtilityTest, UtityTest_ConcatAsString_003, TestSize.Level1)
745 {
746     CALL_TEST_DEBUG;
747     std::string str1 = "abcde";
748     std::string str2 = "fghij";
749     std::string str3 = "klmno";
750     std::string str = Utility::ConcatAsString(str1, str2, str3);
751     EXPECT_STREQ(str.c_str(), "abcdefghijklmno");
752 }
753 
754 /**
755  * @tc.name: UtityTest_ConcatAsString_004
756  * @tc.desc: Splicing strings
757  * @tc.type: FUNC
758  * @tc.require:
759  */
HWTEST_F(UtilityTest, UtityTest_ConcatAsString_004, TestSize.Level1)760 HWTEST_F(UtilityTest, UtityTest_ConcatAsString_004, TestSize.Level1)
761 {
762     CALL_TEST_DEBUG;
763     std::string str1 = "abcde";
764     std::string str2 = "fghij";
765     std::string str3 = "";
766     std::string str = Utility::ConcatAsString(str1, str2, str3);
767     EXPECT_STREQ(str.c_str(), "abcdefghij");
768 }
769 
770 /**
771  * @tc.name: UtityTest_RemoveSpace_001
772  * @tc.desc: Remove string space
773  * @tc.type: FUNC
774  * @tc.require:
775  */
HWTEST_F(UtilityTest, UtityTest_RemoveSpace_001, TestSize.Level1)776 HWTEST_F(UtilityTest, UtityTest_RemoveSpace_001, TestSize.Level1)
777 {
778     CALL_TEST_DEBUG;
779     std::string str = "abc de";
780     Utility::RemoveSpace(str);
781     EXPECT_STREQ(str.c_str(), "abcde");
782 }
783 
784 /**
785  * @tc.name: UtityTest_RemoveSpace_002
786  * @tc.desc: Remove string space
787  * @tc.type: FUNC
788  * @tc.require:
789  */
HWTEST_F(UtilityTest, UtityTest_RemoveSpace_002, TestSize.Level1)790 HWTEST_F(UtilityTest, UtityTest_RemoveSpace_002, TestSize.Level1)
791 {
792     CALL_TEST_DEBUG;
793     std::string str = "abcde";
794     Utility::RemoveSpace(str);
795     EXPECT_STREQ(str.c_str(), "abcde");
796 }
797 
798 /**
799  * @tc.name: UtityTest_RemoveSpace_003
800  * @tc.desc: Remove string space
801  * @tc.type: FUNC
802  * @tc.require:
803  */
HWTEST_F(UtilityTest, UtityTest_RemoveSpace_003, TestSize.Level1)804 HWTEST_F(UtilityTest, UtityTest_RemoveSpace_003, TestSize.Level1)
805 {
806     CALL_TEST_DEBUG;
807     std::string str = " abcde";
808     Utility::RemoveSpace(str);
809     EXPECT_STREQ(str.c_str(), "abcde");
810 }
811 
812 /**
813  * @tc.name: UtityTest_RemoveSpace_004
814  * @tc.desc: Remove string space
815  * @tc.type: FUNC
816  * @tc.require:
817  */
HWTEST_F(UtilityTest, UtityTest_RemoveSpace_004, TestSize.Level1)818 HWTEST_F(UtilityTest, UtityTest_RemoveSpace_004, TestSize.Level1)
819 {
820     CALL_TEST_DEBUG;
821     std::string str = "abcde ";
822     Utility::RemoveSpace(str);
823     EXPECT_STREQ(str.c_str(), "abcde");
824 }
825 
826 /**
827  * @tc.name: UtityTest_RemoveSpace_005
828  * @tc.desc: Remove string space
829  * @tc.type: FUNC
830  * @tc.require:
831  */
HWTEST_F(UtilityTest, UtityTest_RemoveSpace_005, TestSize.Level1)832 HWTEST_F(UtilityTest, UtityTest_RemoveSpace_005, TestSize.Level1)
833 {
834     CALL_TEST_DEBUG;
835     std::string str = "    ";
836     Utility::RemoveSpace(str);
837     EXPECT_STREQ(str.c_str(), "");
838 }
839 
840 /**
841  * @tc.name: UtityTest_CopyNulstr_001
842  * @tc.desc: Copy string to target
843  * @tc.type: FUNC
844  * @tc.require:
845  */
HWTEST_F(UtilityTest, UtityTest_CopyNulstr_001, TestSize.Level1)846 HWTEST_F(UtilityTest, UtityTest_CopyNulstr_001, TestSize.Level1)
847 {
848     CALL_TEST_DEBUG;
849     char dest[] = "0";
850     size_t size = SIZE1;
851     char src[] = "abcdefghijklmnopqrst";
852     size_t len = Utility::CopyNulstr(dest, size, src);
853     EXPECT_EQ(len, size - 1);
854 }
855 
856 /**
857  * @tc.name: UtityTest_CopyNulstr_002
858  * @tc.desc: Copy string to target
859  * @tc.type: FUNC
860  * @tc.require:
861  */
HWTEST_F(UtilityTest, UtityTest_CopyNulstr_002, TestSize.Level1)862 HWTEST_F(UtilityTest, UtityTest_CopyNulstr_002, TestSize.Level1)
863 {
864     CALL_TEST_DEBUG;
865     char *dest = nullptr;
866     size_t size = SIZE2;
867     char *src = nullptr;
868     size_t len = Utility::CopyNulstr(dest, size, src);
869     EXPECT_EQ(len, 0);
870 }
871 
872 /**
873  * @tc.name: UtityTest_CopyNulstr_003
874  * @tc.desc: Copy string to target
875  * @tc.type: FUNC
876  * @tc.require:
877  */
HWTEST_F(UtilityTest, UtityTest_CopyNulstr_003, TestSize.Level1)878 HWTEST_F(UtilityTest, UtityTest_CopyNulstr_003, TestSize.Level1)
879 {
880     CALL_TEST_DEBUG;
881     char dest[] = {0};
882     size_t size = SIZE2;
883     char *src = nullptr;
884     size_t len = Utility::CopyNulstr(dest, size, src);
885     EXPECT_EQ(len, 0);
886 }
887 
888 /**
889  * @tc.name: UtityTest_CopyNulstr_004
890  * @tc.desc: Copy string to target
891  * @tc.type: FUNC
892  * @tc.require:
893  */
HWTEST_F(UtilityTest, UtityTest_CopyNulstr_004, TestSize.Level1)894 HWTEST_F(UtilityTest, UtityTest_CopyNulstr_004, TestSize.Level1)
895 {
896     CALL_TEST_DEBUG;
897     char *dest = nullptr;
898     size_t size = SIZE2;
899     char src[] = "dadaaaaaaaddsadada";
900     size_t len = Utility::CopyNulstr(dest, size, src);
901     EXPECT_EQ(len, 0);
902 }
903 
904 /**
905  * @tc.name: UtityTest_GetSysClockTime_001
906  * @tc.desc: Get system time
907  * @tc.type: FUNC
908  * @tc.require:
909  */
HWTEST_F(UtilityTest, UtityTest_GetSysClockTime_001, TestSize.Level1)910 HWTEST_F(UtilityTest, UtityTest_GetSysClockTime_001, TestSize.Level1)
911 {
912     CALL_TEST_DEBUG;
913     int64_t time = Utility::GetSysClockTime();
914     EXPECT_NE(time, 0);
915 }
916 
917 /**
918  * @tc.name: UtityTest_StartWith1_001
919  * @tc.desc:
920  * @tc.type: FUNC
921  * @tc.require:
922  */
HWTEST_F(UtilityTest, UtityTest_StartWith1_001, TestSize.Level1)923 HWTEST_F(UtilityTest, UtityTest_StartWith1_001, TestSize.Level1)
924 {
925     CALL_TEST_DEBUG;
926     const char *exampleStr = "HelloWorld";
927     const char *examplePrefix = "Hello";
928     bool ret = Utility::StartWith(exampleStr, examplePrefix);
929     ASSERT_TRUE(ret);
930 }
931 
932 /**
933  * @tc.name: UtityTest_StartWith1_002
934  * @tc.desc:
935  * @tc.type: FUNC
936  * @tc.require:
937  */
HWTEST_F(UtilityTest, UtityTest_StartWith1_002, TestSize.Level1)938 HWTEST_F(UtilityTest, UtityTest_StartWith1_002, TestSize.Level1)
939 {
940     CALL_TEST_DEBUG;
941     const char *exampleStr = "HelloWorld";
942     const char *examplePrefix = "HelloWorld";
943     bool ret = Utility::StartWith(exampleStr, examplePrefix);
944     ASSERT_TRUE(ret);
945 }
946 
947 /**
948  * @tc.name: UtityTest_StartWith1_003
949  * @tc.desc:
950  * @tc.type: FUNC
951  * @tc.require:
952  */
HWTEST_F(UtilityTest, UtityTest_StartWith1_003, TestSize.Level1)953 HWTEST_F(UtilityTest, UtityTest_StartWith1_003, TestSize.Level1)
954 {
955     CALL_TEST_DEBUG;
956     const char *exampleStr = "HelloWorld";
957     const char *examplePrefix = "";
958     bool ret = Utility::StartWith(exampleStr, examplePrefix);
959     ASSERT_FALSE(ret);
960 }
961 
962 /**
963  * @tc.name: UtityTest_StartWith1_004
964  * @tc.desc:
965  * @tc.type: FUNC
966  * @tc.require:
967  */
HWTEST_F(UtilityTest, UtityTest_StartWith1_004, TestSize.Level1)968 HWTEST_F(UtilityTest, UtityTest_StartWith1_004, TestSize.Level1)
969 {
970     CALL_TEST_DEBUG;
971     const char *exampleStr = "Hello";
972     const char *examplePrefix = "HelloWorld";
973     bool ret = Utility::StartWith(exampleStr, examplePrefix);
974     ASSERT_FALSE(ret);
975 }
976 
977 /**
978  * @tc.name: UtityTest_StartWith1_005
979  * @tc.desc:
980  * @tc.type: FUNC
981  * @tc.require:
982  */
HWTEST_F(UtilityTest, UtityTest_StartWith1_005, TestSize.Level1)983 HWTEST_F(UtilityTest, UtityTest_StartWith1_005, TestSize.Level1)
984 {
985     CALL_TEST_DEBUG;
986     const char *exampleStr = "";
987     const char *examplePrefix = "HelloWorld";
988     bool ret = Utility::StartWith(exampleStr, examplePrefix);
989     ASSERT_FALSE(ret);
990 }
991 
992 /**
993  * @tc.name: UtityTest_StartWith1_006
994  * @tc.desc:
995  * @tc.type: FUNC
996  * @tc.require:
997  */
HWTEST_F(UtilityTest, UtityTest_StartWith1_006, TestSize.Level1)998 HWTEST_F(UtilityTest, UtityTest_StartWith1_006, TestSize.Level1)
999 {
1000     CALL_TEST_DEBUG;
1001     const char *exampleStr = "";
1002     const char *examplePrefix = "";
1003     bool ret = Utility::StartWith(exampleStr, examplePrefix);
1004     ASSERT_FALSE(ret);
1005 }
1006 
1007 /**
1008  * @tc.name: UtityTest_StartWith2_001
1009  * @tc.desc:
1010  * @tc.type: FUNC
1011  * @tc.require:
1012  */
HWTEST_F(UtilityTest, UtityTest_StartWith2_001, TestSize.Level1)1013 HWTEST_F(UtilityTest, UtityTest_StartWith2_001, TestSize.Level1)
1014 {
1015     CALL_TEST_DEBUG;
1016     std::string exampleStr = "abc12345";
1017     std::string examplePrefix = "abc";
1018     bool ret = Utility::StartWith(exampleStr, examplePrefix);
1019     ASSERT_TRUE(ret);
1020 }
1021 
1022 /**
1023  * @tc.name: UtityTest_StartWith2_002
1024  * @tc.desc:
1025  * @tc.type: FUNC
1026  * @tc.require:
1027  */
HWTEST_F(UtilityTest, UtityTest_StartWith2_002, TestSize.Level1)1028 HWTEST_F(UtilityTest, UtityTest_StartWith2_002, TestSize.Level1)
1029 {
1030     CALL_TEST_DEBUG;
1031     std::string exampleStr = "abc";
1032     std::string examplePrefix = "abc";
1033     bool ret = Utility::StartWith(exampleStr, examplePrefix);
1034     ASSERT_TRUE(ret);
1035 }
1036 
1037 /**
1038  * @tc.name: UtityTest_StartWith2_003
1039  * @tc.desc:
1040  * @tc.type: FUNC
1041  * @tc.require:
1042  */
HWTEST_F(UtilityTest, UtityTest_StartWith2_003, TestSize.Level1)1043 HWTEST_F(UtilityTest, UtityTest_StartWith2_003, TestSize.Level1)
1044 {
1045     CALL_TEST_DEBUG;
1046     std::string exampleStr = "abc12345";
1047     std::string examplePrefix = "";
1048     bool ret = Utility::StartWith(exampleStr, examplePrefix);
1049     ASSERT_TRUE(ret);
1050 }
1051 
1052 /**
1053  * @tc.name: UtityTest_StartWith2_004
1054  * @tc.desc:
1055  * @tc.type: FUNC
1056  * @tc.require:
1057  */
HWTEST_F(UtilityTest, UtityTest_StartWith2_004, TestSize.Level1)1058 HWTEST_F(UtilityTest, UtityTest_StartWith2_004, TestSize.Level1)
1059 {
1060     CALL_TEST_DEBUG;
1061     std::string exampleStr = "abc";
1062     std::string examplePrefix = "abcdefg";
1063     bool ret = Utility::StartWith(exampleStr, examplePrefix);
1064     ASSERT_FALSE(ret);
1065 }
1066 
1067 /**
1068  * @tc.name: UtityTest_StartWith2_005
1069  * @tc.desc:
1070  * @tc.type: FUNC
1071  * @tc.require:
1072  */
HWTEST_F(UtilityTest, UtityTest_StartWith2_005, TestSize.Level1)1073 HWTEST_F(UtilityTest, UtityTest_StartWith2_005, TestSize.Level1)
1074 {
1075     CALL_TEST_DEBUG;
1076     std::string exampleStr = "";
1077     std::string examplePrefix = "abc";
1078     bool ret = Utility::StartWith(exampleStr, examplePrefix);
1079     ASSERT_FALSE(ret);
1080 }
1081 
1082 /**
1083  * @tc.name: UtityTest_StartWith2_006
1084  * @tc.desc:
1085  * @tc.type: FUNC
1086  * @tc.require:
1087  */
HWTEST_F(UtilityTest, UtityTest_StartWith2_006, TestSize.Level1)1088 HWTEST_F(UtilityTest, UtityTest_StartWith2_006, TestSize.Level1)
1089 {
1090     CALL_TEST_DEBUG;
1091     std::string exampleStr = "";
1092     std::string examplePrefix = "";
1093     bool ret = Utility::StartWith(exampleStr, examplePrefix);
1094     ASSERT_TRUE(ret);
1095 }
1096 
1097 /**
1098  * @tc.name: UtityTest_RemoveTrailingChars1_001
1099  * @tc.desc:
1100  * @tc.type: FUNC
1101  * @tc.require:
1102  */
HWTEST_F(UtilityTest, UtityTest_RemoveTrailingChars1_001, TestSize.Level1)1103 HWTEST_F(UtilityTest, UtityTest_RemoveTrailingChars1_001, TestSize.Level1)
1104 {
1105     CALL_TEST_DEBUG;
1106     char path2[] = "abcd";
1107     Utility::RemoveTrailingChars('d', path2);
1108     ASSERT_STREQ(path2, "abc");
1109 }
1110 
1111 /**
1112  * @tc.name: UtityTest_RemoveTrailingChars1_002
1113  * @tc.desc:
1114  * @tc.type: FUNC
1115  * @tc.require:
1116  */
HWTEST_F(UtilityTest, UtityTest_RemoveTrailingChars1_002, TestSize.Level1)1117 HWTEST_F(UtilityTest, UtityTest_RemoveTrailingChars1_002, TestSize.Level1)
1118 {
1119     CALL_TEST_DEBUG;
1120     char path2[] = "abcd";
1121     Utility::RemoveTrailingChars('d', path2);
1122     ASSERT_STREQ(path2, "abc");
1123 }
1124 
1125 /**
1126  * @tc.name: UtityTest_RemoveTrailingChars1_003
1127  * @tc.desc:
1128  * @tc.type: FUNC
1129  * @tc.require:
1130  */
HWTEST_F(UtilityTest, UtityTest_RemoveTrailingChars1_003, TestSize.Level1)1131 HWTEST_F(UtilityTest, UtityTest_RemoveTrailingChars1_003, TestSize.Level1)
1132 {
1133     CALL_TEST_DEBUG;
1134     char path2[] = "abacda";
1135     Utility::RemoveTrailingChars('a', path2);
1136     ASSERT_STREQ(path2, "abacd");
1137 }
1138 
1139 /**
1140  * @tc.name: UtityTest_RemoveTrailingChars1_004
1141  * @tc.desc:
1142  * @tc.type: FUNC
1143  * @tc.require:
1144  */
HWTEST_F(UtilityTest, UtityTest_RemoveTrailingChars1_004, TestSize.Level1)1145 HWTEST_F(UtilityTest, UtityTest_RemoveTrailingChars1_004, TestSize.Level1)
1146 {
1147     CALL_TEST_DEBUG;
1148     char path2[] = "abacda";
1149     Utility::RemoveTrailingChars('f', path2);
1150     ASSERT_STREQ(path2, "abacda");
1151 }
1152 
1153 /**
1154  * @tc.name: UtityTest_RemoveTrailingChars1_005
1155  * @tc.desc:
1156  * @tc.type: FUNC
1157  * @tc.require:
1158  */
HWTEST_F(UtilityTest, UtityTest_RemoveTrailingChars1_005, TestSize.Level1)1159 HWTEST_F(UtilityTest, UtityTest_RemoveTrailingChars1_005, TestSize.Level1)
1160 {
1161     CALL_TEST_DEBUG;
1162     char path2[] = "";
1163     Utility::RemoveTrailingChars('f', path2);
1164     ASSERT_STREQ(path2, "");
1165 }
1166 
1167 /**
1168  * @tc.name: UtityTest_RemoveTrailingChars2_001
1169  * @tc.desc:
1170  * @tc.type: FUNC
1171  * @tc.require:
1172  */
HWTEST_F(UtilityTest, UtityTest_RemoveTrailingChars2_001, TestSize.Level1)1173 HWTEST_F(UtilityTest, UtityTest_RemoveTrailingChars2_001, TestSize.Level1)
1174 {
1175     CALL_TEST_DEBUG;
1176     const std::string path1 = "cd";
1177     std::string path2 = "abcd";
1178     Utility::RemoveTrailingChars(path1, path2);
1179     ASSERT_STREQ(path2.c_str(), "ab");
1180 }
1181 
1182 /**
1183  * @tc.name: UtityTest_RemoveTrailingChars2_002
1184  * @tc.desc:
1185  * @tc.type: FUNC
1186  * @tc.require:
1187  */
HWTEST_F(UtilityTest, UtityTest_RemoveTrailingChars2_002, TestSize.Level1)1188 HWTEST_F(UtilityTest, UtityTest_RemoveTrailingChars2_002, TestSize.Level1)
1189 {
1190     CALL_TEST_DEBUG;
1191     const std::string path1 = "c";
1192     std::string path2 = "abdc";
1193     Utility::RemoveTrailingChars(path1, path2);
1194     ASSERT_STREQ(path2.c_str(), "abd");
1195 }
1196 
1197 
1198 /**
1199  * @tc.name: UtityTest_RemoveTrailingChars2_003
1200  * @tc.desc:
1201  * @tc.type: FUNC
1202  * @tc.require:
1203  */
HWTEST_F(UtilityTest, UtityTest_RemoveTrailingChars2_003, TestSize.Level1)1204 HWTEST_F(UtilityTest, UtityTest_RemoveTrailingChars2_003, TestSize.Level1)
1205 {
1206     CALL_TEST_DEBUG;
1207     const std::string path1 = "a";
1208     std::string path2 = "abacda";
1209     Utility::RemoveTrailingChars(path1, path2);
1210     ASSERT_STREQ(path2.c_str(), "abacd");
1211 }
1212 
1213 /**
1214  * @tc.name: UtityTest_RemoveTrailingChars2_004
1215  * @tc.desc:
1216  * @tc.type: FUNC
1217  * @tc.require:
1218  */
HWTEST_F(UtilityTest, UtityTest_RemoveTrailingChars2_004, TestSize.Level1)1219 HWTEST_F(UtilityTest, UtityTest_RemoveTrailingChars2_004, TestSize.Level1)
1220 {
1221     CALL_TEST_DEBUG;
1222     const std::string path1 = "e";
1223     std::string path2 = "abc";
1224     Utility::RemoveTrailingChars(path1, path2);
1225     ASSERT_STREQ(path2.c_str(), "abc");
1226 }
1227 
1228 /**
1229  * @tc.name: UtityTest_RemoveTrailingChars2_005
1230  * @tc.desc:
1231  * @tc.type: FUNC
1232  * @tc.require:
1233  */
HWTEST_F(UtilityTest, UtityTest_RemoveTrailingChars2_005, TestSize.Level1)1234 HWTEST_F(UtilityTest, UtityTest_RemoveTrailingChars2_005, TestSize.Level1)
1235 {
1236     CALL_TEST_DEBUG;
1237     const std::string path1 = "";
1238     std::string path2 = "abc";
1239     Utility::RemoveTrailingChars(path1, path2);
1240     ASSERT_STREQ(path2.c_str(), "abc");
1241 }
1242 } // namespace DeviceStatus
1243 } // namespace Msdp
1244 } // namespace OHOS
1245