[llvm] [SetOperations] Support set containers with remove_if (PR #96613)

Jakub Kuderski via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 25 07:05:33 PDT 2024


================
@@ -65,6 +66,16 @@ TEST(SetOperationsTest, SetIntersect) {
   // is empty as they are non-overlapping.
   EXPECT_THAT(Set1, IsEmpty());
   EXPECT_EQ(ExpectedSet2, Set2);
+
+  // Check that set_intersect works on SetVector via remove_if.
+  SmallSetVector<int, 4> SV;
+  SV.insert(3);
+  SV.insert(6);
+  SV.insert(4);
+  SV.insert(5);
+  set_intersect(SV, Set2);
+  // SV should contain only 6 and 5 now.
+  EXPECT_EQ(SV.getArrayRef(), ArrayRef({6, 5}));
----------------
kuhar wrote:

Since this file already uses gmock:
```suggestion
  EXPECT_THAT(SV, ElementsAre(6, 5));
```

https://github.com/llvm/llvm-project/pull/96613


More information about the llvm-commits mailing list