38 lines · cpp
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-exception6//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_INSENSITIVE28 EXPECT_TRUE(pathStartsWith(testPath("fOo"), testPath("foo/bar")));29 EXPECT_TRUE(pathStartsWith(testPath("foo"), testPath("fOo/bar")));30#else31 EXPECT_FALSE(pathStartsWith(testPath("fOo"), testPath("foo/bar")));32 EXPECT_FALSE(pathStartsWith(testPath("foo"), testPath("fOo/bar")));33#endif34}35} // namespace36} // namespace clangd37} // namespace clang38