mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-24 14:30:09 +08:00
Rename buildChecks
to buildCodingChecks
This commit is contained in:
parent
3270192715
commit
52968b172f
@ -63,6 +63,10 @@ internal abstract class AbstractMessageProtocolTest : AbstractMockNetworkHandler
|
||||
return MessageProtocolFacadeImpl(protocols.toList())
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// coding
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
protected fun doEncoderChecks(
|
||||
expectedStruct: List<ImMsgBody.Elem>,
|
||||
protocols: Array<out MessageProtocol>,
|
||||
@ -114,7 +118,7 @@ internal abstract class AbstractMessageProtocolTest : AbstractMockNetworkHandler
|
||||
): Unit = doEncoderChecks(expectedStruct.toList(), protocols, encode)
|
||||
|
||||
|
||||
inner class ChecksBuilder {
|
||||
inner class CodingChecksBuilder {
|
||||
var elems: MutableList<ImMsgBody.Elem> = mutableListOf()
|
||||
var messages: MessageChainBuilder = MessageChainBuilder()
|
||||
|
||||
@ -170,11 +174,11 @@ internal abstract class AbstractMessageProtocolTest : AbstractMockNetworkHandler
|
||||
)
|
||||
|
||||
@Suppress("DeferredIsResult")
|
||||
protected fun buildChecks(
|
||||
builderAction: ChecksBuilder.() -> Unit,
|
||||
protected fun buildCodingChecks(
|
||||
builderAction: CodingChecksBuilder.() -> Unit,
|
||||
): Deferred<ChecksConfiguration> { // IDE will warn you if you forget to call .do
|
||||
contract { callsInPlace(builderAction, InvocationKind.EXACTLY_ONCE) }
|
||||
return CompletableDeferred(ChecksBuilder().apply(builderAction).build())
|
||||
return CompletableDeferred(CodingChecksBuilder().apply(builderAction).build())
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
@ -202,4 +206,10 @@ internal abstract class AbstractMessageProtocolTest : AbstractMockNetworkHandler
|
||||
doEncoderChecks()
|
||||
doDecoderChecks()
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// sending
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
}
|
@ -55,7 +55,7 @@ internal class CustomMessageProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `test encode`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
customElem = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.CustomElem(
|
||||
@ -70,7 +70,7 @@ internal class CustomMessageProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `test decode`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
customElem = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.CustomElem(
|
||||
|
@ -28,7 +28,7 @@ internal class FileMessageProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `test decode`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
elemFlags2 = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.ElemFlags2(
|
||||
|
Binary file not shown.
@ -33,7 +33,7 @@ internal class ImageProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `group Image receive from macOS`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
customFace = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.CustomFace(
|
||||
@ -68,7 +68,7 @@ internal class ImageProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `friend Image receive from macOS`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
notOnlineImage = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.NotOnlineImage(
|
||||
@ -107,7 +107,7 @@ internal class ImageProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `group Image receive from Android`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
customFace = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.CustomFace(
|
||||
@ -150,7 +150,7 @@ internal class ImageProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `friend Image receive from Android`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
notOnlineImage = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.NotOnlineImage(
|
||||
@ -193,7 +193,7 @@ internal class ImageProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `group Image receive from iOS`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
notOnlineImage = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.NotOnlineImage(
|
||||
@ -232,7 +232,7 @@ internal class ImageProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `friend Image receive from iOS`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
notOnlineImage = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.NotOnlineImage(
|
||||
@ -275,7 +275,7 @@ internal class ImageProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `group Image receive from Windows`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
customFace = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.CustomFace(
|
||||
@ -315,7 +315,7 @@ internal class ImageProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `friend Image receive from Windows`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
notOnlineImage = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.NotOnlineImage(
|
||||
@ -357,7 +357,7 @@ internal class ImageProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `group Image receive from iPadOS`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
customFace = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.CustomFace(
|
||||
@ -397,7 +397,7 @@ internal class ImageProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `friend Image receive from iPadOS`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
notOnlineImage = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.NotOnlineImage(
|
||||
@ -440,7 +440,7 @@ internal class ImageProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `group Image send without dimension`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
customFace = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.CustomFace(
|
||||
@ -464,7 +464,7 @@ internal class ImageProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `friend Image send without dimension`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
notOnlineImage = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.NotOnlineImage(
|
||||
@ -493,7 +493,7 @@ internal class ImageProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `group Image send with dimension`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
customFace = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.CustomFace(
|
||||
@ -522,13 +522,13 @@ internal class ImageProtocolTest : AbstractMessageProtocolTest() {
|
||||
}.doEncoderChecks()
|
||||
}
|
||||
|
||||
private fun ChecksBuilder.targetGroup() {
|
||||
private fun CodingChecksBuilder.targetGroup() {
|
||||
target(bot.addGroup(1, 1))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `friend Image send with dimension`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
notOnlineImage = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.NotOnlineImage(
|
||||
@ -557,7 +557,7 @@ internal class ImageProtocolTest : AbstractMessageProtocolTest() {
|
||||
}.doEncoderChecks()
|
||||
}
|
||||
|
||||
private fun ChecksBuilder.targetFriend() {
|
||||
private fun CodingChecksBuilder.targetFriend() {
|
||||
target(bot.addFriend(1))
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ internal class MarketFaceProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `decode Dice`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
marketFace = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.MarketFace(
|
||||
@ -65,7 +65,7 @@ internal class MarketFaceProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `encode Dice`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
marketFace = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.MarketFace(
|
||||
@ -99,7 +99,7 @@ internal class MarketFaceProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `encode decode MarketFace from Android`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
marketFace = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.MarketFace(
|
||||
@ -147,7 +147,7 @@ internal class MarketFaceProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `encode decode MarketFace from macOS`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
marketFace = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.MarketFace(
|
||||
|
@ -33,7 +33,7 @@ internal class MusicShareProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `decode from Android`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
lightApp = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.LightAppElem(
|
||||
|
@ -28,7 +28,7 @@ internal class PokeMessageProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `test PokeMessage`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
commonElem = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.CommonElem(
|
||||
@ -64,7 +64,7 @@ internal class PokeMessageProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun encode() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
commonElem = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.CommonElem(
|
||||
|
@ -25,6 +25,24 @@
|
||||
* https://github.com/mamoe/mirai/blob/dev/LICENSE
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2019-2022 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/dev/LICENSE
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2019-2022 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/dev/LICENSE
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.internal.message.protocol.impl
|
||||
|
||||
import net.mamoe.mirai.internal.message.protocol.MessageProtocol
|
||||
@ -40,7 +58,7 @@ internal class QuoteReplyProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `decode group reference group`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
srcMsg = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.SourceMsg(
|
||||
@ -98,11 +116,11 @@ internal class QuoteReplyProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
}
|
||||
|
||||
private fun ChecksBuilder.targetGroup() {
|
||||
private fun CodingChecksBuilder.targetGroup() {
|
||||
target(bot.addGroup(1, 1))
|
||||
}
|
||||
|
||||
private fun ChecksBuilder.targetFriend() {
|
||||
private fun CodingChecksBuilder.targetFriend() {
|
||||
target(bot.addFriend(1))
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ internal class RichMessageProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `decode from Android`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
richMsg = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.RichMsg(
|
||||
@ -59,7 +59,7 @@ internal class RichMessageProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun encode() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
richMsg = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.RichMsg(
|
||||
|
@ -30,7 +30,7 @@ internal class TextProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `test PlainText`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
text = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Text(
|
||||
@ -44,7 +44,7 @@ internal class TextProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `test AtAll`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
text = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Text(
|
||||
@ -59,7 +59,7 @@ internal class TextProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `AtAll auto append spaces`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
text = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Text(
|
||||
@ -79,7 +79,7 @@ internal class TextProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `test At`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
text = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Text(
|
||||
@ -94,7 +94,7 @@ internal class TextProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `At auto append spaces`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
text = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Text(
|
||||
|
@ -28,7 +28,7 @@ internal class VipFaceProtocolTest : AbstractMessageProtocolTest() {
|
||||
|
||||
@Test
|
||||
fun `test decode`() {
|
||||
buildChecks {
|
||||
buildCodingChecks {
|
||||
elem(
|
||||
net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.Elem(
|
||||
commonElem = net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody.CommonElem(
|
||||
|
Loading…
Reference in New Issue
Block a user