diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-05-08 23:17:08 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2020-05-08 23:33:15 +0000 |
commit | 1435d93b3d22f5c3819761246c564d6669cac54b (patch) | |
tree | 11525f1af326541e88f42493996b5eb7942309d2 /searchlib/src/tests/common | |
parent | 4b071b048ee01b58ef920899a64e928bbb0d88cf (diff) |
Follow up on code PR comments.
Diffstat (limited to 'searchlib/src/tests/common')
-rw-r--r-- | searchlib/src/tests/common/bitvector/bitvector_test.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/searchlib/src/tests/common/bitvector/bitvector_test.cpp b/searchlib/src/tests/common/bitvector/bitvector_test.cpp index a0e46870741..499db526dbe 100644 --- a/searchlib/src/tests/common/bitvector/bitvector_test.cpp +++ b/searchlib/src/tests/common/bitvector/bitvector_test.cpp @@ -312,23 +312,23 @@ setEveryNthBit(uint32_t n, BitVector & bv, uint32_t offset, uint32_t end) { bv.invalidateCachedCount(); } BitVector::UP -createEveryNthBitSet(uint32_t n, uint32_t end) { - BitVector::UP bv(BitVector::create(0, end)); - setEveryNthBit(n, *bv, 0, end); +createEveryNthBitSet(uint32_t n, uint32_t offset, uint32_t sz) { + BitVector::UP bv(BitVector::create(offset, offset + sz)); + setEveryNthBit(n, *bv, offset, offset + sz); return bv; } template<typename Func> void -verifyThatLongerWithShorterWorksAsZeroPadded(uint32_t sz1, uint32_t sz2, Func func) { - BitVector::UP aLarger = createEveryNthBitSet(2, sz2); +verifyThatLongerWithShorterWorksAsZeroPadded(uint32_t offset, uint32_t sz1, uint32_t sz2, Func func) { + BitVector::UP aLarger = createEveryNthBitSet(2, offset, sz2); - BitVector::UP bSmall = createEveryNthBitSet(3, sz1); - BitVector::UP bLarger = createEveryNthBitSet(3, sz2); - bLarger->clearInterval(sz1, sz2); + BitVector::UP bSmall = createEveryNthBitSet(3, 0, offset + sz1); + BitVector::UP bLarger = createEveryNthBitSet(3, 0, offset + sz2); + bLarger->clearInterval(offset + sz1, offset + sz2); EXPECT_EQUAL(bSmall->countTrueBits(), bLarger->countTrueBits()); - BitVector::UP aLarger2 = BitVector::create(*aLarger); + BitVector::UP aLarger2 = BitVector::create(*aLarger, aLarger->getStartIndex(), aLarger->size()); EXPECT_TRUE(*aLarger == *aLarger2); func(*aLarger, *bLarger); func(*aLarger2, *bSmall); @@ -338,7 +338,7 @@ verifyThatLongerWithShorterWorksAsZeroPadded(uint32_t sz1, uint32_t sz2, Func fu TEST("requireThatAndWorks") { for (uint32_t offset(0); offset < 100; offset++) { testAnd(offset); - verifyThatLongerWithShorterWorksAsZeroPadded(offset+256, offset+256 + offset + 3, + verifyThatLongerWithShorterWorksAsZeroPadded(offset, offset+256, offset+256 + offset + 3, [](BitVector & a, const BitVector & b) { a.andWith(b); }); } } @@ -346,7 +346,7 @@ TEST("requireThatAndWorks") { TEST("requireThatOrWorks") { for (uint32_t offset(0); offset < 100; offset++) { testOr(offset); - verifyThatLongerWithShorterWorksAsZeroPadded(offset+256, offset+256 + offset + 3, + verifyThatLongerWithShorterWorksAsZeroPadded(offset, offset+256, offset+256 + offset + 3, [](BitVector & a, const BitVector & b) { a.orWith(b); }); } } @@ -355,7 +355,7 @@ TEST("requireThatOrWorks") { TEST("requireThatAndNotWorks") { for (uint32_t offset(0); offset < 100; offset++) { testAndNot(offset); - verifyThatLongerWithShorterWorksAsZeroPadded(offset+256, offset+256 + offset + 3, + verifyThatLongerWithShorterWorksAsZeroPadded(offset, offset+256, offset+256 + offset + 3, [](BitVector & a, const BitVector & b) { a.andNotWith(b); }); } } |