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

Additional testing

parent 3c0e613b
No related branches found
No related tags found
No related merge requests found
Pipeline #583 passed
Showing
with 589 additions and 42 deletions
......@@ -27,22 +27,29 @@ import de.kuschku.libquassel.protocol.serializers.QuasselSerializers
import de.kuschku.libquassel.protocol.serializers.primitive.QtSerializer
import de.kuschku.libquassel.protocol.serializers.primitive.QuasselSerializer
import java.nio.ByteBuffer
import java.util.*
typealias QVariant_ = QVariant<*>
typealias QVariantList = List<QVariant_>
typealias QVariantMap = Map<String, QVariant_>
typealias QStringList = List<String?>
sealed class QVariant<T> constructor(
private val data: T,
open val serializer: QtSerializer<T>,
) {
class Typed<T> internal constructor(data: T, serializer: QtSerializer<T>) :
QVariant<T>(data, serializer)
sealed class QVariant<T> {
abstract val data: T
abstract val serializer: QtSerializer<T>
class Custom<T> internal constructor(data: T, override val serializer: QuasselSerializer<T>) :
QVariant<T>(data, serializer)
data class Typed<T> internal constructor(
override val data: T,
override val serializer: QtSerializer<T>
) : QVariant<T>() {
override fun toString() = super.toString()
}
data class Custom<T> internal constructor(
override val data: T,
override val serializer: QuasselSerializer<T>
) : QVariant<T>() {
override fun toString() = super.toString()
}
fun value(): T = data
......@@ -51,11 +58,13 @@ sealed class QVariant<T> constructor(
serializer.serialize(buffer, data, featureSet)
}
override fun toString() = when (data) {
override fun toString() = data.let {
when (it) {
is ByteBuffer ->
"QVariant(${serializer::class.java.simpleName}, ${data.contentToString()})"
"QVariant(${serializer::class.java.simpleName}, ${it.contentToString()})"
else ->
"QVariant(${serializer::class.java.simpleName}, $data)"
"QVariant(${serializer::class.java.simpleName}, $it)"
}
}
@Suppress("UNCHECKED_CAST")
......@@ -63,25 +72,6 @@ sealed class QVariant<T> constructor(
if (serializer.javaType == T::class.java && this.value() is T) this as QVariant<T>
else null
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as QVariant<*>
if (data != other.data) return false
if (serializer != other.serializer) return false
return true
}
override fun hashCode(): Int {
var result = data?.hashCode() ?: 0
result = 31 * result + serializer.hashCode()
return result
}
companion object {
fun <T> of(data: T, serializer: QtSerializer<T>) = Typed(data, serializer)
fun <T> of(data: T, serializer: QuasselSerializer<T>) = Custom(data, serializer)
......
......@@ -47,6 +47,18 @@ class StringEncoderTest {
)
}
@Test
fun testUnencodableString() {
assertEquals(
0,
ascii.encode("\uFFFF").remaining()
)
assertThat(
ascii.encode("\uFFFF"),
ByteBufferMatcher(byteBufferOf())
)
}
@Test
fun testNullChar() {
assertEquals(
......@@ -58,13 +70,9 @@ class StringEncoderTest {
ByteBufferMatcher(byteBufferOf(0))
)
assertEquals(
1,
utf8.encodeChar(null).remaining()
)
assertThat(
utf8.encodeChar(null),
ByteBufferMatcher(byteBufferOf(0))
ByteBufferMatcher(byteBufferOf(0xEFu, 0xBFu, 0xBDu))
)
assertEquals(
......@@ -73,19 +81,19 @@ class StringEncoderTest {
)
assertThat(
utf16.encodeChar(null),
ByteBufferMatcher(byteBufferOf(0, 0)),
ByteBufferMatcher(byteBufferOf(0xFFu, 0xFDu)),
)
}
@Test
fun testUnencodableChar() {
assertEquals(
2,
1,
ascii.encodeChar('\uFFFF').remaining()
)
assertThat(
ascii.encodeChar('\uFFFF'),
ByteBufferMatcher(byteBufferOf(0, 0))
ByteBufferMatcher(byteBufferOf(0))
)
}
}
......@@ -22,11 +22,25 @@ import de.kuschku.bitflags.none
import de.kuschku.libquassel.protocol.features.FeatureSet
import de.kuschku.libquassel.protocol.features.LegacyFeature
import de.kuschku.libquassel.protocol.messages.handshake.ClientInit
import de.kuschku.libquassel.protocol.serializers.HandshakeSerializers
import de.kuschku.libquassel.protocol.serializers.QtSerializers
import de.kuschku.libquassel.protocol.serializers.primitive.BoolSerializer
import de.kuschku.libquassel.protocol.testutil.byteBufferOf
import de.kuschku.libquassel.protocol.testutil.handshakeSerializerTest
import de.kuschku.libquassel.protocol.variant.QtType
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.Assertions.assertEquals as assertEquals
class ClientInitSerializerTest {
@Test
fun testIsRegistered() {
assertEquals(
ClientInitSerializer,
HandshakeSerializers.find<ClientInit>("ClientInit"),
)
}
@Test
fun testSimple() = handshakeSerializerTest(
ClientInitSerializer,
......
......@@ -18,11 +18,23 @@
*/
package de.kuschku.libquassel.protocol.serializers.primitive
import de.kuschku.libquassel.protocol.serializers.QtSerializers
import de.kuschku.libquassel.protocol.testutil.byteBufferOf
import de.kuschku.libquassel.protocol.testutil.qtSerializerTest
import de.kuschku.libquassel.protocol.variant.QtType
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
class BoolSerializerTest {
@Test
fun testIsRegistered() {
assertEquals(
BoolSerializer,
QtSerializers.find<Boolean>(QtType.Bool),
)
}
@Test
fun testTrue() = qtSerializerTest(
BoolSerializer,
......
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2020 Janne Mareike Koschinski
* Copyright (c) 2020 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.libquassel.protocol.serializers.primitive
import de.kuschku.libquassel.protocol.serializers.QuasselSerializers
import de.kuschku.libquassel.protocol.testutil.byteBufferOf
import de.kuschku.libquassel.protocol.testutil.qtSerializerTest
import de.kuschku.libquassel.protocol.testutil.quasselSerializerTest
import de.kuschku.libquassel.protocol.types.BufferId
import de.kuschku.libquassel.protocol.variant.QuasselType
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
class BufferIdSerializerTest {
@Test
fun testIsRegistered() {
assertEquals(
BufferIdSerializer,
QuasselSerializers.find<BufferId>(QuasselType.BufferId),
)
}
@Test
fun testZero() = quasselSerializerTest(
BufferIdSerializer,
BufferId(0),
byteBufferOf(0, 0, 0, 0)
)
@Test
fun testMinimal() = quasselSerializerTest(
BufferIdSerializer,
BufferId.MIN_VALUE,
byteBufferOf(-128, 0, 0, 0)
)
@Test
fun testMaximal() = quasselSerializerTest(
BufferIdSerializer,
BufferId.MAX_VALUE,
byteBufferOf(127, -1, -1, -1)
)
@Test
fun testAllOnes() = quasselSerializerTest(
BufferIdSerializer,
BufferId(0.inv()),
byteBufferOf(-1, -1, -1, -1)
)
}
......@@ -20,15 +20,29 @@ package de.kuschku.libquassel.protocol.serializers.primitive
import de.kuschku.bitflags.none
import de.kuschku.bitflags.validValues
import de.kuschku.libquassel.protocol.serializers.QtSerializers
import de.kuschku.libquassel.protocol.serializers.QuasselSerializers
import de.kuschku.libquassel.protocol.testutil.byteBufferOf
import de.kuschku.libquassel.protocol.testutil.quasselSerializerTest
import de.kuschku.libquassel.protocol.types.BufferId
import de.kuschku.libquassel.protocol.types.BufferInfo
import de.kuschku.libquassel.protocol.types.BufferType
import de.kuschku.libquassel.protocol.types.NetworkId
import de.kuschku.libquassel.protocol.variant.QtType
import de.kuschku.libquassel.protocol.variant.QuasselType
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
class BufferInfoSerializerTest {
@Test
fun testIsRegistered() {
assertEquals(
BufferInfoSerializer,
QuasselSerializers.find<BufferInfo>(QuasselType.BufferInfo),
)
}
@Test
fun testBaseCase() = quasselSerializerTest(
BufferInfoSerializer,
......
......@@ -18,13 +18,25 @@
*/
package de.kuschku.libquassel.protocol.serializers.primitive
import de.kuschku.libquassel.protocol.serializers.QtSerializers
import de.kuschku.libquassel.protocol.testutil.byteBufferOf
import de.kuschku.libquassel.protocol.testutil.matchers.ByteBufferMatcher
import de.kuschku.libquassel.protocol.testutil.qtSerializerTest
import de.kuschku.libquassel.protocol.variant.QtType
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import java.nio.ByteBuffer
class ByteBufferSerializerTest {
@Test
fun testIsRegistered() {
assertEquals(
ByteBufferSerializer,
QtSerializers.find<ByteBuffer>(QtType.QByteArray),
)
}
@Test
fun testBaseCase() = qtSerializerTest(
ByteBufferSerializer,
......
......@@ -18,12 +18,25 @@
*/
package de.kuschku.libquassel.protocol.serializers.primitive
import de.kuschku.libquassel.protocol.serializers.QtSerializers
import de.kuschku.libquassel.protocol.testutil.byteBufferOf
import de.kuschku.libquassel.protocol.testutil.qtSerializerTest
import de.kuschku.libquassel.protocol.variant.QtType
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import java.nio.ByteBuffer
import kotlin.experimental.inv
class ByteSerializerTest {
@Test
fun testIsRegistered() {
assertEquals(
ByteSerializer,
QtSerializers.find<Byte>(QtType.Char),
)
}
@Test
fun testZero() = qtSerializerTest(
ByteSerializer,
......
......@@ -18,16 +18,27 @@
*/
package de.kuschku.libquassel.protocol.serializers.primitive
import de.kuschku.libquassel.protocol.serializers.QtSerializers
import de.kuschku.libquassel.protocol.testutil.byteBufferOf
import de.kuschku.libquassel.protocol.testutil.matchers.TemporalMatcher
import de.kuschku.libquassel.protocol.testutil.qtSerializerTest
import de.kuschku.libquassel.protocol.variant.QtType
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.threeten.bp.*
import org.threeten.bp.chrono.JapaneseDate
import org.threeten.bp.temporal.Temporal
class DateTimeSerializerTest {
private val serializer = DateTimeSerializer
@Test
fun testIsRegistered() {
assertEquals(
DateTimeSerializer,
QtSerializers.find<Temporal>(QtType.QDateTime),
)
}
@Test
fun testEpoch() = qtSerializerTest(
......
......@@ -18,11 +18,24 @@
*/
package de.kuschku.libquassel.protocol.serializers.primitive
import de.kuschku.libquassel.protocol.serializers.QtSerializers
import de.kuschku.libquassel.protocol.testutil.byteBufferOf
import de.kuschku.libquassel.protocol.testutil.qtSerializerTest
import de.kuschku.libquassel.protocol.variant.QtType
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.threeten.bp.temporal.Temporal
class DoubleSerializerTest {
@Test
fun testIsRegistered() {
assertEquals(
DoubleSerializer,
QtSerializers.find<Double>(QtType.Double),
)
}
@Test
fun testZero() = qtSerializerTest(
DoubleSerializer,
......
......@@ -18,11 +18,23 @@
*/
package de.kuschku.libquassel.protocol.serializers.primitive
import de.kuschku.libquassel.protocol.serializers.QtSerializers
import de.kuschku.libquassel.protocol.testutil.byteBufferOf
import de.kuschku.libquassel.protocol.testutil.qtSerializerTest
import de.kuschku.libquassel.protocol.variant.QtType
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
class FloatSerializerTest {
@Test
fun testIsRegistered() {
assertEquals(
FloatSerializer,
QtSerializers.find<Float>(QtType.Float),
)
}
@Test
fun testZero() = qtSerializerTest(
FloatSerializer,
......
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2020 Janne Mareike Koschinski
* Copyright (c) 2020 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.libquassel.protocol.serializers.primitive
import de.kuschku.libquassel.protocol.serializers.QuasselSerializers
import de.kuschku.libquassel.protocol.testutil.byteBufferOf
import de.kuschku.libquassel.protocol.testutil.qtSerializerTest
import de.kuschku.libquassel.protocol.testutil.quasselSerializerTest
import de.kuschku.libquassel.protocol.types.IdentityId
import de.kuschku.libquassel.protocol.variant.QuasselType
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
class IdentityIdSerializerTest {
@Test
fun testIsRegistered() {
assertEquals(
IdentityIdSerializer,
QuasselSerializers.find<IdentityId>(QuasselType.IdentityId),
)
}
@Test
fun testZero() = quasselSerializerTest(
IdentityIdSerializer,
IdentityId(0),
byteBufferOf(0, 0, 0, 0)
)
@Test
fun testMinimal() = quasselSerializerTest(
IdentityIdSerializer,
IdentityId.MIN_VALUE,
byteBufferOf(-128, 0, 0, 0)
)
@Test
fun testMaximal() = quasselSerializerTest(
IdentityIdSerializer,
IdentityId.MAX_VALUE,
byteBufferOf(127, -1, -1, -1)
)
@Test
fun testAllOnes() = quasselSerializerTest(
IdentityIdSerializer,
IdentityId(0.inv()),
byteBufferOf(-1, -1, -1, -1)
)
}
......@@ -18,11 +18,23 @@
*/
package de.kuschku.libquassel.protocol.serializers.primitive
import de.kuschku.libquassel.protocol.serializers.QtSerializers
import de.kuschku.libquassel.protocol.testutil.byteBufferOf
import de.kuschku.libquassel.protocol.testutil.qtSerializerTest
import de.kuschku.libquassel.protocol.variant.QtType
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
class IntSerializerTest {
@Test
fun testIsRegistered() {
assertEquals(
IntSerializer,
QtSerializers.find<Int>(QtType.Int),
)
}
@Test
fun testZero() = qtSerializerTest(
IntSerializer,
......
......@@ -18,11 +18,23 @@
*/
package de.kuschku.libquassel.protocol.serializers.primitive
import de.kuschku.libquassel.protocol.serializers.QtSerializers
import de.kuschku.libquassel.protocol.testutil.byteBufferOf
import de.kuschku.libquassel.protocol.testutil.qtSerializerTest
import de.kuschku.libquassel.protocol.variant.QtType
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
class LongSerializerTest {
@Test
fun testIsRegistered() {
assertEquals(
LongSerializer,
QtSerializers.find<Long>(QtType.Long),
)
}
@Test
fun testZero() = qtSerializerTest(
LongSerializer,
......
......@@ -22,13 +22,28 @@ package de.kuschku.libquassel.protocol.serializers.primitive
import de.kuschku.bitflags.none
import de.kuschku.bitflags.validValues
import de.kuschku.libquassel.protocol.features.FeatureSet
import de.kuschku.libquassel.protocol.serializers.QtSerializers
import de.kuschku.libquassel.protocol.serializers.QuasselSerializers
import de.kuschku.libquassel.protocol.testutil.byteBufferOf
import de.kuschku.libquassel.protocol.testutil.quasselSerializerTest
import de.kuschku.libquassel.protocol.types.*
import de.kuschku.libquassel.protocol.variant.QtType
import de.kuschku.libquassel.protocol.variant.QuasselType
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.threeten.bp.Instant
import java.nio.ByteBuffer
class MessageSerializerTest {
@Test
fun testIsRegistered() {
assertEquals(
MessageSerializer,
QuasselSerializers.find<Message>(QuasselType.Message),
)
}
@Test
fun testEmpty() = quasselSerializerTest(
MessageSerializer,
......
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2020 Janne Mareike Koschinski
* Copyright (c) 2020 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.libquassel.protocol.serializers.primitive
import de.kuschku.libquassel.protocol.features.FeatureSet
import de.kuschku.libquassel.protocol.serializers.QuasselSerializers
import de.kuschku.libquassel.protocol.testutil.byteBufferOf
import de.kuschku.libquassel.protocol.testutil.quasselSerializerTest
import de.kuschku.libquassel.protocol.types.MsgId
import de.kuschku.libquassel.protocol.variant.QuasselType
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
class MsgIdSerializerTest {
@Test
fun testIsRegistered() {
assertEquals(
MsgIdSerializer,
QuasselSerializers.find<MsgId>(QuasselType.MsgId),
)
}
@Test
fun testZero() = quasselSerializerTest(
MsgIdSerializer,
MsgId(0),
byteBufferOf(0, 0, 0, 0, 0, 0, 0, 0),
featureSets = listOf(FeatureSet.all())
)
@Test
fun testMinimal() = quasselSerializerTest(
MsgIdSerializer,
MsgId.MIN_VALUE,
byteBufferOf(-128, 0, 0, 0, 0, 0, 0, 0),
featureSets = listOf(FeatureSet.all())
)
@Test
fun testMaximal() = quasselSerializerTest(
MsgIdSerializer,
MsgId.MAX_VALUE,
byteBufferOf(127, -1, -1, -1, -1, -1, -1, -1),
featureSets = listOf(FeatureSet.all())
)
@Test
fun testAllOnes() = quasselSerializerTest(
MsgIdSerializer,
MsgId(0.inv()),
byteBufferOf(-1, -1, -1, -1, -1, -1, -1, -1),
featureSets = listOf(FeatureSet.all())
)
}
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2020 Janne Mareike Koschinski
* Copyright (c) 2020 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.libquassel.protocol.serializers.primitive
import de.kuschku.libquassel.protocol.serializers.QuasselSerializers
import de.kuschku.libquassel.protocol.testutil.byteBufferOf
import de.kuschku.libquassel.protocol.testutil.qtSerializerTest
import de.kuschku.libquassel.protocol.testutil.quasselSerializerTest
import de.kuschku.libquassel.protocol.types.NetworkId
import de.kuschku.libquassel.protocol.variant.QuasselType
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
class NetworkIdSerializerTest {
@Test
fun testIsRegistered() {
assertEquals(
NetworkIdSerializer,
QuasselSerializers.find<NetworkId>(QuasselType.NetworkId),
)
}
@Test
fun testZero() = quasselSerializerTest(
NetworkIdSerializer,
NetworkId(0),
byteBufferOf(0, 0, 0, 0)
)
@Test
fun testMinimal() = quasselSerializerTest(
NetworkIdSerializer,
NetworkId.MIN_VALUE,
byteBufferOf(-128, 0, 0, 0)
)
@Test
fun testMaximal() = quasselSerializerTest(
NetworkIdSerializer,
NetworkId.MAX_VALUE,
byteBufferOf(127, -1, -1, -1)
)
@Test
fun testAllOnes() = quasselSerializerTest(
NetworkIdSerializer,
NetworkId(0.inv()),
byteBufferOf(-1, -1, -1, -1)
)
}
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2020 Janne Mareike Koschinski
* Copyright (c) 2020 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.libquassel.protocol.serializers.primitive
import de.kuschku.libquassel.protocol.features.FeatureSet
import de.kuschku.libquassel.protocol.serializers.QuasselSerializers
import de.kuschku.libquassel.protocol.testutil.byteBufferOf
import de.kuschku.libquassel.protocol.testutil.quasselSerializerTest
import de.kuschku.libquassel.protocol.types.MsgId
import de.kuschku.libquassel.protocol.variant.QuasselType
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
class PeerPtrSerializerTest {
@Test
fun testIsRegistered() {
assertEquals(
PeerPtrSerializer,
QuasselSerializers.find<ULong>(QuasselType.PeerPtr),
)
}
@Test
fun testZero() = quasselSerializerTest(
PeerPtrSerializer,
0uL,
byteBufferOf(0, 0, 0, 0, 0, 0, 0, 0),
featureSets = listOf(FeatureSet.all())
)
@Test
fun testMinimal() = quasselSerializerTest(
PeerPtrSerializer,
ULong.MIN_VALUE,
byteBufferOf(0, 0, 0, 0, 0, 0, 0, 0),
featureSets = listOf(FeatureSet.all())
)
@Test
fun testMaximal() = quasselSerializerTest(
PeerPtrSerializer,
ULong.MAX_VALUE,
byteBufferOf(-1, -1, -1, -1, -1, -1, -1, -1),
featureSets = listOf(FeatureSet.all())
)
@Test
fun testAllOnes() = quasselSerializerTest(
PeerPtrSerializer,
0uL.inv(),
byteBufferOf(-1, -1, -1, -1, -1, -1, -1, -1),
featureSets = listOf(FeatureSet.all())
)
}
......@@ -18,12 +18,24 @@
*/
package de.kuschku.libquassel.protocol.serializers.primitive
import de.kuschku.libquassel.protocol.serializers.QtSerializers
import de.kuschku.libquassel.protocol.testutil.byteBufferOf
import de.kuschku.libquassel.protocol.testutil.matchers.BomMatcherChar
import de.kuschku.libquassel.protocol.testutil.qtSerializerTest
import de.kuschku.libquassel.protocol.variant.QtType
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
class QCharSerializerTest {
@Test
fun testIsRegistered() {
assertEquals(
QCharSerializer,
QtSerializers.find<Char>(QtType.QChar),
)
}
@Test
fun testNull() = qtSerializerTest(
QCharSerializer,
......
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2020 Janne Mareike Koschinski
* Copyright (c) 2020 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.libquassel.protocol.serializers.primitive
import de.kuschku.libquassel.protocol.serializers.QtSerializers
import de.kuschku.libquassel.protocol.testutil.byteBufferOf
import de.kuschku.libquassel.protocol.testutil.matchers.MapMatcher
import de.kuschku.libquassel.protocol.testutil.qtSerializerTest
import de.kuschku.libquassel.protocol.variant.QVariantList
import de.kuschku.libquassel.protocol.variant.QVariantMap
import de.kuschku.libquassel.protocol.variant.QtType
import de.kuschku.libquassel.protocol.variant.qVariant
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
class QVariantListSerializerTest {
@Test
fun testIsRegistered() {
assertEquals(
QVariantListSerializer,
QtSerializers.find<QVariantList>(QtType.QVariantList),
)
}
@Test
fun testEmpty() = qtSerializerTest(
QVariantListSerializer,
listOf(),
byteBufferOf(0, 0, 0, 0)
)
@Test
fun testNormal() = qtSerializerTest(
QVariantListSerializer,
listOf(
qVariant("AzureDiamond", QtType.QString),
qVariant("hunter2", QtType.QString)
),
byteBufferOf( 0x00u, 0x00u, 0x00u, 0x02u, 0x00u, 0x00u, 0x00u, 0x0Au, 0x00u, 0x00u, 0x00u, 0x00u, 0x18u, 0x00u, 0x41u, 0x00u, 0x7Au, 0x00u, 0x75u, 0x00u, 0x72u, 0x00u, 0x65u, 0x00u, 0x44u, 0x00u, 0x69u, 0x00u, 0x61u, 0x00u, 0x6Du, 0x00u, 0x6Fu, 0x00u, 0x6Eu, 0x00u, 0x64u, 0x00u, 0x00u, 0x00u, 0x0Au, 0x00u, 0x00u, 0x00u, 0x00u, 0x0Eu, 0x00u, 0x68u, 0x00u, 0x75u, 0x00u, 0x6Eu, 0x00u, 0x74u, 0x00u, 0x65u, 0x00u, 0x72u, 0x00u, 0x32u)
)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment