Whitespace separated search terms are AND concatenated.

This commit is contained in:
Florian Geyer 2012-10-21 20:45:01 +02:00
parent 4d263a09db
commit 92bf7c94d0
4 changed files with 48 additions and 4 deletions

View file

@ -399,4 +399,35 @@ void TestGroup::testSearch()
delete groupRoot;
}
void TestGroup::testAndConcatenationInSearch()
{
Group* group = new Group();
Entry* entry = new Entry();
entry->setNotes("abc def ghi");
entry->setTitle("jkl");
entry->setGroup(group);
QList<Entry*> searchResult;
searchResult = group->search("", Qt::CaseInsensitive);
QCOMPARE(searchResult.count(), 1);
searchResult = group->search("def", Qt::CaseInsensitive);
QCOMPARE(searchResult.count(), 1);
searchResult = group->search(" abc ghi ", Qt::CaseInsensitive);
QCOMPARE(searchResult.count(), 1);
searchResult = group->search("ghi ef", Qt::CaseInsensitive);
QCOMPARE(searchResult.count(), 1);
searchResult = group->search("abc ef xyz", Qt::CaseInsensitive);
QCOMPARE(searchResult.count(), 0);
searchResult = group->search("abc kl", Qt::CaseInsensitive);
QCOMPARE(searchResult.count(), 1);
delete group;
}
QTEST_GUILESS_MAIN(TestGroup)