1 /*
2 * Copyright (c) 2022 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 "ans_log_wrapper.h"
17
18 #include <gtest/gtest.h>
19
20 using namespace testing::ext;
21 namespace OHOS {
22 namespace Notification {
23
24 class AnsLogTest : public testing::Test {
25 public:
26 static void SetUpTestCase();
27 static void TearDownTestCase();
28 void SetUp();
29 void TearDown();
30 };
31
SetUpTestCase()32 void AnsLogTest::SetUpTestCase()
33 {}
34
TearDownTestCase()35 void AnsLogTest::TearDownTestCase()
36 {}
37
SetUp()38 void AnsLogTest::SetUp()
39 {}
40
TearDown()41 void AnsLogTest::TearDown()
42 {}
43
44 /*
45 * @tc.name: AnsLogTest_001
46 * @tc.desc: test GetBriefFileName function
47 * @tc.type: FUNC
48 * @tc.require: issueI5UI8T
49 */
50 HWTEST_F(AnsLogTest, AnsLogTest_001, TestSize.Level1)
51 {
52 std::string fileName = "../function/EventFwk/test.cpp";
53 std::string exceptStr = "test.cpp";
54
55 std::string result = AnsLogWrapper::GetBriefFileName(fileName.c_str());
56 EXPECT_EQ(exceptStr, result);
57 }
58
59 /*
60 * @tc.name: AnsLogTest_002
61 * @tc.desc: test GetBriefFileName function
62 * @tc.type: FUNC
63 * @tc.require: issueI5UI8T
64 */
65 HWTEST_F(AnsLogTest, AnsLogTest_002, TestSize.Level1)
66 {
67 std::string fileName = "test.cpp";
68 std::string exceptStr = "";
69
70 std::string result = AnsLogWrapper::GetBriefFileName(fileName.c_str());
71 EXPECT_EQ(exceptStr, result);
72
73 fileName = "";
74 result = AnsLogWrapper::GetBriefFileName(fileName.c_str());
75 EXPECT_EQ(exceptStr, result);
76
77 result = AnsLogWrapper::GetBriefFileName(nullptr);
78 EXPECT_EQ(exceptStr, result);
79 }
80 }
81 }