kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82729

Files:
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp

Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -100,15 +100,16 @@
 }
 
 TEST_F(WorkspaceSymbolsTest, Globals) {
-  addFile("foo.h", R"cpp(
+  FS.Files["foo.h"] = R"cpp(
       int global_var;
 
       int global_func();
 
-      struct GlobalStruct {};)cpp");
+      struct GlobalStruct {};)cpp";
+
+  addFile("foo.h", FS.Files["foo.h"]);
   addFile("foo.cpp", R"cpp(
-      #include "foo.h"
-      )cpp");
+      #include "foo.h")cpp");
   EXPECT_THAT(getSymbols("global"),
               UnorderedElementsAre(
                   AllOf(QName("GlobalStruct"), WithKind(SymbolKind::Struct)),
@@ -117,10 +118,11 @@
 }
 
 TEST_F(WorkspaceSymbolsTest, Unnamed) {
-  addFile("foo.h", R"cpp(
+  FS.Files["foo.h"] = R"cpp(
       struct {
         int InUnnamed;
-      } UnnamedStruct;)cpp");
+      } UnnamedStruct;)cpp";
+  addFile("foo.h", FS.Files["foo.h"]);
   addFile("foo.cpp", R"cpp(
       #include "foo.h"
       )cpp");
@@ -141,14 +143,14 @@
 }
 
 TEST_F(WorkspaceSymbolsTest, Namespaces) {
-  addFile("foo.h", R"cpp(
+  FS.Files["foo.h"] = R"cpp(
       namespace ans1 {
         int ai1;
       namespace ans2 {
         int ai2;
       }
-      }
-      )cpp");
+      })cpp";
+  addFile("foo.h", FS.Files["foo.h"]);
   addFile("foo.cpp", R"cpp(
       #include "foo.h"
       )cpp");
@@ -178,24 +180,20 @@
 }
 
 TEST_F(WorkspaceSymbolsTest, MultiFile) {
-  addFile("foo.h", R"cpp(
-      int foo() {
-      }
-      )cpp");
-  addFile("foo2.h", R"cpp(
-      int foo2() {
-      }
-      )cpp");
+  FS.Files["foo.h"] = "int foo() {}";
+  FS.Files["foo2.h"] = "int foo2() {}";
+
+  addFile("foo.h", FS.Files["foo.h"]);
+  addFile("foo2.h", FS.Files["foo2.h"]);
   addFile("foo.cpp", R"cpp(
       #include "foo.h"
-      #include "foo2.h"
-      )cpp");
+      #include "foo2.h")cpp");
   EXPECT_THAT(getSymbols("foo"),
               UnorderedElementsAre(QName("foo"), QName("foo2")));
 }
 
 TEST_F(WorkspaceSymbolsTest, GlobalNamespaceQueries) {
-  addFile("foo.h", R"cpp(
+  FS.Files["foo.h"] = R"cpp(
       int foo() {
       }
       class Foo {
@@ -204,8 +202,8 @@
       namespace ns {
       int foo2() {
       }
-      }
-      )cpp");
+      })cpp";
+  addFile("foo.h", FS.Files["foo.h"]);
   addFile("foo.cpp", R"cpp(
       #include "foo.h"
       )cpp");
@@ -219,7 +217,7 @@
 }
 
 TEST_F(WorkspaceSymbolsTest, Enums) {
-  addFile("foo.h", R"cpp(
+  FS.Files["foo.h"] = R"cpp(
     enum {
       Red
     };
@@ -239,8 +237,8 @@
       enum class Color4 {
         White
       };
-    }
-      )cpp");
+    })cpp";
+  addFile("foo.h", FS.Files["foo.h"]);
   addFile("foo.cpp", R"cpp(
       #include "foo.h"
       )cpp");
@@ -259,21 +257,21 @@
 }
 
 TEST_F(WorkspaceSymbolsTest, Ranking) {
-  addFile("foo.h", R"cpp(
+  FS.Files["foo.h"] = R"cpp(
       namespace ns{}
       void func();
-      )cpp");
+      )cpp";
+  addFile("foo.h", FS.Files["foo.h"]);
   addFile("foo.cpp", R"cpp(
-      #include "foo.h"
-      )cpp");
+      #include "foo.h")cpp");
   EXPECT_THAT(getSymbols("::"), ElementsAre(QName("func"), QName("ns")));
 }
 
 TEST_F(WorkspaceSymbolsTest, WithLimit) {
-  addFile("foo.h", R"cpp(
+  FS.Files["foo.h"] = R"cpp(
       int foo;
-      int foo2;
-      )cpp");
+      int foo2;)cpp";
+  addFile("foo.h", FS.Files["foo.h"]);
   addFile("foo.cpp", R"cpp(
       #include "foo.h"
       )cpp");
@@ -447,13 +445,13 @@
 }
 
 TEST_F(DocumentSymbolsTest, ExternSymbol) {
+  FS.Files["foo.h"] = R"cpp(
+      extern int var;)cpp";
+
+  addFile(testPath("foo.h"), FS.Files["foo.h"]);
   std::string FilePath = testPath("foo.cpp");
-  addFile(testPath("foo.h"), R"cpp(
-      extern int var;
-      )cpp");
   addFile(FilePath, R"cpp(
-      #include "foo.h"
-      )cpp");
+      #include "foo.h")cpp");
 
   EXPECT_THAT(getSymbols(FilePath), IsEmpty());
 }
@@ -488,19 +486,17 @@
 }
 
 TEST_F(DocumentSymbolsTest, InHeaderFile) {
-  addFile(testPath("bar.h"), R"cpp(
-      int foo() {
-      }
-      )cpp");
-  std::string FilePath = testPath("foo.h");
-  addFile(FilePath, R"cpp(
+  FS.Files["bar.h"] = R"cpp(
+      int foo() {})cpp";
+  FS.Files["foo.h"] = R"cpp(
       #include "bar.h"
-      int test() {
-      }
-      )cpp");
+      int test() {})cpp";
+
+  std::string FilePath = testPath("foo.h");
+  addFile(testPath("bar.h"), FS.Files["bar.h"]);
+  addFile(FilePath, FS.Files["foo.h"]);
   addFile(testPath("foo.cpp"), R"cpp(
-      #include "foo.h"
-      )cpp");
+      #include "foo.h")cpp");
   EXPECT_THAT(getSymbols(FilePath), ElementsAre(WithName("test")));
 }
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to