[llvm] [ADT] Add unit tests for set_subtract (PR #99561)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 18 16:08:14 PDT 2024
================
@@ -199,6 +201,42 @@ TEST(SetOperationsTest, SetSubtract) {
EXPECT_EQ(ExpectedSet2, Set2);
}
+TEST(SetOperationsTest, SetSubtractSmallPtrSet) {
+ int A[4];
+
+ // Set1.size() < Set2.size()
+ SmallPtrSet<int *, 4> Set1 = {&A[0], &A[1]};
+ SmallPtrSet<int *, 4> Set2 = {&A[1], &A[2], &A[3]};
+ SmallPtrSet<int *, 4> ExpectedSet1 = {&A[0]};
+ set_subtract(Set1, Set2);
+ EXPECT_EQ(ExpectedSet1, Set1);
+
+ // Set1.size() > Set2.size()
+ Set1 = {&A[0], &A[1], &A[2]};
+ Set2 = {&A[0], &A[2]};
+ ExpectedSet1 = {&A[1]};
+ set_subtract(Set1, Set2);
+ EXPECT_EQ(ExpectedSet1, Set1);
----------------
kazutakahirata wrote:
I've switched to `testing::UnorderedEelementsAre` in the latest iteration. Thanks!
https://github.com/llvm/llvm-project/pull/99561
More information about the llvm-commits
mailing list