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

source code of clang-tools-extra/clangd/unittests/support/PathTests.cpp