From 1a5ab72fc6e45d7f30ecfa35d18bbe3dfb1f799b Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Tue, 25 Oct 2022 15:46:26 +0200 Subject: Verify that single dictionary entry from lookupRange() is a match. --- .../tests/attribute/searchcontext/searchcontext_test.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp') diff --git a/searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp b/searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp index 4d02ea7f61d..b6aaadd08cc 100644 --- a/searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp +++ b/searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -71,6 +72,7 @@ class DocSet : public std::set public: DocSet() noexcept; ~DocSet(); + DocSet(std::initializer_list l) : std::set(l) { } DocSet(const uint32_t *b, const uint32_t *e) : std::set(b, e) {} DocSet & put(const uint32_t &v) { insert(v); @@ -1398,7 +1400,7 @@ SearchContextTest::testRegexSearch(const AttributePtr & ptr) addDocs(*ptr.get(), numDocs); const char * strings [] = {"abc1def", "abc2Def", "abc2def", "abc4def", "abc5def", "abc6def"}; - std::vector terms = { "abc", "bc2de" }; + std::vector terms = { "abc", "bc2de", "^abc1def.*bar" }; for (uint32_t doc = 1; doc < numDocs + 1; ++doc) { ASSERT_TRUE(doc < vec.getNumDocs()); @@ -1409,14 +1411,9 @@ SearchContextTest::testRegexSearch(const AttributePtr & ptr) std::vector expected; DocSet empty; - { - uint32_t docs[] = {1, 2, 3, 4, 5, 6}; - expected.emplace_back(docs, docs + 6); // "abc" - } - { - uint32_t docs[] = {2, 3}; - expected.emplace_back(docs, docs + 2); // "bc2de" - } + expected.emplace_back(DocSet{1, 2, 3, 4, 5, 6}); // "abc" + expected.emplace_back(DocSet{2, 3}); // "bc2de" + expected.emplace_back(empty); // "^abc1def.*bar" for (uint32_t i = 0; i < terms.size(); ++i) { performSearch(vec, terms[i], expected[i], TermType::REGEXP); -- cgit v1.2.3