summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKadir Cetinkaya <kadircet@google.com>2019-04-24 09:42:53 +0000
committerKadir Cetinkaya <kadircet@google.com>2019-04-24 09:42:53 +0000
commit3780ed783f7dcc8df497419fde673cdf67924726 (patch)
tree581a7664988b8101f7370907863d54cb1bae9428
parent1f556bcaac971a9e696baf4b3bab9c5b13bcd36a (diff)
[clangd] Fix handling of include paths in windows tests
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@359079 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--unittests/clangd/CodeCompleteTests.cpp13
-rw-r--r--unittests/clangd/HeadersTests.cpp7
2 files changed, 12 insertions, 8 deletions
diff --git a/unittests/clangd/CodeCompleteTests.cpp b/unittests/clangd/CodeCompleteTests.cpp
index 7bf5c870..e5ba7d4e 100644
--- a/unittests/clangd/CodeCompleteTests.cpp
+++ b/unittests/clangd/CodeCompleteTests.cpp
@@ -22,6 +22,7 @@
#include "clang/Sema/CodeCompleteConsumer.h"
#include "clang/Tooling/CompilationDatabase.h"
#include "llvm/Support/Error.h"
+#include "llvm/Support/Path.h"
#include "llvm/Testing/Support/Error.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
@@ -699,11 +700,13 @@ TEST(CompletionTest, DynamicIndexIncludeInsertion) {
Server.addDocument(testPath("foo_impl.cpp"), FileContent);
// Wait for the dynamic index being built.
ASSERT_TRUE(Server.blockUntilIdleForTest());
- EXPECT_THAT(
- completions(Server, "Foo^ foo;").Completions,
- ElementsAre(AllOf(Named("Foo"),
- HasInclude('"' + testPath("foo_header.h") + '"'),
- InsertInclude())));
+ EXPECT_THAT(completions(Server, "Foo^ foo;").Completions,
+ ElementsAre(AllOf(Named("Foo"),
+ HasInclude('"' +
+ llvm::sys::path::convert_to_slash(
+ testPath("foo_header.h")) +
+ '"'),
+ InsertInclude())));
}
TEST(CompletionTest, DynamicIndexMultiFile) {
diff --git a/unittests/clangd/HeadersTests.cpp b/unittests/clangd/HeadersTests.cpp
index 28f4d7b1..e1591abb 100644
--- a/unittests/clangd/HeadersTests.cpp
+++ b/unittests/clangd/HeadersTests.cpp
@@ -15,6 +15,7 @@
#include "clang/Frontend/CompilerInvocation.h"
#include "clang/Frontend/FrontendActions.h"
#include "clang/Lex/PreprocessorOptions.h"
+#include "llvm/Support/Path.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
@@ -221,7 +222,8 @@ TEST_F(HeadersTest, ShortenedInclude) {
}
TEST_F(HeadersTest, NotShortenedInclude) {
- std::string BarHeader = testPath("sub-2/bar.h");
+ std::string BarHeader =
+ llvm::sys::path::convert_to_slash(testPath("sub-2/bar.h"));
EXPECT_EQ(calculate(BarHeader, ""), "\"" + BarHeader + "\"");
}
@@ -265,8 +267,7 @@ TEST(Headers, NoHeaderSearchInfo) {
auto Inserting = HeaderFile{HeaderPath, /*Verbatim=*/false};
auto Verbatim = HeaderFile{"<x>", /*Verbatim=*/true};
- EXPECT_EQ(Inserter.calculateIncludePath(Inserting),
- "\"" + HeaderPath + "\"");
+ EXPECT_EQ(Inserter.calculateIncludePath(Inserting), "\"" + HeaderPath + "\"");
EXPECT_EQ(Inserter.shouldInsertInclude(HeaderPath, Inserting), false);
EXPECT_EQ(Inserter.calculateIncludePath(Verbatim), "<x>");