alternate constructor for HotSpotInfo; testing; updated commentary

This commit is contained in:
FateJH 2016-09-22 16:28:09 -04:00
parent d40f64c053
commit b1615aa4d9
2 changed files with 57 additions and 13 deletions

View file

@ -5,6 +5,7 @@ import org.specs2.mutable._
import net.psforever.packet._
import net.psforever.packet.game._
import net.psforever.types._
import scodec.Attempt
import scodec.Attempt.Successful
import scodec.bits._
@ -915,6 +916,34 @@ class GamePacketTest extends Specification {
}
}
"HotSpotInfo" should {
val string = hex"00 D0 70 08 CA 80 00 00" // note: completing that last byte is required to avoid it being placed at the start of the vector
"decode" in {
HotSpotInfo.codec.decode(string.toBitVector) match {
case Attempt.Successful(decoded) =>
decoded.value.x mustEqual 2000
decoded.value.y mustEqual 2700
decoded.value.scale mustEqual 128
case _ =>
ko
}
}
"encode (long-hand)" in {
val msg = HotSpotInfo(0, 2000, 0, 2700, 128)
val pkt = HotSpotInfo.codec.encode(msg).require.toByteVector
pkt mustEqual string
}
"encode (short-hand)" in {
val msg = HotSpotInfo(2000, 2700, 128)
val pkt = HotSpotInfo.codec.encode(msg).require.toByteVector
pkt mustEqual string
}
}
"HotSpotUpdateMessage" should {
val stringClear = hex"9F 0500 1 00 0"
val stringOne = hex"9F 0500 1 01 0 00 2E9 00 145 80000 0"