diff options
author | Akinori MUSHA <knu@idaemons.org> | 2019-08-12 17:33:31 +0300 |
---|---|---|
committer | Jonathan White <support@dmapps.us> | 2019-09-05 05:31:15 +0300 |
commit | 41131ae48d7af70360ded2504a9233fa8d2117d5 (patch) | |
tree | 331d429671ecd5c0408c1c06823d0523692cad45 /tests/TestEntrySearcher.cpp | |
parent | 0a3b19edf230264a28010f1783b37d43ae9608c3 (diff) |
Allow abbreviation of search field names
This allows `t:word` instead of `title:word` and `p:word` instead of `password:word`, and so on. The rule is that an abbreviated name expands to the first field name that starts with it, with exceptions
`u:` expanding to `username:` instead of `url:` and `pw:` expanding to `password:`.
Diffstat (limited to 'tests/TestEntrySearcher.cpp')
-rw-r--r-- | tests/TestEntrySearcher.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/TestEntrySearcher.cpp b/tests/TestEntrySearcher.cpp index 5a14481ae..7b129df17 100644 --- a/tests/TestEntrySearcher.cpp +++ b/tests/TestEntrySearcher.cpp @@ -96,7 +96,7 @@ void TestEntrySearcher::testSearch() e3->setGroup(group3); Entry* e3b = new Entry(); - e3b->setTitle("test search test"); + e3b->setTitle("test search test 123"); e3b->setUsername("test@email.com"); e3b->setPassword("realpass"); e3b->setGroup(group3); @@ -108,16 +108,31 @@ void TestEntrySearcher::testSearch() m_searchResult = m_entrySearcher.search("search term", m_rootGroup); QCOMPARE(m_searchResult.count(), 3); + m_searchResult = m_entrySearcher.search("123", m_rootGroup); + QCOMPARE(m_searchResult.count(), 2); + m_searchResult = m_entrySearcher.search("search term", group211); QCOMPARE(m_searchResult.count(), 1); // Test advanced search terms + m_searchResult = m_entrySearcher.search("title:123", m_rootGroup); + QCOMPARE(m_searchResult.count(), 1); + + m_searchResult = m_entrySearcher.search("t:123", m_rootGroup); + QCOMPARE(m_searchResult.count(), 1); + m_searchResult = m_entrySearcher.search("password:testpass", m_rootGroup); QCOMPARE(m_searchResult.count(), 1); + m_searchResult = m_entrySearcher.search("pw:testpass", m_rootGroup); + QCOMPARE(m_searchResult.count(), 1); + m_searchResult = m_entrySearcher.search("!user:email.com", m_rootGroup); QCOMPARE(m_searchResult.count(), 5); + m_searchResult = m_entrySearcher.search("!u:email.com", m_rootGroup); + QCOMPARE(m_searchResult.count(), 5); + m_searchResult = m_entrySearcher.search("*user:\".*@.*\\.com\"", m_rootGroup); QCOMPARE(m_searchResult.count(), 1); |