1ecea7218SKadir Cetinkaya //===-- PathTests.cpp -------------------------------------------*- C++ -*-===//
2ecea7218SKadir Cetinkaya //
3ecea7218SKadir Cetinkaya // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4ecea7218SKadir Cetinkaya // See https://llvm.org/LICENSE.txt for license information.
5ecea7218SKadir Cetinkaya // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6ecea7218SKadir Cetinkaya //
7ecea7218SKadir Cetinkaya //===----------------------------------------------------------------------===//
8ecea7218SKadir Cetinkaya
9*cdef5a71SKadir Cetinkaya #include "TestFS.h"
10ecea7218SKadir Cetinkaya #include "support/Path.h"
11ecea7218SKadir Cetinkaya #include "gmock/gmock.h"
12ecea7218SKadir Cetinkaya #include "gtest/gtest.h"
13ecea7218SKadir Cetinkaya
14ecea7218SKadir Cetinkaya namespace clang {
15ecea7218SKadir Cetinkaya namespace clangd {
16ecea7218SKadir Cetinkaya namespace {
TEST(PathTests,IsAncestor)17ecea7218SKadir Cetinkaya TEST(PathTests, IsAncestor) {
18*cdef5a71SKadir Cetinkaya EXPECT_TRUE(pathStartsWith(testPath("foo"), testPath("foo")));
19*cdef5a71SKadir Cetinkaya EXPECT_TRUE(pathStartsWith(testPath("foo/"), testPath("foo")));
20ecea7218SKadir Cetinkaya
21*cdef5a71SKadir Cetinkaya EXPECT_FALSE(pathStartsWith(testPath("foo"), testPath("fooz")));
22*cdef5a71SKadir Cetinkaya EXPECT_FALSE(pathStartsWith(testPath("foo/"), testPath("fooz")));
23ecea7218SKadir Cetinkaya
24*cdef5a71SKadir Cetinkaya EXPECT_TRUE(pathStartsWith(testPath("foo"), testPath("foo/bar")));
25*cdef5a71SKadir Cetinkaya EXPECT_TRUE(pathStartsWith(testPath("foo/"), testPath("foo/bar")));
26ecea7218SKadir Cetinkaya
27ecea7218SKadir Cetinkaya #ifdef CLANGD_PATH_CASE_INSENSITIVE
28*cdef5a71SKadir Cetinkaya EXPECT_TRUE(pathStartsWith(testPath("fOo"), testPath("foo/bar")));
29*cdef5a71SKadir Cetinkaya EXPECT_TRUE(pathStartsWith(testPath("foo"), testPath("fOo/bar")));
30ecea7218SKadir Cetinkaya #else
31*cdef5a71SKadir Cetinkaya EXPECT_FALSE(pathStartsWith(testPath("fOo"), testPath("foo/bar")));
32*cdef5a71SKadir Cetinkaya EXPECT_FALSE(pathStartsWith(testPath("foo"), testPath("fOo/bar")));
33ecea7218SKadir Cetinkaya #endif
34ecea7218SKadir Cetinkaya }
35ecea7218SKadir Cetinkaya } // namespace
36ecea7218SKadir Cetinkaya } // namespace clangd
37ecea7218SKadir Cetinkaya } // namespace clang
38