PSF-BotServer/common/src/test/scala/game/DisconnectMessageTest.scala
Fate-JH 6001446cd5 Split Up GamePacketTest (#102)
* split up GamePacketTest into separate testing files

* PR wants this file?
2017-03-04 10:06:10 -05:00

30 lines
780 B
Scala

// Copyright (c) 2016 PSForever.net to present
package game
import org.specs2.mutable._
import net.psforever.packet._
import net.psforever.packet.game._
import scodec.bits._
class DisconnectMessageTest extends Specification {
val string = hex"B7 85 46 69 72 73 74 86 53 65 63 6F 6E 64 8E 46 69 72 73 74 20 26 20 73 65 63 6F 6E 64"
"decode" in {
PacketCoding.DecodePacket(string).require match {
case DisconnectMessage(unk1, unk2, unk3) =>
unk1 mustEqual "First"
unk2 mustEqual "Second"
unk3 mustEqual "First & second"
case _ =>
ko
}
}
"encode" in {
val msg = DisconnectMessage("First", "Second", "First & second")
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
pkt mustEqual string
}
}