Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • api-redesign
  • main
  • 0.10.0
  • 0.10.1
  • 0.10.2
  • 0.7.0
  • 0.8.0
  • 0.8.1
  • 0.9.0
  • 0.9.1
  • 0.9.2
11 results

Target

Select target project
  • justJanne/libquassel
1 result
Select Git revision
  • api-redesign
  • main
  • 0.10.0
  • 0.10.1
  • 0.10.2
  • 0.7.0
  • 0.8.0
  • 0.8.1
  • 0.9.0
  • 0.9.1
  • 0.9.2
11 results
Show changes
Showing with 155 additions and 152 deletions
......@@ -18,7 +18,7 @@ class InsertTest {
for (i in -1024..1024) {
assertEquals(
listOf(7),
emptyList<Int>().insert(7, i)
emptyList<Int>().insert(7, i),
)
}
}
......@@ -28,7 +28,7 @@ class InsertTest {
for (i in -1024..0) {
assertEquals(
listOf(7, 1, 2, 3),
listOf(1, 2, 3).insert(7, i)
listOf(1, 2, 3).insert(7, i),
)
}
}
......@@ -38,7 +38,7 @@ class InsertTest {
for (i in 3..1024) {
assertEquals(
listOf(1, 2, 3, 7),
listOf(1, 2, 3).insert(7, i)
listOf(1, 2, 3).insert(7, i),
)
}
}
......@@ -47,7 +47,7 @@ class InsertTest {
fun appendsForNoParameter() {
assertEquals(
listOf(1, 2, 3, 7),
listOf(1, 2, 3).insert(7)
listOf(1, 2, 3).insert(7),
)
}
......@@ -55,9 +55,10 @@ class InsertTest {
fun isEquivalentToMutableAdd() {
for (i in -1024..1024) {
val before = listOf(1, 2, 3, 4, 5).shuffled()
val afterMutable = before.toMutableList().apply {
add(i.coerceIn(0..before.size), 7)
}
val afterMutable =
before.toMutableList().apply {
add(i.coerceIn(0..before.size), 7)
}
val afterImmutable = before.insert(7, i)
assertEquals(afterMutable, afterImmutable)
}
......
......@@ -18,7 +18,7 @@ class MoveTest {
for (i in 6..1024) {
assertEquals(
listOf(1, 2, 3, 4, 5, 7),
listOf(1, 2, 7, 3, 4, 5).move(7, i)
listOf(1, 2, 7, 3, 4, 5).move(7, i),
)
}
}
......@@ -27,7 +27,7 @@ class MoveTest {
fun appendsForNoParameter() {
assertEquals(
listOf(1, 2, 3, 4, 5, 7),
listOf(1, 2, 7, 3, 4, 5).move(7)
listOf(1, 2, 7, 3, 4, 5).move(7),
)
}
......@@ -36,7 +36,7 @@ class MoveTest {
for (i in -1024..0) {
assertEquals(
listOf(7, 1, 2, 3, 4, 5),
listOf(1, 2, 7, 3, 4, 5).move(7, i)
listOf(1, 2, 7, 3, 4, 5).move(7, i),
)
}
}
......@@ -47,7 +47,7 @@ class MoveTest {
val data = listOf(1, 2, 3, 4, 5, 7).shuffled()
assertEquals(
data,
data.move(7, data.indexOf(7))
data.move(7, data.indexOf(7)),
)
}
}
......@@ -56,7 +56,7 @@ class MoveTest {
fun movesCorrectly() {
assertEquals(
listOf('a', 'c', 'd', 'e', 'b', 'f'),
listOf('a', 'b', 'c', 'd', 'e', 'f').move('b', 4)
listOf('a', 'b', 'c', 'd', 'e', 'f').move('b', 4),
)
}
}
......@@ -15,39 +15,41 @@ import org.junit.jupiter.api.Test
class PairsTest {
@Test
fun testFunctionality() {
val list = (0 until 1024).map {
Pair(Math.random(), Math.random())
}
val list =
(0 until 1024).map {
Pair(Math.random(), Math.random())
}
assertEquals(
list,
PairsProxy.call(
list.flatMap { listOf(it.first, it.second) },
::Pair
)
::Pair,
),
)
assertEquals(
list,
list.flatMap { listOf(it.first, it.second) }.pairs()
list.flatMap { listOf(it.first, it.second) }.pairs(),
)
}
@Test
fun testMalformedPairs() {
val list = (0 until 1024).map {
Pair(Math.random(), Math.random())
}
val list =
(0 until 1024).map {
Pair(Math.random(), Math.random())
}
assertEquals(
list.subList(0, 256),
PairsProxy.call(
list.flatMap { listOf(it.first, it.second) }
.subList(0, 513),
::Pair
)
::Pair,
),
)
assertEquals(
list.subList(0, 256),
list.flatMap { listOf(it.first, it.second) }
.subList(0, 513).pairs()
.subList(0, 513).pairs(),
)
}
}
/*
* libquassel
* Copyright (c) 2021 Janne Mareike Koschinski
*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at https://mozilla.org/MPL/2.0/.
*/
package de.justjanne.libquassel.protocol.util.collections
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
class RemoveTest {
@Test
fun isEquivalentToMutableRemove() {
for (i in -1024..1024) {
val before = listOf(1, 2, 3, 4, 5).shuffled()
val afterMutable = before.toMutableList().apply {
remove(i)
}
val afterImmutable = before.remove(i)
assertEquals(afterMutable, afterImmutable)
}
}
}
......@@ -18,9 +18,9 @@ class ExpansionTest {
assertEquals(
listOf(
Expansion.Text("/join "),
Expansion.Parameter(0, null, "$0")
Expansion.Parameter(0, null, "$0"),
),
Expansion.parse("/join $0")
Expansion.parse("/join $0"),
)
assertEquals(
......@@ -28,9 +28,9 @@ class ExpansionTest {
Expansion.Text("/whois "),
Expansion.Parameter(0, null, "$0"),
Expansion.Text(" "),
Expansion.Parameter(0, null, "$0")
Expansion.Parameter(0, null, "$0"),
),
Expansion.parse("/whois $0 $0")
Expansion.parse("/whois $0 $0"),
)
}
......@@ -39,9 +39,9 @@ class ExpansionTest {
assertEquals(
listOf(
Expansion.Text("/say Welcome to the support channel for the IRC client Quassel, "),
Expansion.Parameter(1, null, "\$1")
Expansion.Parameter(1, null, "\$1"),
),
Expansion.parse("/say Welcome to the support channel for the IRC client Quassel, \$1")
Expansion.parse("/say Welcome to the support channel for the IRC client Quassel, \$1"),
)
assertEquals(
listOf(
......@@ -55,7 +55,7 @@ class ExpansionTest {
Expansion.Text(" "),
Expansion.Parameter(1, Expansion.ParameterField.IDENT, "\$1:ident"),
),
Expansion.parse("\$1 \$1:account \$1:hostname \$1:identd \$1:ident")
Expansion.parse("\$1 \$1:account \$1:hostname \$1:identd \$1:ident"),
)
}
......@@ -69,9 +69,9 @@ class ExpansionTest {
Expansion.Constant(Expansion.ConstantField.CHANNEL, "\$channelname"),
Expansion.Text(" on "),
Expansion.Constant(Expansion.ConstantField.NETWORK, "\$network"),
Expansion.Text(".")
Expansion.Text("."),
),
Expansion.parse("/say I am \$nick, welcoming you to our channel \$channelname on \$network.")
Expansion.parse("/say I am \$nick, welcoming you to our channel \$channelname on \$network."),
)
assertEquals(
listOf(
......@@ -79,9 +79,9 @@ class ExpansionTest {
Expansion.Constant(Expansion.ConstantField.NICK, "\$nick"),
Expansion.Text(" from "),
Expansion.Constant(Expansion.ConstantField.CHANNEL, "\$channel"),
Expansion.Text(".")
Expansion.Text("."),
),
Expansion.parse("/say That’s right, I’m /the/ \$nick from \$channel.")
Expansion.parse("/say That’s right, I’m /the/ \$nick from \$channel."),
)
}
......@@ -99,7 +99,7 @@ class ExpansionTest {
Expansion.ParameterRange(3, null, "\$3.."),
Expansion.Text("\""),
),
Expansion.parse("1 \"\$1\" 2 \"\$2\" 3..4 \"\$3..4\" 3.. \"\$3..\"")
Expansion.parse("1 \"\$1\" 2 \"\$2\" 3..4 \"\$3..4\" 3.. \"\$3..\""),
)
}
}
......@@ -40,13 +40,15 @@ class ExpressionMatchTest {
// Phrase with space, case-insensitive
val simpleMatchSpace = ExpressionMatch(" space ", ExpressionMatch.MatchMode.MatchPhrase, true)
// Complex phrase
val complexMatchFull = """^(?:norm|norm\-space|\!norm\-escaped|\\\!slash\-invert|\\\\double|escape\;""" +
"""sep|slash\-end\-split\\|quad\\\\\!noninvert|newline\-split|newline\-split\-slash\\|slash\-at\-end\\)$"""
val complexMatch = ExpressionMatch(
complexMatchFull,
ExpressionMatch.MatchMode.MatchPhrase,
false
)
val complexMatchFull =
"""^(?:norm|norm\-space|\!norm\-escaped|\\\!slash\-invert|\\\\double|escape\;""" +
"""sep|slash\-end\-split\\|quad\\\\\!noninvert|newline\-split|newline\-split\-slash\\|slash\-at\-end\\)$"""
val complexMatch =
ExpressionMatch(
complexMatchFull,
ExpressionMatch.MatchMode.MatchPhrase,
false,
)
assertEquals("(?:^|\\W)test(?:\\W|$)", simpleMatch.positiveRegex?.pattern)
assertEquals(setOf(RegexOption.IGNORE_CASE), simpleMatch.positiveRegex?.options)
......@@ -90,27 +92,30 @@ class ExpressionMatchTest {
@Test
fun matchMultiPhrase() {
// Simple phrases, case-insensitive
val simpleMatch = ExpressionMatch(
"test\nOther ",
ExpressionMatch.MatchMode.MatchMultiPhrase,
false
)
val simpleMatch =
ExpressionMatch(
"test\nOther ",
ExpressionMatch.MatchMode.MatchMultiPhrase,
false,
)
// Simple phrases, case-sensitive
val simpleMatchCS = ExpressionMatch(
"test\nOther ",
ExpressionMatch.MatchMode.MatchMultiPhrase,
true
)
val simpleMatchCS =
ExpressionMatch(
"test\nOther ",
ExpressionMatch.MatchMode.MatchMultiPhrase,
true,
)
// Complex phrases
val complexMatchFullA =
"""^(?:norm|norm\-space|\!norm\-escaped|\\\!slash\-invert|\\\\double)|escape\;""" +
"""sep|slash\-end\-split\\|quad\\\\\!noninvert)|newline\-split|newline\-split\-slash\\|slash\-at\-end\\)$"""
val complexMatchFullB = """^(?:invert|invert\-space)$)$"""
val complexMatch = ExpressionMatch(
complexMatchFullA + "\n" + complexMatchFullB,
ExpressionMatch.MatchMode.MatchMultiPhrase,
false
)
val complexMatch =
ExpressionMatch(
complexMatchFullA + "\n" + complexMatchFullB,
ExpressionMatch.MatchMode.MatchMultiPhrase,
false,
)
// Assert valid and not empty
assertFalse(simpleMatch.isEmpty())
......@@ -166,7 +171,8 @@ class ExpressionMatchTest {
val complexMatch =
ExpressionMatch(
"""never?gonna*give\*you\?up\\test|y\yeah\\1\\\\2\\\1inval""",
ExpressionMatch.MatchMode.MatchWildcard, false
ExpressionMatch.MatchMode.MatchWildcard,
false,
)
// Assert valid and not empty
......@@ -219,62 +225,73 @@ class ExpressionMatchTest {
val emptyMatch =
ExpressionMatch(
";!\n;",
ExpressionMatch.MatchMode.MatchMultiWildcard, false
ExpressionMatch.MatchMode.MatchMultiWildcard,
false,
)
val simpleMatch =
ExpressionMatch(
"?test*;another?",
ExpressionMatch.MatchMode.MatchMultiWildcard, false
ExpressionMatch.MatchMode.MatchMultiWildcard,
false,
)
val simpleMatchCS =
ExpressionMatch(
"?test*;another?",
ExpressionMatch.MatchMode.MatchMultiWildcard, true
ExpressionMatch.MatchMode.MatchMultiWildcard,
true,
)
val simpleMatchEscape =
ExpressionMatch(
"\\?test\\*\\\n*thing\\*",
ExpressionMatch.MatchMode.MatchMultiWildcard, false
ExpressionMatch.MatchMode.MatchMultiWildcard,
false,
)
val simpleMatchInvert =
ExpressionMatch(
"""test*;!testing;\!testing""",
ExpressionMatch.MatchMode.MatchMultiWildcard, false
ExpressionMatch.MatchMode.MatchMultiWildcard,
false,
)
val simpleMatchImplicit =
ExpressionMatch(
"""!testing*""",
ExpressionMatch.MatchMode.MatchMultiWildcard, false
ExpressionMatch.MatchMode.MatchMultiWildcard,
false,
)
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\\"""
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
val complexMatchNormal = listOf(
"""norm""",
"""norm-space""",
"""!norm-escaped""",
"""\!slash-invert""",
"""\\double""",
"""escape;sep""",
"""slash-end-split\""",
"""quad\\!noninvert""",
"""newline-split""",
"""newline-split-slash\""",
"""slash-at-end\"""
)
val complexMatchNormal =
listOf(
"""norm""",
"""norm-space""",
"""!norm-escaped""",
"""\!slash-invert""",
"""\\double""",
"""escape;sep""",
"""slash-end-split\""",
"""quad\\!noninvert""",
"""newline-split""",
"""newline-split-slash\""",
"""slash-at-end\""",
)
// Match negating components
val complexMatchInvert = listOf(
"""invert""",
"""invert-space"""
)
val complexMatch = ExpressionMatch(
complexMatchFull, ExpressionMatch.MatchMode.MatchMultiWildcard,
false
)
val complexMatchInvert =
listOf(
"""invert""",
"""invert-space""",
)
val complexMatch =
ExpressionMatch(
complexMatchFull,
ExpressionMatch.MatchMode.MatchMultiWildcard,
false,
)
// Assert valid and not empty
assertTrue(emptyMatch.isEmpty())
......@@ -336,37 +353,43 @@ class ExpressionMatchTest {
val emptyMatch =
ExpressionMatch(
""" """,
ExpressionMatch.MatchMode.MatchRegEx, false
ExpressionMatch.MatchMode.MatchRegEx,
false,
)
// Simple regex, case-insensitive
val simpleMatch =
ExpressionMatch(
"""simple.\*escape-match.*""",
ExpressionMatch.MatchMode.MatchRegEx, false
ExpressionMatch.MatchMode.MatchRegEx,
false,
)
// Simple regex, case-sensitive
val simpleMatchCS =
ExpressionMatch(
"""simple.\*escape-match.*""",
ExpressionMatch.MatchMode.MatchRegEx, true
ExpressionMatch.MatchMode.MatchRegEx,
true,
)
// Inverted regex, case-insensitive
val simpleMatchInvert =
ExpressionMatch(
"""!invert.\*escape-match.*""",
ExpressionMatch.MatchMode.MatchRegEx, false
ExpressionMatch.MatchMode.MatchRegEx,
false,
)
// Non-inverted regex, case-insensitive
val simpleMatchNoInvert =
ExpressionMatch(
"""\!simple.\*escape-match.*""",
ExpressionMatch.MatchMode.MatchRegEx, false
ExpressionMatch.MatchMode.MatchRegEx,
false,
)
// Non-inverted regex literal slash, case-insensitive
val simpleMatchNoInvertSlash =
ExpressionMatch(
"""\\!simple.\*escape-match.*""",
ExpressionMatch.MatchMode.MatchRegEx, false
ExpressionMatch.MatchMode.MatchRegEx,
false,
)
// Assert valid and not empty
......@@ -416,32 +439,35 @@ class ExpressionMatchTest {
// Tests imported from https://github.com/ircdocs/parser-tests/blob/master/tests/mask-match.yaml
@Test
fun testDan() {
val mask1 = ExpressionMatch(
"*@127.0.0.1",
ExpressionMatch.MatchMode.MatchWildcard,
caseSensitive = false
)
val mask1 =
ExpressionMatch(
"*@127.0.0.1",
ExpressionMatch.MatchMode.MatchWildcard,
caseSensitive = false,
)
assertTrue(mask1.match("coolguy!ab@127.0.0.1"))
assertTrue(mask1.match("cooldud3!~bc@127.0.0.1"))
assertFalse(mask1.match("coolguy!ab@127.0.0.5"))
assertFalse(mask1.match("cooldud3!~d@124.0.0.1"))
val mask2 = ExpressionMatch(
"cool*@*",
ExpressionMatch.MatchMode.MatchWildcard,
caseSensitive = false
)
val mask2 =
ExpressionMatch(
"cool*@*",
ExpressionMatch.MatchMode.MatchWildcard,
caseSensitive = false,
)
assertTrue(mask2.match("coolguy!ab@127.0.0.1"))
assertTrue(mask2.match("cooldud3!~bc@127.0.0.1"))
assertTrue(mask2.match("cool132!ab@example.com"))
assertFalse(mask2.match("koolguy!ab@127.0.0.5"))
assertFalse(mask2.match("cooodud3!~d@124.0.0.1"))
val mask3 = ExpressionMatch(
"cool!*@*",
ExpressionMatch.MatchMode.MatchWildcard,
caseSensitive = false
)
val mask3 =
ExpressionMatch(
"cool!*@*",
ExpressionMatch.MatchMode.MatchWildcard,
caseSensitive = false,
)
assertTrue(mask3.match("cool!guyab@127.0.0.1"))
assertTrue(mask3.match("cool!~dudebc@127.0.0.1"))
assertTrue(mask3.match("cool!312ab@example.com"))
......@@ -451,11 +477,12 @@ class ExpressionMatchTest {
assertFalse(mask3.match("cooodud3!~d@124.0.0.1"))
// Cause failures in fnmatch/glob based matchers
val mask4 = ExpressionMatch(
"cool[guy]!*@*",
ExpressionMatch.MatchMode.MatchWildcard,
caseSensitive = false
)
val mask4 =
ExpressionMatch(
"cool[guy]!*@*",
ExpressionMatch.MatchMode.MatchWildcard,
caseSensitive = false,
)
assertTrue(mask4.match("cool[guy]!guy@127.0.0.1"))
assertTrue(mask4.match("cool[guy]!a@example.com"))
assertFalse(mask4.match("coolg!ab@127.0.0.1"))
......
......@@ -23,22 +23,22 @@ class QVariantTest {
"QVariant(QByteArray, DEADBEEF)",
qVariant(
byteBufferOf(0xDEu, 0xADu, 0xBEu, 0xEFu),
QtType.QByteArray
).toString()
QtType.QByteArray,
).toString(),
)
assertEquals(
"QVariant(QString, DEADBEEF)",
qVariant(
"DEADBEEF",
QtType.QString
).toString()
QtType.QString,
).toString(),
)
assertEquals(
"QVariant(BufferId, BufferId(-1))",
qVariant(
BufferId(-1),
QuasselType.BufferId
).toString()
QuasselType.BufferId,
).toString(),
)
}
}
......@@ -7,15 +7,15 @@
* obtain one at https://mozilla.org/MPL/2.0/.
*/
enableFeaturePreview("VERSION_CATALOGS")
rootProject.name = "libquassel"
includeBuild("gradle/convention")
include(
":libquassel-annotations",
":libquassel-api",
":libquassel-client",
":libquassel-persistence",
":libquassel-generator",
":libquassel-irc",
":libquassel-protocol"
......