1 /*
2  * Copyright (C) 2019 The Android Open Source Project
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  *      http://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  */
16 
17 #include "../path.h"
18 
19 #include <gtest/gtest.h>
20 
21 using namespace std::literals;
22 
23 namespace android::incremental::path {
24 
TEST(Path,Normalize)25 TEST(Path, Normalize) {
26     EXPECT_STREQ("", normalize("").c_str());
27     EXPECT_STREQ("/data/app/com.snapchat.android-evzhnJDgPOq8VcxwEkSY5g==/base.apk",
28                  normalize("/data/app/com.snapchat.android-evzhnJDgPOq8VcxwEkSY5g==/base.apk")
29                          .c_str());
30     EXPECT_STREQ("/a/b", normalize("/a/c/../b").c_str());
31 }
32 
TEST(Path,Comparator)33 TEST(Path, Comparator) {
34     EXPECT_TRUE(PathLess()("/a", "/aa"));
35     EXPECT_TRUE(PathLess()("/a/b", "/aa/b"));
36     EXPECT_TRUE(PathLess()("/a", "/a/b"));
37     EXPECT_TRUE(PathLess()("/a/b"sv, "/a\0"sv));
38     EXPECT_TRUE(!PathLess()("/aa/b", "/a/b"));
39     EXPECT_TRUE(!PathLess()("/a/b", "/a/b"));
40     EXPECT_TRUE(!PathLess()("/a/b", "/a"));
41 }
42 
43 } // namespace android::incremental::path
44