mirror of
https://github.com/psforever/PSF-LoginServer.git
synced 2026-02-13 03:33:40 +00:00
Restructure repository
* Move /common/src to /src * Move services to net.psforever package * Move /pslogin to /server
This commit is contained in:
parent
89a30ae6f6
commit
f4fd78fc5d
958 changed files with 527 additions and 725 deletions
52
src/test/scala/game/DensityLevelUpdateMessageTest.scala
Normal file
52
src/test/scala/game/DensityLevelUpdateMessageTest.scala
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package game
|
||||
|
||||
import org.specs2.mutable._
|
||||
import net.psforever.packet._
|
||||
import net.psforever.packet.game._
|
||||
import scodec.bits._
|
||||
|
||||
class DensityLevelUpdateMessageTest extends Specification {
|
||||
val string = hex"cd 0100 1f4e 000000"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
case DensityLevelUpdateMessage(zone_id, building_id, unk) =>
|
||||
zone_id mustEqual 1
|
||||
building_id mustEqual 19999
|
||||
unk.length mustEqual 8
|
||||
unk.head mustEqual 0
|
||||
unk(1) mustEqual 0
|
||||
unk(2) mustEqual 0
|
||||
unk(3) mustEqual 0
|
||||
unk(4) mustEqual 0
|
||||
unk(5) mustEqual 0
|
||||
unk(6) mustEqual 0
|
||||
unk(7) mustEqual 0
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val msg = DensityLevelUpdateMessage(1, 19999, List(0, 0, 0, 0, 0, 0, 0, 0))
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
||||
"encode (failure; wrong number of list entries)" in {
|
||||
val msg = DensityLevelUpdateMessage(1, 19999, List(0))
|
||||
PacketCoding.EncodePacket(msg).isSuccessful mustEqual false
|
||||
}
|
||||
|
||||
"encode (failure; list number too big)" in {
|
||||
val msg = DensityLevelUpdateMessage(1, 19999, List(0, 0, 0, 0, 0, 0, 0, 8))
|
||||
PacketCoding.EncodePacket(msg).isSuccessful mustEqual false
|
||||
}
|
||||
|
||||
"encode (failure; list number too small)" in {
|
||||
val msg = DensityLevelUpdateMessage(1, 19999, List(0, 0, 0, 0, 0, -1, 0, 0))
|
||||
PacketCoding.EncodePacket(msg).isSuccessful mustEqual false
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue