[PATCH] D70528: [NFC] ASSERT_EQ before accessing items in containers

Kirill Bobyrev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 21 03:31:37 PST 2019


kbobyrev updated this revision to Diff 230417.
kbobyrev marked an inline comment as done.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70528/new/

https://reviews.llvm.org/D70528

Files:
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -709,7 +709,10 @@
 
   auto Parsed = TU.build();
   for (const auto &D : Parsed.getDiagnostics()) {
-    EXPECT_EQ(D.Fixes.size(), 1u);
+    if (D.Fixes.size() != 1) {
+      ADD_FAILURE() << "D.Fixes.size() != 1";
+      continue;
+    }
     EXPECT_EQ(D.Fixes[0].Message,
               std::string("Add include \"a.h\" for symbol X"));
   }
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1874,7 +1874,10 @@
     Annotations TestCode(Text);
     auto Results = completions(Server, TestCode.code(), TestCode.point());
 
-    EXPECT_EQ(Results.Completions.size(), 1u);
+    if (Results.Completions.size() != 1) {
+      ADD_FAILURE() << "Results.Completions.size() != 1";
+      continue;
+    }
     EXPECT_THAT(Results.Completions.front().CompletionTokenRange,
                 TestCode.range());
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70528.230417.patch
Type: text/x-patch
Size: 1269 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191121/aff9d970/attachment.bin>


More information about the cfe-commits mailing list