From 3b993ef7aa7899939eaa15a7df11f4c0ce7a55d5 Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Fri, 14 Sep 2018 17:37:45 -0400 Subject: [PATCH] Correct identified issues --- src/core/EntrySearcher.cpp | 2 +- src/core/EntrySearcher.h | 2 +- src/core/Tools.cpp | 1 - tests/TestEntrySearcher.cpp | 14 +++++++------- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/core/EntrySearcher.cpp b/src/core/EntrySearcher.cpp index 626c3c2d71..c22b32ea8b 100644 --- a/src/core/EntrySearcher.cpp +++ b/src/core/EntrySearcher.cpp @@ -121,7 +121,7 @@ QList > EntrySearcher::parseSearchTerm auto results = m_termParser.globalMatch(searchString); while (results.hasNext()) { auto result = results.next(); - QSharedPointer term(new SearchTerm()); + auto term = QSharedPointer::create(); // Quoted string group term->word = result.captured(3); diff --git a/src/core/EntrySearcher.h b/src/core/EntrySearcher.h index 3a2fcb1234..e68a03d94b 100644 --- a/src/core/EntrySearcher.h +++ b/src/core/EntrySearcher.h @@ -39,7 +39,7 @@ class EntrySearcher private: bool searchEntryImpl(const QString& searchString, Entry* entry); - enum Field { + enum class Field { Undefined, Title, Username, diff --git a/src/core/Tools.cpp b/src/core/Tools.cpp index 3211190e49..9c172b2520 100644 --- a/src/core/Tools.cpp +++ b/src/core/Tools.cpp @@ -357,7 +357,6 @@ QRegularExpression convertToRegex(const QString& string, bool useWildcards, bool // Wildcard support (*, ?, |) if (useWildcards) { pattern.replace(regexEscape, "\\\\1"); - pattern.replace("**", "*"); pattern.replace("*", ".*"); pattern.replace("?", "."); } diff --git a/tests/TestEntrySearcher.cpp b/tests/TestEntrySearcher.cpp index 6b74967cfe..43ef77bf4d 100644 --- a/tests/TestEntrySearcher.cpp +++ b/tests/TestEntrySearcher.cpp @@ -144,21 +144,21 @@ void TestEntrySearcher::testSearchTermParser() QCOMPARE(terms.length(), 5); - QCOMPARE(terms[0]->field, EntrySearcher::Undefined); + QCOMPARE(terms[0]->field, EntrySearcher::Field::Undefined); QCOMPARE(terms[0]->word, QString("test")); QCOMPARE(terms[0]->exclude, true); - QCOMPARE(terms[1]->field, EntrySearcher::Undefined); + QCOMPARE(terms[1]->field, EntrySearcher::Field::Undefined); QCOMPARE(terms[1]->word, QString("quoted \\\"string\\\"")); QCOMPARE(terms[1]->exclude, false); - QCOMPARE(terms[2]->field, EntrySearcher::Username); + QCOMPARE(terms[2]->field, EntrySearcher::Field::Username); QCOMPARE(terms[2]->word, QString("user")); - QCOMPARE(terms[3]->field, EntrySearcher::Password); + QCOMPARE(terms[3]->field, EntrySearcher::Field::Password); QCOMPARE(terms[3]->word, QString("test me")); - QCOMPARE(terms[4]->field, EntrySearcher::Undefined); + QCOMPARE(terms[4]->field, EntrySearcher::Field::Undefined); QCOMPARE(terms[4]->word, QString("noquote")); // Test wildcard and regex search terms @@ -166,9 +166,9 @@ void TestEntrySearcher::testSearchTermParser() QCOMPARE(terms.length(), 2); - QCOMPARE(terms[0]->field, EntrySearcher::Url); + QCOMPARE(terms[0]->field, EntrySearcher::Field::Url); QCOMPARE(terms[0]->regex.pattern(), QString("^.*\\.google\\.com$")); - QCOMPARE(terms[1]->field, EntrySearcher::Username); + QCOMPARE(terms[1]->field, EntrySearcher::Field::Username); QCOMPARE(terms[1]->regex.pattern(), QString("\\d+\\w{2}")); }