Mailinglist Archive: zypp-commit (606 mails)

< Previous Next >
[zypp-commit] r9478 - in /trunk/libzypp: tests/zypp/PoolQuery_test.cc zypp/PoolQuery.cc
  • From: jkupec@xxxxxxxxxxxxxxxx
  • Date: Wed, 09 Apr 2008 09:49:19 -0000
  • Message-id: <20080409094919.F2384270A8@xxxxxxxxxxxxxxxx>
Author: jkupec
Date: Wed Apr 9 11:49:19 2008
New Revision: 9478

URL: http://svn.opensuse.org/viewcvs/zypp?rev=9478&view=rev
Log:
- fix multi-attribute search using dataiterator_match

Modified:
trunk/libzypp/tests/zypp/PoolQuery_test.cc
trunk/libzypp/zypp/PoolQuery.cc

Modified: trunk/libzypp/tests/zypp/PoolQuery_test.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/zypp/PoolQuery_test.cc?rev=9478&r1=9477&r2=9478&view=diff
==============================================================================
--- trunk/libzypp/tests/zypp/PoolQuery_test.cc (original)
+++ trunk/libzypp/tests/zypp/PoolQuery_test.cc Wed Apr 9 11:49:19 2008
@@ -196,63 +196,61 @@
// 1xx multiple attribute queries
/////////////////////////////////////////////////////////////////////////////

-/*
+
BOOST_AUTO_TEST_CASE(pool_query_100)
{
cout << "****100****" << endl;
PoolQuery q;
- q.addString("browser");
+ q.addString("mp3");
q.addAttribute(sat::SolvAttr::name);
q.addAttribute(sat::SolvAttr::summary);
q.addAttribute(sat::SolvAttr::description);

std::for_each(q.begin(), q.end(), &result_cb);
- BOOST_CHECK(q.size() == 15);
+ BOOST_CHECK(q.size() == 73);

cout << endl;

PoolQuery q1;
- q1.addString("browser");
+ q1.addString("mp3");
q1.addAttribute(sat::SolvAttr::name);

std::for_each(q1.begin(), q1.end(), &result_cb);
- BOOST_CHECK(q1.size() == 5);
+ BOOST_CHECK(q1.size() == 7);
}

-
// multi attr (same value) substring matching (case sensitive and insensitive)
-BOOST_AUTO_TEST_CASE(pool_query_10)
+BOOST_AUTO_TEST_CASE(pool_query_101)
{
- cout << "****10****" << endl;
+ cout << "****101****" << endl;

PoolQuery q;
- q.addString("SSH");
+ q.addString("ZYpp");
q.addAttribute(sat::SolvAttr::name);
q.addAttribute(sat::SolvAttr::summary);
q.addAttribute(sat::SolvAttr::description);

std::for_each(q.begin(), q.end(), &result_cb);
- cout << q.size() << endl;
- BOOST_CHECK(q.size() == 17);
+ BOOST_CHECK(q.size() == 30);

cout << endl;

PoolQuery q2;
- q2.addString("SSH");
+ q2.addString("ZYpp");
q2.addAttribute(sat::SolvAttr::name);
q2.addAttribute(sat::SolvAttr::summary);
q2.addAttribute(sat::SolvAttr::description);
q2.setCaseSensitive();

std::for_each(q2.begin(), q2.end(), &result_cb);
- cout << q2.size() << endl;
+ BOOST_CHECK(q2.size() == 2);
}


// multi attr (same value) glob matching (case sensitive and insensitive)
-BOOST_AUTO_TEST_CASE(pool_query_11)
+BOOST_AUTO_TEST_CASE(pool_query_102)
{
- cout << "****11****" << endl;
+ cout << "****102****" << endl;
PoolQuery q;
q.addString("pack*");
q.addAttribute(sat::SolvAttr::name);
@@ -260,10 +258,10 @@
q.setMatchGlob();

std::for_each(q.begin(), q.end(), &result_cb);
- cout << q.asString() << endl;
-// BOOST_CHECK(q.size() == 11);
+ cout << q.size() << endl;
+ BOOST_CHECK(q.size() == 35);
}
-*/
+

/////////////////////////////////////////////////////////////////////////////
// 3xx repo filter queries (addRepo(alias_str))

Modified: trunk/libzypp/zypp/PoolQuery.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/PoolQuery.cc?rev=9478&r1=9477&r2=9478&view=diff
==============================================================================
--- trunk/libzypp/zypp/PoolQuery.cc (original)
+++ trunk/libzypp/zypp/PoolQuery.cc Wed Apr 9 11:49:19 2008
@@ -474,8 +474,8 @@

// compiled

- o << "regex compiled strings: " << _rcstrings << endl;
- o << "regex compiled attributes:" << endl;
+ o << "compiled strings: " << _rcstrings << endl;
+ o << "compiled attributes:" << endl;
for (CompiledAttrMap::const_iterator ai = _rcattrs.begin(); ai !=
_rcattrs.end(); ++ai)
o << "* " << ai->first << ": " << ai->second << endl;

@@ -604,32 +604,9 @@
const IdString & value =
IdString(_rdit->kv.id);

- switch(_pqimpl->_flags & SEARCH_STRINGMASK)
- {
- case SEARCH_STRING:
- if (_pqimpl->_flags & SEARCH_NOCASE)
- matches = ! str::compareCI(sstr.c_str(), value.c_str());
- else
- matches = (sstr == value.asString());
- break;
- case SEARCH_SUBSTRING:
- if (_pqimpl->_flags & SEARCH_NOCASE)
- matches = ::strcasestr(value.c_str(), sstr.c_str());
- else
- matches = (value.asString().find(sstr) != string::npos);
- break;
- case SEARCH_GLOB:
- matches = !::fnmatch(sstr.c_str(), value.c_str(),
- (_pqimpl->_flags & SEARCH_NOCASE) ? FNM_CASEFOLD : 0);
- break;
- case SEARCH_REGEX:
- matches = false;
- break;
- default:
- matches = false;
- ERR << "invalid string matching type: "
- << (_pqimpl->_flags & SEARCH_STRINGMASK) << endl;
- }
+ //! \todo pass compiled regex if SEARCH_REGEX
+ matches = dataiterator_match(_rdit, _pqimpl->_flags, sstr.c_str());
+
if (matches)
INT << "value: " << value.asString() << endl
<< " mstr: " << sstr << endl;

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages