Fixed Capabilites iterator exposing prereq marker.
authorMichael Andres <ma@suse.de>
Tue, 26 Feb 2008 12:29:19 +0000 (12:29 +0000)
committerMichael Andres <ma@suse.de>
Tue, 26 Feb 2008 12:29:19 +0000 (12:29 +0000)
package/libzypp.changes
tests/zypp/Capabilities_test.cc
zypp/Capabilities.h
zypp/sat/detail/PoolImpl.cc

index 9e48856..c190047 100644 (file)
@@ -1,4 +1,10 @@
 -------------------------------------------------------------------
+Tue Feb 26 13:26:30 CET 2008 - ma@suse.de
+- Fixed Capabilites iterator exposing prereq marker.
+- revision 8914
+
+-------------------------------------------------------------------
 Tue Feb 26 11:29:05 CET 2008 - schubi@suse.de
 
 - postinstall script fixed
index d2b90c0..6c0323b 100644 (file)
@@ -2,6 +2,7 @@
 //
 // tests for Capabilities
 //
+#include <iostream>
 #include <string>
 
 // Boost.Test
@@ -9,6 +10,7 @@
 #include <boost/test/auto_unit_test.hpp>
 
 #include "zypp/Capability.h"
+#include "zypp/Capabilities.h"
 
 using boost::unit_test::test_suite;
 using boost::unit_test::test_case;
@@ -78,5 +80,35 @@ BOOST_AUTO_TEST_CASE(capabilities_test)
 
   BOOST_CHECK_EQUAL( ( c0 == c1 ), false );
   BOOST_CHECK_EQUAL( Capability::matches( c0, c1 ), CapMatch::yes );
+
+
+  Capability r( "req" );
+  Capability p( "prereq" );
+
+  sat::detail::IdType caps[10];
+  caps[0] = r.id();
+  caps[1] = sat::detail::solvablePrereqMarker;
+  caps[2] = p.id();
+  caps[3] = 0;
+
+  // Capabilities with and without prereq (skip marker in ++)
+  Capabilities c( caps );
+  cout << c << endl;
+  BOOST_CHECK_EQUAL( c.size(), 2 );
+  Capabilities::const_iterator it( c.begin() );
+  BOOST_CHECK_EQUAL( *it, r );
+  BOOST_CHECK_EQUAL( it.tagged(), false );
+  ++it;
+  BOOST_CHECK_EQUAL( *it, p );
+  BOOST_CHECK_EQUAL( it.tagged(), true );
+
+  // Capabilities with prereq only (skip marker in ctor)
+  c = Capabilities( caps+1 );
+  cout << c << endl;
+  BOOST_CHECK_EQUAL( c.size(), 1 );
+  it = c.begin();
+  BOOST_CHECK_EQUAL( *it, p );
+  BOOST_CHECK_EQUAL( it.tagged(), true );
+
 }
 
index 257887a..b0cd922 100644 (file)
@@ -103,7 +103,13 @@ namespace zypp
 
       explicit const_iterator( const sat::detail::IdType * _idx )
       : const_iterator::iterator_adaptor_( _idx )
-      {}
+      {
+        if ( base_reference() && sat::detail::isDepMarkerId( *base_reference() ) )
+        {
+          _tagged = true;
+          ++base_reference();
+        }
+      }
 
     public:
       /** Return \c true if the \ref Capability is \c tagged.
index 4e639d6..d5fc51a 100644 (file)
@@ -158,7 +158,7 @@ namespace zypp
         if ( ! _pool->whatprovides )
         {
           DBG << "pool_createwhatprovides..." << endl;
-          ::pool_addfileprovides( _pool, sat::Pool::instance().systemRepo().get());
+          ::pool_addfileprovides( _pool, sat::Pool::instance().systemRepo().get() );
           ::pool_createwhatprovides( _pool );
         }
       }