mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-09 18:00:33 +08:00
Fix test
This commit is contained in:
parent
2f9d104f88
commit
e7ea19682a
@ -35,7 +35,7 @@ class MessageSvc {
|
|||||||
.readRemainingAsJceStruct(RequestPushNotify.serializer())
|
.readRemainingAsJceStruct(RequestPushNotify.serializer())
|
||||||
|
|
||||||
println(requestPushNotify.contentToString())
|
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 net.mamoe.mirai.utils.cryptor.contentToString
|
||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
|
|
||||||
fun main() {
|
|
||||||
JceDecoderTest().testSimpleMap()
|
|
||||||
}
|
|
||||||
|
|
||||||
class JceDecoderTest {
|
class JceDecoderTest {
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@ -40,7 +36,7 @@ class JceDecoderTest {
|
|||||||
@Serializable
|
@Serializable
|
||||||
class TestComplexJceStruct(
|
class TestComplexJceStruct(
|
||||||
@SerialId(6) val string: String = "haha",
|
@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(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(9) val map: Map<String, Map<String, ByteArray>> = mapOf("哈哈" to mapOf("哈哈" to byteArrayOf(1, 2, 3))),
|
||||||
// @SerialId(10) val nestedJceStruct: TestSimpleJceStruct = TestSimpleJceStruct(),
|
// @SerialId(10) val nestedJceStruct: TestSimpleJceStruct = TestSimpleJceStruct(),
|
||||||
@ -59,12 +55,22 @@ class JceDecoderTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testEncoder() {
|
fun testEncoder() {
|
||||||
println(TestComplexJceStruct().toByteArray(TestComplexJceStruct.serializer()).loadAs(TestComplexNullableJceStruct.serializer()).contentToString())
|
println(
|
||||||
|
TestComplexJceStruct().toByteArray(TestComplexJceStruct.serializer()).loadAs(
|
||||||
|
TestComplexNullableJceStruct.serializer(),
|
||||||
|
JceCharset.UTF8
|
||||||
|
).contentToString()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testEncoder3() {
|
fun testEncoder3() {
|
||||||
println(TestComplexNullableJceStruct().toByteArray(TestComplexNullableJceStruct.serializer()).loadAs(TestComplexNullableJceStruct.serializer()).contentToString())
|
println(
|
||||||
|
TestComplexNullableJceStruct().toByteArray(TestComplexNullableJceStruct.serializer()).loadAs(
|
||||||
|
TestComplexNullableJceStruct.serializer(),
|
||||||
|
JceCharset.UTF8
|
||||||
|
).contentToString()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -181,4 +181,4 @@ fun ByteArray.toInt(): Int =
|
|||||||
* 从 [IoBuffer.Pool] [borrow][ObjectPool.borrow] 一个 [IoBuffer] 然后将 [this] 写入.
|
* 从 [IoBuffer.Pool] [borrow][ObjectPool.borrow] 一个 [IoBuffer] 然后将 [this] 写入.
|
||||||
* 注意回收 ([ObjectPool.recycle])
|
* 注意回收 ([ObjectPool.recycle])
|
||||||
*/
|
*/
|
||||||
fun ByteArray.toIoBuffer(offset: Int = 0, length: Int = this.size - offset): IoBuffer = IoBuffer.Pool.borrow().let { it.writeFully(this, offset, length); it }
|
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 }
|
Loading…
Reference in New Issue
Block a user