using namespace llvm;
-// SmallPtrSet swapping test.
+TEST(SmallPtrSetTest, Assignment) {
+ int buf[8];
+ for (int i = 0; i < 8; ++i)
+ buf[i] = 0;
+
+ SmallPtrSet<int *, 4> s1;
+ s1.insert(&buf[0]);
+ s1.insert(&buf[1]);
+
+ SmallPtrSet<int *, 4> s2;
+ (s2 = s1).insert(&buf[2]);
+
+ // Self assign as well.
+ (s2 = s2).insert(&buf[3]);
+
+ s1 = s2;
+ EXPECT_EQ(4U, s1.size());
+ for (int i = 0; i < 8; ++i)
+ if (i < 4)
+ EXPECT_TRUE(s1.count(&buf[i]));
+ else
+ EXPECT_FALSE(s1.count(&buf[i]));
+}
+
TEST(SmallPtrSetTest, GrowthTest) {
int i;
int buf[8];
else
EXPECT_FALSE(s3.count(&buf[i]));
+ // Move assign to the moved-from object.
s1 = llvm_move(s3);
EXPECT_EQ(4U, s1.size());
for (int i = 0; i < 8; ++i)