Fix bug in PoolQuery::addDependency
authorMichael Andres <ma@suse.de>
Tue, 27 Jul 2010 14:08:09 +0000 (16:08 +0200)
committerMichael Andres <ma@suse.de>
Tue, 27 Jul 2010 14:08:09 +0000 (16:08 +0200)
tests/zypp/PoolQuery_test.cc
zypp/PoolQuery.cc

index 7d77851..19a7ab4 100644 (file)
@@ -778,6 +778,28 @@ BOOST_AUTO_TEST_CASE(addDependency)
     //dumpQ( std::cout, q );
     BOOST_CHECK_EQUAL( q.size(), 0 );
   }
+  {
+    cout << "****addDependency2d****"  << endl;
+    PoolQuery q;
+    q.setCaseSensitive( false );
+    q.setMatchSubstring();
+    // libzypp provides yast2-packagemanager...
+    q.addDependency( sat::SolvAttr::provides, "yast2-packagemanager", Arch_i586 ); // AND with arch i585
+    std::for_each(q.begin(), q.end(), PrintAndCount());
+    //dumpQ( std::cout, q );
+    BOOST_CHECK_EQUAL( q.size(), 2 );
+  }
+  {
+    cout << "****addDependency2e****"  << endl;
+    PoolQuery q;
+    q.setCaseSensitive( false );
+    q.setMatchSubstring();
+    // but no package named yast2-packagemanager
+    q.addDependency( sat::SolvAttr::name, "yast2-packagemanager", Arch_i586 ); // AND with arch i585
+    std::for_each(q.begin(), q.end(), PrintAndCount());
+    //dumpQ( std::cout, q );
+    BOOST_CHECK_EQUAL( q.size(), 0 );
+  }
 
   {
     cout << "****addDependency3****"  << endl;
index fbb0ce0..c2caef6 100644 (file)
@@ -850,8 +850,11 @@ attremptycheckend:
     {
       case Rel::ANY_e: // no additional constraint on edition.
         if ( arch.empty() )    // no additional constraint on arch.
+       {
          addAttribute( attr, name );
-        return;
+         return;
+       }
+       break;
 
       case Rel::NONE_e:        // will never match.
         return;