mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-02-25 17:33:33 +00:00
adjusted workflow of Codec to better account for String padding and to consolidate different data formats; added comments; added working (simple) test
This commit is contained in:
parent
73c88fb9de
commit
7d158eba1a
2 changed files with 233 additions and 56 deletions
39
common/src/test/scala/game/BattleplanMessageTest.scala
Normal file
39
common/src/test/scala/game/BattleplanMessageTest.scala
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package game
|
||||
|
||||
import org.specs2.mutable._
|
||||
import net.psforever.packet._
|
||||
import net.psforever.packet.game._
|
||||
import scodec.bits._
|
||||
|
||||
class BattleplanMessageTest extends Specification {
|
||||
val string = hex"b3 3a197902 94 59006500740041006e006f0074006800650072004600610069006c0075007200650041006c007400 0000 01 e0"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
case BattleplanMessage(unk1, mastermind, unk2, diagrams) =>
|
||||
unk1 mustEqual 41490746
|
||||
mastermind mustEqual "YetAnotherFailureAlt"
|
||||
unk2 mustEqual 0
|
||||
diagrams.size mustEqual 1
|
||||
//h0
|
||||
diagrams.head.pageNum mustEqual 14
|
||||
diagrams.head.sheet.isDefined mustEqual false
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val msg = BattleplanMessage(
|
||||
41490746,
|
||||
"YetAnotherFailureAlt",
|
||||
0,
|
||||
BattleDiagram(14) ::
|
||||
Nil
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue