Mailinglist Archive: zypp-commit (171 mails)

< Previous Next >
[zypp-commit] <libzypp> master : Add Solvable::asString "name-version-release.arch"
  • From: Michael Andres <ma@xxxxxxx>
  • Date: Thu, 4 Jun 2009 18:13:55 +0200
  • Message-id: <E1MCf0t-0003QY-1U@xxxxxxxxxxxxxxxx>
ref: refs/heads/master
commit ae0597a9ad43f04b21254f773b5752146fb57972
Author: Michael Andres <ma@xxxxxxx>
Date: Thu Jun 4 18:13:55 2009 +0200

Add Solvable::asString "name-version-release.arch"
---
tests/sat/Solvable_test.cc | 18 +++++++++++++++++-
zypp/sat/Solvable.cc | 10 ++++++++++
zypp/sat/Solvable.h | 9 +++++++++
3 files changed, 36 insertions(+), 1 deletions(-)

diff --git a/tests/sat/Solvable_test.cc b/tests/sat/Solvable_test.cc
index cea20dc..0ec48cc 100644
--- a/tests/sat/Solvable_test.cc
+++ b/tests/sat/Solvable_test.cc
@@ -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
}
+
diff --git a/zypp/sat/Solvable.cc b/zypp/sat/Solvable.cc
index dae6d9f..4757488 100644
--- a/zypp/sat/Solvable.cc
+++ b/zypp/sat/Solvable.cc
@@ -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
{ /////////////////////////////////////////////////////////////////
diff --git a/zypp/sat/Solvable.h b/zypp/sat/Solvable.h
index 68fbf59..a880630 100644
--- a/zypp/sat/Solvable.h
+++ b/zypp/sat/Solvable.h
@@ -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.
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages