llvm.org GIT mirror llvm / 46a1e8b
Add unittests for empty bitvectors. Addendum to r292575 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292817 91177308-0d34-0410-b5e6-96231b3b80d8 Matthias Braun 2 years ago
1 changed file(s) with 37 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
424424 EXPECT_EQ(C, B);
425425 }
426426
427 template
428 static void testEmpty(const TypeParam &A) {
429 EXPECT_TRUE(A.empty());
430 EXPECT_EQ((size_t)0, A.size());
431 EXPECT_EQ((size_t)0, A.count());
432 EXPECT_FALSE(A.any());
433 EXPECT_TRUE(A.all());
434 EXPECT_TRUE(A.none());
435 EXPECT_EQ(-1, A.find_first());
436 EXPECT_EQ(A, TypeParam());
437 }
438
439 /// Tests whether BitVector behaves well with Bits==nullptr, Capacity==0
440 TYPED_TEST(BitVectorTest, EmptyVector) {
441 TypeParam A;
442 testEmpty(A);
443
444 TypeParam B;
445 B.reset();
446 testEmpty(B);
447
448 TypeParam C;
449 C.clear();
450 testEmpty(C);
451
452 TypeParam D(A);
453 testEmpty(D);
454
455 TypeParam E;
456 E = A;
457 testEmpty(E);
458
459 TypeParam F;
460 E.reset(A);
461 testEmpty(E);
462 }
463
427464 }
428465 #endif