From 00d55247a9550585134eee397d342e8405dcecb6 Mon Sep 17 00:00:00 2001 From: Jan Kupec Date: Mon, 7 Apr 2008 11:30:06 +0000 Subject: [PATCH] - fix the ResultIterator stop rule - +1 test --- tests/zypp/PoolQuery_test.cc | 23 ++++++++++++++++++----- zypp/PoolQuery.cc | 7 +++++-- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/tests/zypp/PoolQuery_test.cc b/tests/zypp/PoolQuery_test.cc index 4faf426..604ea02 100644 --- a/tests/zypp/PoolQuery_test.cc +++ b/tests/zypp/PoolQuery_test.cc @@ -105,11 +105,7 @@ BOOST_AUTO_TEST_CASE(pool_query_4) q.addAttribute(sat::SolvAttr::name, "zypper"); q.addRepo("zypp_svn"); - PoolQuery::ResultIterator it = q.begin(); - std::for_each( - it, - q.end(), - &result_cb); + std::for_each(q.begin(), q.end(), &result_cb); BOOST_CHECK(q.size() == 3); } @@ -145,8 +141,25 @@ BOOST_AUTO_TEST_CASE(pool_query_6) BOOST_CHECK(q1.size() == 5); } +// match exact BOOST_AUTO_TEST_CASE(pool_query_7) { + cout << "****7****" << endl; + PoolQuery q; + q.addString("vim"); + q.addAttribute(sat::SolvAttr::name); + q.setMatchExact(); + + std::for_each(q.begin(), q.end(), &result_cb); + BOOST_CHECK(q.size() == 3); + + PoolQuery q1; + q1.addString("zypp"); + q1.addAttribute(sat::SolvAttr::name); + q1.setMatchExact(); + + std::for_each(q1.begin(), q1.end(), &result_cb); + BOOST_CHECK(q1.empty()); } BOOST_AUTO_TEST_CASE(pool_query_8) diff --git a/zypp/PoolQuery.cc b/zypp/PoolQuery.cc index 9c1d073..e0584e4 100644 --- a/zypp/PoolQuery.cc +++ b/zypp/PoolQuery.cc @@ -517,7 +517,8 @@ attremptycheckend: while (_has_next && !(got_match = matchSolvable())); } - if (!got_match) + // no more solvables and the last did not match + if (!got_match && !_has_next) { base_reference() = 0; _sid = 0; @@ -569,9 +570,11 @@ attremptycheckend: _sid = _rdit->solvid; } } + // no more attributes/solvables, return else { - return matches; + // did the last solvable match conditions? + return matches && in_repo; } } while (_rdit->solvid == _sid || !in_repo /*_sid < 2 *//*_rdit->repo->start*/); -- 2.7.4