}
*/
+// test matching
+BOOST_AUTO_TEST_CASE(pool_query_equal)
+{
+ cout << "****equal****" << endl;
+ PoolQuery q;
+ q.addString("zypp");
+ q.addAttribute(sat::SolvAttr::name);
+ q.setMatchGlob();
+ PoolQuery q2;
+ q2.addString("zypp");
+ q2.addAttribute(sat::SolvAttr::name);
+ q2.setMatchGlob();
+ PoolQuery q3;
+ q3.addString("zypp");
+ q3.addAttribute(sat::SolvAttr::name);
+ q3.setMatchGlob();
+ q3.setRequireAll(true);
+ PoolQuery q4;
+ q4.addAttribute(sat::SolvAttr::name,"zypp");
+ q4.setMatchGlob();
+
+ BOOST_CHECK(equal(q,q2));
+ BOOST_CHECK(!equal(q,q3));
+ //only exact equal! \TODO maybe change
+ BOOST_CHECK(!equal(q,q4));
+ BOOST_CHECK(!equal(q4,q3));
+}
// save/load query
BOOST_AUTO_TEST_CASE(pool_query_save_restore)
ostream & operator<<( ostream & str, const PoolQuery & obj )
{ return str << obj.asString(); }
+ bool operator==(const PoolQuery& a, const PoolQuery& b)
+ {
+ return equal(a,b);
+ }
+
+ //internal matching two containers O(n^2)
+ template <class Container>
+ bool equalContainers(const Container& a, const Container& b)
+ {
+ for_(it,a.begin(),a.end())
+ {
+ bool finded = false;
+ for_( it2, b.begin(),b.end() )
+ {
+ if (*it==*it2)
+ {
+ finded = true;
+ break;
+ }
+ }
+
+ if (!finded)
+ return false;
+ }
+ return true;
+ }
+
+ bool equal(const PoolQuery& a, const PoolQuery& b)
+ {
+ if( a.matchType()!=b.matchType() )
+ return false;
+ if( a.matchWord()!=b.matchWord())
+ return false;
+ if( a.requireAll()!=b.requireAll() )
+ return false;
+ if(!equalContainers(a.strings(), b.strings()))
+ return false;
+ if(!equalContainers(a.kinds(), b.kinds()))
+ return false;
+ if(!equalContainers(a.repos(), b.repos()))
+ return false;
+ if(!equalContainers(a.attributes(), b.attributes()))
+ return false;
+
+ return true;
+ }
+
/////////////////////////////////////////////////////////////////
} // namespace zypp
/** \relates PoolQuery Stream output. */
std::ostream & operator<<( std::ostream & str, const PoolQuery & obj );
+ bool equal(const PoolQuery& a, const PoolQuery& b);
+ bool operator==(const PoolQuery& a, const PoolQuery& b);
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : PoolQuery::ResultIterator