mirror of
https://github.com/psforever/PSF-LoginServer.git
synced 2026-01-19 18:44:45 +00:00
Merge pull request #18 from tfarley/pkt-chatmsg-tests
Add tests for ChatMsg encoding and decoding
This commit is contained in:
commit
ecef89c91e
|
|
@ -4,6 +4,7 @@ import java.net.{InetAddress, InetSocketAddress}
|
||||||
import org.specs2.mutable._
|
import org.specs2.mutable._
|
||||||
import net.psforever.packet._
|
import net.psforever.packet._
|
||||||
import net.psforever.packet.game._
|
import net.psforever.packet.game._
|
||||||
|
import net.psforever.types._
|
||||||
import scodec.Attempt.Successful
|
import scodec.Attempt.Successful
|
||||||
import scodec.bits._
|
import scodec.bits._
|
||||||
|
|
||||||
|
|
@ -163,5 +164,44 @@ class GamePacketTest extends Specification {
|
||||||
ok
|
ok
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"ChatMsg" should {
|
||||||
|
val string_local = hex"12 1A C000 83610062006300"
|
||||||
|
val string_tell = hex"12 20 C180640065006600 83610062006300"
|
||||||
|
|
||||||
|
"decode" in {
|
||||||
|
PacketCoding.DecodePacket(string_local).require match {
|
||||||
|
case ChatMsg(messagetype, unk1, recipient, contents) =>
|
||||||
|
messagetype mustEqual ChatMessageType.Local
|
||||||
|
unk1 mustEqual true
|
||||||
|
recipient mustEqual ""
|
||||||
|
contents mustEqual "abc"
|
||||||
|
case default =>
|
||||||
|
ko
|
||||||
|
}
|
||||||
|
|
||||||
|
PacketCoding.DecodePacket(string_tell).require match {
|
||||||
|
case ChatMsg(messagetype, unk1, recipient, contents) =>
|
||||||
|
messagetype mustEqual ChatMessageType.Tell
|
||||||
|
unk1 mustEqual true
|
||||||
|
recipient mustEqual "def"
|
||||||
|
contents mustEqual "abc"
|
||||||
|
case default =>
|
||||||
|
ko
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
"encode" in {
|
||||||
|
val msg_local = ChatMsg(ChatMessageType.Local, true, "", "abc")
|
||||||
|
val pkt_local = PacketCoding.EncodePacket(msg_local).require.toByteVector
|
||||||
|
|
||||||
|
pkt_local mustEqual string_local
|
||||||
|
|
||||||
|
val msg_tell = ChatMsg(ChatMessageType.Tell, true, "def", "abc")
|
||||||
|
val pkt_tell = PacketCoding.EncodePacket(msg_tell).require.toByteVector
|
||||||
|
|
||||||
|
pkt_tell mustEqual string_tell
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue