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 "utils_log.h" 19 20 namespace OHOS::Test { 21 using namespace testing; 22 using namespace testing::ext; 23 using namespace std; 24 25 class UtilsLogTest : public testing::Test { 26 public: 27 static void SetUpTestCase(void); 28 static void TearDownTestCase(void); 29 void SetUp(); 30 void TearDown(); 31 }; SetUpTestCase(void)32void UtilsLogTest::SetUpTestCase(void) 33 { 34 GTEST_LOG_(INFO) << "SetUpTestCase"; 35 } 36 TearDownTestCase(void)37void UtilsLogTest::TearDownTestCase(void) 38 { 39 GTEST_LOG_(INFO) << "TearDownTestCase"; 40 } 41 SetUp(void)42void UtilsLogTest::SetUp(void) 43 { 44 GTEST_LOG_(INFO) << "SetUp"; 45 } 46 TearDown(void)47void UtilsLogTest::TearDown(void) 48 { 49 GTEST_LOG_(INFO) << "TearDown"; 50 } 51 52 /** 53 * @tc.name: GetFileNameFromFullPathTest 54 * @tc.desc: Verify the GetFileNameFromFullPath function 55 * @tc.type: FUNC 56 * @tc.require: SR000HRKKA 57 */ 58 HWTEST_F(UtilsLogTest, GetFileNameFromFullPathTest, TestSize.Level1) 59 { 60 GTEST_LOG_(INFO) << "GetFileNameFromFullPathTest Start"; 61 try { 62 const char *str1 = "test_path"; 63 std::string out = ""; 64 std::string ret = GetFileNameFromFullPath(str1); 65 EXPECT_STREQ(ret.c_str(), out.c_str()); 66 const char *str2 = "test_path/1.txt"; 67 out = "1.txt"; 68 ret = GetFileNameFromFullPath(str2); 69 EXPECT_STREQ(ret.c_str(), out.c_str()); 70 } catch (...) { 71 EXPECT_TRUE(false); 72 GTEST_LOG_(INFO) << "GetFileNameFromFullPathTest FAILED"; 73 } 74 GTEST_LOG_(INFO) << "GetFileNameFromFullPathTest End"; 75 } 76 } // namespace OHOS::Test 77