aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-03-08 21:04:33 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2017-03-08 21:04:33 +0100
commit6f8fb9fabfe1b103d59299ecb0d602f48c2aaf4a (patch)
treefa95447d635328adb6e1b990ce122509740a78ff
parente9402901f8e765742a86d949d053dd9c73fbbb2d (diff)
Test notSelf
-rw-r--r--searchlib/src/tests/common/bitvector/bitvector_test.cpp32
1 files changed, 27 insertions, 5 deletions
diff --git a/searchlib/src/tests/common/bitvector/bitvector_test.cpp b/searchlib/src/tests/common/bitvector/bitvector_test.cpp
index 11c43166ef5..e794695d278 100644
--- a/searchlib/src/tests/common/bitvector/bitvector_test.cpp
+++ b/searchlib/src/tests/common/bitvector/bitvector_test.cpp
@@ -1,7 +1,5 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/fastos/fastos.h>
-#include <vespa/log/log.h>
-LOG_SETUP("bitvector_test");
+
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/searchlib/common/growablebitvector.h>
@@ -139,10 +137,14 @@ assertBV(const std::string & exp, const BitVector & act)
}
void
-fill(BitVector & bv, const std::vector<uint32_t> & bits, uint32_t offset)
+fill(BitVector & bv, const std::vector<uint32_t> & bits, uint32_t offset, bool fill=true)
{
for (uint32_t bit : bits) {
- bv.setBit(bit + offset);
+ if (fill) {
+ bv.setBit(bit + offset);
+ } else {
+ bv.clearBit(bit + offset);
+ }
}
}
@@ -244,6 +246,18 @@ testAndNot(uint32_t offset)
EXPECT_TRUE(assertBV(fill({7,103}, offset), *v3));
}
+void
+testNot(uint32_t offset)
+{
+ uint32_t end = offset + 128;
+ BitVector::UP v1(BitVector::create(offset, end));
+ v1->setInterval(offset, end);
+ fill(*v1, A, offset, false);
+
+ v1->notSelf();
+ EXPECT_TRUE(assertBV(fill(A, offset), *v1));
+}
+
TEST("requireThatSequentialOperationsOnPartialWorks")
{
PartialBitVector p1(717,919);
@@ -308,6 +322,13 @@ TEST("requireThatAndNotWorks") {
}
}
+
+TEST("requireThatNotWorks") {
+ for (uint32_t offset(0); offset < 100; offset++) {
+ testNot(offset);
+ }
+}
+
TEST("requireThatClearWorks")
{
AllocatedBitVector v1(128);
@@ -538,4 +559,5 @@ TEST("requireThatGrowWorks")
g.trimHoldLists(2);
}
+
TEST_MAIN() { TEST_RUN_ALL(); }