1 // Copyright (C) 2020 The Android Open Source Project
2 //
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 #include "utils/header_abi_util.h"
16
17 #include <gtest/gtest.h>
18
19
20 namespace header_checker {
21 namespace utils {
22
23
TEST(CollectExportedHeadersTest,NormalizeAbsolutePaths)24 TEST(CollectExportedHeadersTest, NormalizeAbsolutePaths) {
25 const std::string root = "/root/dir";
26 EXPECT_EQ("", NormalizePath(root, root));
27 EXPECT_EQ("/unit/test", NormalizePath("/unit/test", root));
28 EXPECT_EQ("/root/unit/test", NormalizePath(root + "/../unit/test", root));
29 }
30
31
TEST(CollectExportedHeadersTest,NormalizeCwdPaths)32 TEST(CollectExportedHeadersTest, NormalizeCwdPaths) {
33 const std::string cwd = GetCwd();
34 ASSERT_NE("", cwd);
35 EXPECT_EQ("", NormalizePath("", cwd));
36 EXPECT_EQ("unit/test", NormalizePath("./unit/test/.", cwd));
37 EXPECT_EQ("unit/test", NormalizePath("unit//test//", cwd));
38 EXPECT_EQ("test", NormalizePath("unit/../test", cwd));
39 EXPECT_EQ("unit/test", NormalizePath(cwd + "/unit/test", cwd));
40 EXPECT_EQ('/', NormalizePath("../unit/test", cwd)[0]);
41 }
42
43
44 } // namespace utils
45 } // namespace header_checker
46