diff --git a/searchlib/src/tests/queryeval/same_element/CMakeLists.txt b/searchlib/src/tests/queryeval/same_element/CMakeLists.txt index 268402ceaaae..eb856b12fb8a 100644 --- a/searchlib/src/tests/queryeval/same_element/CMakeLists.txt +++ b/searchlib/src/tests/queryeval/same_element/CMakeLists.txt @@ -4,5 +4,6 @@ vespa_add_executable(searchlib_same_element_test_app TEST same_element_test.cpp DEPENDS vespa_searchlib + GTest::gtest ) vespa_add_test(NAME searchlib_same_element_test_app COMMAND searchlib_same_element_test_app) diff --git a/searchlib/src/tests/queryeval/same_element/same_element_test.cpp b/searchlib/src/tests/queryeval/same_element/same_element_test.cpp index 4334c0bf49e3..72630f0a6204 100644 --- a/searchlib/src/tests/queryeval/same_element/same_element_test.cpp +++ b/searchlib/src/tests/queryeval/same_element/same_element_test.cpp @@ -7,19 +7,18 @@ #include #include #include -#include -#include -#include +#include using namespace search::fef; using namespace search::queryeval; using search::attribute::SearchContextElementIterator; void verify_elements(SameElementSearch &se, uint32_t docid, const std::initializer_list list) { + SCOPED_TRACE("verify elements, docid=" + std::to_string(docid)); std::vector expect(list); std::vector actual; se.find_matching_elements(docid, actual); - EXPECT_EQUAL(actual, expect); + EXPECT_EQ(actual, expect); } FieldSpec make_field_spec() { @@ -72,15 +71,15 @@ FakeResult make_result(const std::vectorinitRange(1, 1000); auto *se = dynamic_cast(search.get()); ASSERT_TRUE(se != nullptr); - TEST_DO(verify_elements(*se, 5, {3, 7})); - TEST_DO(verify_elements(*se, 10, {})); - TEST_DO(verify_elements(*se, 20, {})); + verify_elements(*se, 5, {3, 7}); + verify_elements(*se, 10, {}); + verify_elements(*se, 20, {}); } -TEST("require that children must match within same element") { +TEST(SameElementTest, require_that_children_must_match_within_same_element) { auto a = make_result({{5, {1,3,7}}}); auto b = make_result({{5, {2,5,10}}}); SimpleResult result = find_matches({a, b}); SimpleResult expect; - EXPECT_EQUAL(result, expect); + EXPECT_EQ(result, expect); } -TEST("require that strict iterator seeks to next hit and can unpack matching docid") { +TEST(SameElementTest, require_that_strict_iterator_seeks_to_next_hit_and_can_unpack_matching_docid) { auto md = make_match_data(); auto a = make_result({{5, {1,2}}, {7, {1,2}}, {8, {1,2}}, {9, {1,2}}}); auto b = make_result({{5, {3}}, {6, {1,2}}, {7, {2,4}}, {9, {1}}}); @@ -110,39 +109,39 @@ TEST("require that strict iterator seeks to next hit and can unpack matching doc auto search = bp->createSearch(*md); auto* tfmd = md->resolveTermField(0); search->initRange(1, 1000); - EXPECT_LESS(search->getDocId(), 1u); + EXPECT_LT(search->getDocId(), 1u); EXPECT_FALSE(search->seek(1)); - EXPECT_EQUAL(search->getDocId(), 7u); + EXPECT_EQ(search->getDocId(), 7u); search->unpack(7); - EXPECT_EQUAL(tfmd->getDocId(), 7u); + EXPECT_EQ(tfmd->getDocId(), 7u); EXPECT_TRUE(search->seek(9)); - EXPECT_EQUAL(search->getDocId(), 9u); - EXPECT_EQUAL(tfmd->getDocId(), 7u); + EXPECT_EQ(search->getDocId(), 9u); + EXPECT_EQ(tfmd->getDocId(), 7u); search->unpack(9); - EXPECT_EQUAL(tfmd->getDocId(), 9u); + EXPECT_EQ(tfmd->getDocId(), 9u); EXPECT_FALSE(search->seek(10)); EXPECT_TRUE(search->isAtEnd()); } -TEST("require that results are estimated appropriately") { +TEST(SameElementTest, require_that_results_are_estimated_appropriately) { auto a = make_result({{5, {0}}, {5, {0}}, {5, {0}}}); auto b = make_result({{5, {0}}, {5, {0}}}); auto c = make_result({{5, {0}}, {5, {0}}, {5, {0}}, {5, {0}}}); auto bp = finalize(make_blueprint({a,b,c}), true); - EXPECT_EQUAL(bp->getState().estimate().estHits, 2u); + EXPECT_EQ(bp->getState().estimate().estHits, 2u); } -TEST("require that children are sorted") { +TEST(SameElementTest, require_that_children_are_sorted) { auto a = make_result({{5, {0}}, {5, {0}}, {5, {0}}}); auto b = make_result({{5, {0}}, {5, {0}}}); auto c = make_result({{5, {0}}, {5, {0}}, {5, {0}}, {5, {0}}}); auto bp = finalize(make_blueprint({a,b,c}), true); - EXPECT_EQUAL(dynamic_cast(*bp).terms()[0]->getState().estimate().estHits, 2u); - EXPECT_EQUAL(dynamic_cast(*bp).terms()[1]->getState().estimate().estHits, 3u); - EXPECT_EQUAL(dynamic_cast(*bp).terms()[2]->getState().estimate().estHits, 4u); + EXPECT_EQ(dynamic_cast(*bp).terms()[0]->getState().estimate().estHits, 2u); + EXPECT_EQ(dynamic_cast(*bp).terms()[1]->getState().estimate().estHits, 3u); + EXPECT_EQ(dynamic_cast(*bp).terms()[2]->getState().estimate().estHits, 4u); } -TEST("require that attribute iterators are wrapped for element unpacking") { +TEST(SameElementTest, require_that_attribute_iterators_are_wrapped_for_element_unpacking) { auto a = make_result({{5, {1,3,7}}}); auto b = make_result({{5, {3,5,10}}}); auto bp = finalize(make_blueprint({a,b}, true), false); @@ -150,9 +149,9 @@ TEST("require that attribute iterators are wrapped for element unpacking") { auto search = bp->createSearch(*md); auto *se = dynamic_cast(search.get()); ASSERT_TRUE(se != nullptr); - ASSERT_EQUAL(se->children().size(), 2u); + ASSERT_EQ(se->children().size(), 2u); EXPECT_TRUE(dynamic_cast(se->children()[0].get()) != nullptr); EXPECT_TRUE(dynamic_cast(se->children()[1].get()) != nullptr); } -TEST_MAIN() { TEST_RUN_ALL(); } +GTEST_MAIN_RUN_ALL_TESTS()