path_util_test.cc
Go to the documentation of this file.
1 //
2 // Copyright 2019 The Abseil Authors.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // https://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
17 
18 #include "gtest/gtest.h"
19 
20 namespace {
21 
22 namespace flags = absl::flags_internal;
23 
24 TEST(FlagsPathUtilTest, TestBasename) {
25  EXPECT_EQ(flags::Basename(""), "");
26  EXPECT_EQ(flags::Basename("a.cc"), "a.cc");
27  EXPECT_EQ(flags::Basename("dir/a.cc"), "a.cc");
28  EXPECT_EQ(flags::Basename("dir1/dir2/a.cc"), "a.cc");
29  EXPECT_EQ(flags::Basename("../dir1/dir2/a.cc"), "a.cc");
30  EXPECT_EQ(flags::Basename("/dir1/dir2/a.cc"), "a.cc");
31  EXPECT_EQ(flags::Basename("/dir1/dir2/../dir3/a.cc"), "a.cc");
32 }
33 
34 // --------------------------------------------------------------------
35 
36 TEST(FlagsPathUtilTest, TestPackage) {
37  EXPECT_EQ(flags::Package(""), "");
38  EXPECT_EQ(flags::Package("a.cc"), "");
39  EXPECT_EQ(flags::Package("dir/a.cc"), "dir/");
40  EXPECT_EQ(flags::Package("dir1/dir2/a.cc"), "dir1/dir2/");
41  EXPECT_EQ(flags::Package("../dir1/dir2/a.cc"), "../dir1/dir2/");
42  EXPECT_EQ(flags::Package("/dir1/dir2/a.cc"), "/dir1/dir2/");
43  EXPECT_EQ(flags::Package("/dir1/dir2/../dir3/a.cc"), "/dir1/dir2/../dir3/");
44 }
45 
46 } // namespace
constexpr const char * Basename(const char *fname, int offset)
Definition: raw_logging.h:119
absl::string_view Package(absl::string_view filename)
Definition: path_util.h:49
TEST(Symbolize, Unimplemented)


abseil_cpp
Author(s):
autogenerated on Mon Feb 28 2022 21:31:19