WhatProvides testcase extended and iterator fixed
authorMichael Andres <ma@suse.de>
Thu, 9 Oct 2008 11:54:22 +0000 (11:54 +0000)
committerMichael Andres <ma@suse.de>
Thu, 9 Oct 2008 11:54:22 +0000 (11:54 +0000)
devel/devel.ma/NewPool.cc
package/libzypp.changes
tests/sat/WhatProvides_test.cc
zypp/sat/WhatProvides.cc
zypp/sat/WhatProvides.h

index fb14532..36f3ba6 100644 (file)
@@ -430,6 +430,16 @@ void testCMP( const L & lhs, const R & rhs )
 #undef OUTS
 }
 
+void wsoft()
+{
+  ResPool pool( ResPool::instance() );
+  for_( it, pool.begin(), pool.end() )
+  {
+    if ( it->status().isSoftLocked() )
+      INT << "SL: " << *it << endl;
+  }
+}
+
 /******************************************************************
 **
 **      FUNCTION NAME : main
@@ -600,6 +610,21 @@ try {
   ///////////////////////////////////////////////////////////////////
   ///////////////////////////////////////////////////////////////////
 
+   if ( 1 )
+  {
+    PoolItem pi ( getPi<Pattern>("apparmor") );
+    MIL << pi << endl;
+    if ( pi )
+    {
+      Pattern::constPtr p( pi->asKind<Pattern>() );
+      MIL << p << endl;
+      if ( p )
+      {
+        p->contents();
+      }
+    }
+  }
+
   if ( 0 )
   {
     CapabilitySet caps;
@@ -678,11 +703,13 @@ try {
     }
   }
 
+#if 0
   getZYpp()->resolver()->addRequire( Capability("amarok") );
   solve();
   vdumpPoolStats( USR << "Transacting:"<< endl,
                   make_filter_begin<resfilter::ByTransact>(pool),
                   make_filter_end<resfilter::ByTransact>(pool) ) << endl;
+#endif
 
   //////////////////////////////////////////////////////////////////
   INT << "===[END]============================================" << endl << endl;
index 3ec2faa..d9f2c55 100644 (file)
@@ -1,9 +1,9 @@
 -------------------------------------------------------------------
-Thu Oct  9 00:58:37 CEST 2008 - ma@suse.de
+Thu Oct  9 13:52:03 CEST 2008 - ma@suse.de
 
 - Add required copy-ctor and assignment operator to WhatProvides.
   (bnc #433087)
-- revision 11270
+- revision 11276
 
 -------------------------------------------------------------------
 Wed Oct  8 16:24:25 CEST 2008 - jkupec@suse.cz
index 38d6d27..ccd50ab 100644 (file)
@@ -1,5 +1,7 @@
 #include "TestSetup.h"
 
+#define LABELED(V) #V << ":\t" << V
+
 BOOST_AUTO_TEST_CASE(WhatProvides)
 {
   TestSetup test( Arch_x86_64 );
@@ -22,4 +24,41 @@ BOOST_AUTO_TEST_CASE(WhatProvides)
     BOOST_CHECK( q.empty() );
     BOOST_CHECK( q.size() == 0 );
   }
+
+  {
+    // sat::WhatProvides::const_iterator requires proper
+    // copyctor and assignment. If they break
+    sat::WhatProvides q;
+    BOOST_CHECK( q.begin() == q.begin() );
+    BOOST_CHECK( q.begin() == q.end()  );
+
+    q = sat::WhatProvides( Capability("zypper.x86_64 == 0.12.5-1.1") );
+    // q no longer empty
+    BOOST_CHECK( q.begin() == q.begin() );
+    BOOST_CHECK( q.begin() != q.end() );
+
+    sat::WhatProvides::const_iterator a;
+    BOOST_CHECK( a == q.end() );
+
+    sat::WhatProvides::const_iterator b( q.begin() );
+    BOOST_CHECK( b == q.begin() );
+
+//     SEC << LABELED(q.begin()) << endl;
+//     SEC << LABELED(q.end()) << endl;
+//     SEC << LABELED(a) << endl;
+//     SEC << LABELED(b) << endl;
+
+    {
+      a = q.begin();
+      BOOST_CHECK( a == q.begin() );
+//       SEC << LABELED(a) << endl;
+//       SEC << LABELED(b) << endl;
+
+      a = b;
+      BOOST_CHECK( a == b );
+//       SEC << LABELED(a) << endl;
+//       SEC << LABELED(b) << endl;
+    }
+    BOOST_CHECK( a == q.begin() );
+  }
 }
index 8ae380d..4c3c75c 100644 (file)
@@ -164,6 +164,22 @@ namespace zypp
       return dumpRange( str << "(" << obj.size() << ")", obj.begin(), obj.end() );
     }
 
+    ///////////////////////////////////////////////////////////////////
+    namespace detail
+    { /////////////////////////////////////////////////////////////////
+
+      std::ostream & operator<<( std::ostream & str, const WhatProvidesIterator & obj )
+      {
+        str << str::form( "[%5u]", obj._offset );
+        str << str::form( "<%p(%p)>", obj.base_reference(), &obj.base_reference() );
+        str << str::form( "<%p(%p)>", obj._baseRef, (obj._baseRef ? *obj._baseRef : 0) );
+        return str;
+      }
+
+      /////////////////////////////////////////////////////////////////
+    } //namespace detail
+    ///////////////////////////////////////////////////////////////////
+
     /////////////////////////////////////////////////////////////////
   } // namespace sat
   ///////////////////////////////////////////////////////////////////
index c03b075..c57f572 100644 (file)
@@ -151,6 +151,7 @@ namespace zypp
         , const Solvable               // Reference
         >
     {
+      friend std::ostream & operator<<( std::ostream & str, const WhatProvidesIterator & obj );
       public:
         WhatProvidesIterator()
         : iterator_adaptor_( 0 ), _baseRef( 0 ), _offset( 0 )
@@ -173,7 +174,7 @@ namespace zypp
         /** Copy-ctor required to keep _baseRef adjusted. */
         WhatProvidesIterator( const WhatProvidesIterator & rhs )
         : iterator_adaptor_( rhs.base_reference() )
-        , _baseRef( base_reference() ? &base_reference() : 0 )
+        , _baseRef( base_reference() ? &base_reference() : rhs._baseRef )
         , _offset( rhs._offset )
         {}
 
@@ -183,7 +184,7 @@ namespace zypp
           if ( this != &rhs ) // no self assign
           {
             base_reference() = rhs.base_reference();
-            _baseRef = ( base_reference() ? &base_reference() : 0 );
+            _baseRef = ( base_reference() ? &base_reference() : rhs._baseRef );
             _offset = rhs._offset;
           }
           return *this;