- fix the ResultIterator stop rule
authorJan Kupec <jkupec@suse.cz>
Mon, 7 Apr 2008 11:30:06 +0000 (11:30 +0000)
committerJan Kupec <jkupec@suse.cz>
Mon, 7 Apr 2008 11:30:06 +0000 (11:30 +0000)
- +1 test

tests/zypp/PoolQuery_test.cc
zypp/PoolQuery.cc

index 4faf426..604ea02 100644 (file)
@@ -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)
index 9c1d073..e0584e4 100644 (file)
@@ -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*/);