Commit e7ea1968 authored by Him188's avatar Him188

Fix test

parent 2f9d104f
......@@ -35,7 +35,7 @@ class MessageSvc {
.readRemainingAsJceStruct(RequestPushNotify.serializer())
println(requestPushNotify.contentToString())
TODO()
return requestPushNotify
}
}
}
......
......@@ -9,10 +9,6 @@ import net.mamoe.mirai.qqandroid.io.buildJcePacket
import net.mamoe.mirai.utils.cryptor.contentToString
import kotlin.test.Test
fun main() {
JceDecoderTest().testSimpleMap()
}
class JceDecoderTest {
@Serializable
......@@ -40,7 +36,7 @@ class JceDecoderTest {
@Serializable
class TestComplexJceStruct(
@SerialId(6) val string: String = "haha",
@SerialId(7) val byteArray: ByteArray = ByteArray(2000),
@SerialId(7) val byteArray: ByteArray = ByteArray(500),
@SerialId(8) val byteList: List<Byte> = listOf(1, 2, 3), // error here
@SerialId(9) val map: Map<String, Map<String, ByteArray>> = mapOf("哈哈" to mapOf("哈哈" to byteArrayOf(1, 2, 3))),
// @SerialId(10) val nestedJceStruct: TestSimpleJceStruct = TestSimpleJceStruct(),
......@@ -59,12 +55,22 @@ class JceDecoderTest {
@Test
fun testEncoder() {
println(TestComplexJceStruct().toByteArray(TestComplexJceStruct.serializer()).loadAs(TestComplexNullableJceStruct.serializer()).contentToString())
println(
TestComplexJceStruct().toByteArray(TestComplexJceStruct.serializer()).loadAs(
TestComplexNullableJceStruct.serializer(),
JceCharset.UTF8
).contentToString()
)
}
@Test
fun testEncoder3() {
println(TestComplexNullableJceStruct().toByteArray(TestComplexNullableJceStruct.serializer()).loadAs(TestComplexNullableJceStruct.serializer()).contentToString())
println(
TestComplexNullableJceStruct().toByteArray(TestComplexNullableJceStruct.serializer()).loadAs(
TestComplexNullableJceStruct.serializer(),
JceCharset.UTF8
).contentToString()
)
}
@Test
......
......@@ -181,4 +181,4 @@ fun ByteArray.toInt(): Int =
* 从 [IoBuffer.Pool] [borrow][ObjectPool.borrow] 一个 [IoBuffer] 然后将 [this] 写入.
* 注意回收 ([ObjectPool.recycle])
*/
fun ByteArray.toIoBuffer(offset: Int = 0, length: Int = this.size - offset): IoBuffer = IoBuffer.Pool.borrow().let { it.writeFully(this, offset, length); it }
\ No newline at end of file
fun ByteArray.toIoBuffer(offset: Int = 0, length: Int = this.size - offset, pool: ObjectPool<IoBuffer> = IoBuffer.Pool): IoBuffer = pool.borrow().let { it.writeFully(this, offset, length); it }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment