Skip to content
Snippets Groups Projects
Verified Commit 011d72e8 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Minor fixes

parent db256157
No related branches found
No related tags found
No related merge requests found
Pipeline #263 passed
...@@ -233,7 +233,7 @@ class ExpressionMatch : Serializable { ...@@ -233,7 +233,7 @@ class ExpressionMatch : Serializable {
} }
} }
if (_sourceExpressionEmpty && !isValid()) { if (!isValid()) {
// This can happen with invalid regex, so make it a bit more user-friendly. Set it to Info // This can happen with invalid regex, so make it a bit more user-friendly. Set it to Info
// level as ideally someone's not just going to leave a broken match rule around. For // level as ideally someone's not just going to leave a broken match rule around. For
// MatchRegEx, they probably need to fix their regex rule. For the other modes, there's // MatchRegEx, they probably need to fix their regex rule. For the other modes, there's
...@@ -463,7 +463,7 @@ class ExpressionMatch : Serializable { ...@@ -463,7 +463,7 @@ class ExpressionMatch : Serializable {
1, 2 -> { 1, 2 -> {
// "\!" -> Elsewhere: keep as "\!" // "\!" -> Elsewhere: keep as "\!"
// "\\!" -> Elsewhere: keep as "\\!" // "\\!" -> Elsewhere: keep as "\\!"
curString += """\""".repeat(consecutiveSlashes) curString += """\""".repeat(consecutiveSlashes) + "!"
} }
else -> { else -> {
// This shouldn't ever happen (even with invalid wildcard rules), log a warning // This shouldn't ever happen (even with invalid wildcard rules), log a warning
...@@ -718,7 +718,7 @@ class ExpressionMatch : Serializable { ...@@ -718,7 +718,7 @@ class ExpressionMatch : Serializable {
* @see ExpressionMatch::convertFromWildcard() * @see ExpressionMatch::convertFromWildcard()
* @return QString with all regular expression characters escaped * @return QString with all regular expression characters escaped
*/ */
fun wildcardToRegEx(expression: String): String { private fun wildcardToRegEx(expression: String): String {
// Convert the wildcard expression into regular expression format // Convert the wildcard expression into regular expression format
// We're taking a little bit different of a route... // We're taking a little bit different of a route...
......
...@@ -193,7 +193,6 @@ class ExpressionMatchTest { ...@@ -193,7 +193,6 @@ class ExpressionMatchTest {
@Test @Test
fun matchMultiWildcard() { fun matchMultiWildcard() {
/*
// Simple wildcards, case-insensitive // Simple wildcards, case-insensitive
val simpleMatch = val simpleMatch =
ExpressionMatch("?test*;another?", ExpressionMatch("?test*;another?",
...@@ -202,12 +201,10 @@ class ExpressionMatchTest { ...@@ -202,12 +201,10 @@ class ExpressionMatchTest {
val simpleMatchCS = val simpleMatchCS =
ExpressionMatch("?test*;another?", ExpressionMatch("?test*;another?",
ExpressionMatch.MatchMode.MatchMultiWildcard, true) ExpressionMatch.MatchMode.MatchMultiWildcard, true)
*/
// Escaped wildcards, case-insensitive // Escaped wildcards, case-insensitive
val simpleMatchEscape = val simpleMatchEscape =
ExpressionMatch("""\?test\*\;*thing\*""", ExpressionMatch("""\?test\*\;*thing\*""",
ExpressionMatch.MatchMode.MatchMultiWildcard, false) ExpressionMatch.MatchMode.MatchMultiWildcard, false)
/*
// Inverted wildcards, case-insensitive // Inverted wildcards, case-insensitive
val simpleMatchInvert = val simpleMatchInvert =
ExpressionMatch("""test*;!testing""", ExpressionMatch("""test*;!testing""",
...@@ -217,7 +214,12 @@ class ExpressionMatchTest { ...@@ -217,7 +214,12 @@ class ExpressionMatchTest {
ExpressionMatch("""!testing*""", ExpressionMatch("""!testing*""",
ExpressionMatch.MatchMode.MatchMultiWildcard, false) ExpressionMatch.MatchMode.MatchMultiWildcard, false)
// Complex wildcard // Complex wildcard
val complexMatchFull = """norm;!invert; norm-space ; !invert-space ;;!;\!norm-escaped;\\!slash-invert;\\\\double; escape\;sep;slash-end-split\\;quad\\\\!noninvert;newline-split\nnewline-split-slash\\\nslash-at-end\\""" val complexMatchFull = """norm;!invert; norm-space ; !invert-space ;;!;\!norm-escaped;""" +
"""\\!slash-invert;\\\\double; escape\;sep;slash-end-split\\;""" +
"""quad\\\\!noninvert;newline-split""" + "\n" +
"""newline-split-slash\\""" + "\n" +
"""slash-at-end\\"""
// Match normal components // Match normal components
val complexMatchNormal = listOf( val complexMatchNormal = listOf(
"""norm""", """norm""",
...@@ -234,8 +236,8 @@ class ExpressionMatchTest { ...@@ -234,8 +236,8 @@ class ExpressionMatchTest {
) )
// Match negating components // Match negating components
val complexMatchInvert = listOf( val complexMatchInvert = listOf(
"""(invert)""", """invert""",
"""(invert-space)""" """invert-space"""
) )
val complexMatch = val complexMatch =
ExpressionMatch(complexMatchFull, ExpressionMatch.MatchMode.MatchMultiWildcard, ExpressionMatch(complexMatchFull, ExpressionMatch.MatchMode.MatchMultiWildcard,
...@@ -260,10 +262,8 @@ class ExpressionMatchTest { ...@@ -260,10 +262,8 @@ class ExpressionMatchTest {
assertTrue(simpleMatch.match("@testing")) assertTrue(simpleMatch.match("@testing"))
assertTrue(simpleMatch.match("!test")) assertTrue(simpleMatch.match("!test"))
assertTrue(simpleMatch.match("anotherA")) assertTrue(simpleMatch.match("anotherA"))
*/
assertTrue(simpleMatchEscape.match("?test*;thing*")) assertTrue(simpleMatchEscape.match("?test*;thing*"))
assertTrue(simpleMatchEscape.match("?test*;AAAAAthing*")) assertTrue(simpleMatchEscape.match("?test*;AAAAAthing*"))
/*
assertTrue(simpleMatchInvert.match("test")) assertTrue(simpleMatchInvert.match("test"))
assertTrue(simpleMatchInvert.match("testing things")) assertTrue(simpleMatchInvert.match("testing things"))
// Assert implicit wildcard succeeds // Assert implicit wildcard succeeds
...@@ -274,10 +274,8 @@ class ExpressionMatchTest { ...@@ -274,10 +274,8 @@ class ExpressionMatchTest {
assertFalse(simpleMatch.match("anotherBB")) assertFalse(simpleMatch.match("anotherBB"))
// Assert unrelated fails // Assert unrelated fails
assertFalse(simpleMatch.match("not above")) assertFalse(simpleMatch.match("not above"))
*/
// Assert escaped wildcard fails // Assert escaped wildcard fails
assertFalse(simpleMatchEscape.match("@testing")) assertFalse(simpleMatchEscape.match("@testing"))
/*
// Assert inverted match fails // Assert inverted match fails
assertFalse(simpleMatchInvert.match("testing")) assertFalse(simpleMatchInvert.match("testing"))
assertFalse(simpleMatchImplicit.match("testing")) assertFalse(simpleMatchImplicit.match("testing"))
...@@ -303,7 +301,6 @@ class ExpressionMatchTest { ...@@ -303,7 +301,6 @@ class ExpressionMatchTest {
assertFalse(complexMatch.match(complexMatchFull)) assertFalse(complexMatch.match(complexMatchFull))
// Assert complex unrelated not match // Assert complex unrelated not match
assertFalse(complexMatch.match("other")) assertFalse(complexMatch.match("other"))
*/
} }
@Test @Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment