clang-tools 20.0.0git
PathTests.cpp
Go to the documentation of this file.
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
bool pathStartsWith(PathRef Ancestor, PathRef Path, llvm::sys::path::Style Style)
Checks if Ancestor is a proper ancestor of Path.
Definition: Path.cpp:36
std::string testPath(PathRef File, llvm::sys::path::Style Style)
Definition: TestFS.cpp:93
TEST(BackgroundQueueTest, Priority)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//