Add Solvable::asString "name-version-release.arch"
authorMichael Andres <ma@suse.de>
Thu, 4 Jun 2009 16:13:55 +0000 (18:13 +0200)
committerMichael Andres <ma@suse.de>
Thu, 4 Jun 2009 16:13:55 +0000 (18:13 +0200)
tests/sat/Solvable_test.cc
zypp/sat/Solvable.cc
zypp/sat/Solvable.h

index cea20dc..0ec48cc 100644 (file)
@@ -22,6 +22,7 @@ BOOST_AUTO_TEST_CASE(test_init)
 {
   TestSetup test( Arch_x86_64 );
   test.loadRepo( TESTS_SRC_DIR "/data/openSUSE-11.1", "opensuse" );
+  test.loadRepo( TESTS_SRC_DIR "/data/11.0-update", "update" );
 }
 
 
@@ -84,6 +85,21 @@ BOOST_AUTO_TEST_CASE(attributes)
     // check that we actually found all testeable
     // resolvables
     BOOST_CHECK_EQUAL(c, 2);
+}
 
-
+BOOST_AUTO_TEST_CASE(asString)
+{
+  BOOST_CHECK_EQUAL( sat::Solvable(0).asString(), "noSolvable" );
+  BOOST_CHECK_EQUAL( sat::Solvable(1).asString(), "systemSolvable" );
+  BOOST_CHECK_EQUAL( sat::Solvable(2).asString(), "product:openSUSE-11.1.x86_64" );
+  BOOST_CHECK_EQUAL( sat::Solvable(3693).asString(), "autoyast2-2.16.19-0.1.src" );
+  BOOST_CHECK_EQUAL( sat::Solvable(19222).asString(), "noSolvable" );
+#if 0
+  Repository r = sat::Pool::instance().reposFind("update");
+  for_( it, r.solvablesBegin(), r.solvablesEnd() )
+  {
+    BOOST_CHECK_EQUAL( (*it).asString(), str::numstring((*it).id()) );
+  }
+#endif
 }
+
index dae6d9f..4757488 100644 (file)
@@ -423,6 +423,16 @@ namespace zypp
                    : Capabilities();
     }
 
+    std::string Solvable::asString() const
+    {
+      NO_SOLVABLE_RETURN( (_id == detail::systemSolvableId ? "systemSolvable" : "noSolvable") );
+      return str::form( "%s-%s.%s",
+                        IdString( _solvable->name ).c_str(),
+                        IdString( _solvable->evr ).c_str(),
+                        IdString( _solvable->arch ).c_str() );
+    }
+
+
     ///////////////////////////////////////////////////////////////////
     namespace
     { /////////////////////////////////////////////////////////////////
index 68fbf59..a880630 100644 (file)
@@ -171,6 +171,15 @@ namespace zypp
 
        bool         installOnly() const;
 
+        /** String representation <tt>"ident-edition.arch"</tt> or \c "noSolvable"
+         * \code
+         *   product:openSUSE-11.1.x86_64
+         *   autoyast2-2.16.19-0.1.src
+         *   noSolvable
+         * \endcode
+        */
+        std::string asString() const;
+
       public:
 
         /** \name Access to the \ref Solvable dependencies.