Packet: MultiPacketEx, CharacterRequestMessage

Rename AggregatePacket -> MultiPacketEx as it makes more sense
This commit is contained in:
Chord 2016-06-03 20:25:20 -04:00
parent 9a0ef28723
commit 7b82491d0e
6 changed files with 143 additions and 4 deletions

View file

@ -129,5 +129,45 @@ class ControlPacketTest extends Specification {
PacketCoding.EncodePacket(SlottedMetaPacket(0, 0x10000, hex"00")).require must throwA[IllegalArgumentException]
}
}
"MultiPacketEx" should {
val strings = Vector(
hex"00",
hex"01 41",
hex"01 41" ++ hex"02 4142",
hex"fe" ++ ByteVector.fill(0xfe)(0x41),
hex"ffff00" ++ ByteVector.fill(0xff)(0x41),
hex"ff0001" ++ ByteVector.fill(0x100)(0x41),
hex"ff ffff ffff 0000" ++ ByteVector.fill(0x0000ffff)(0x41),
hex"ff ffff 0000 0100" ++ ByteVector.fill(0x00010000)(0x41)
)
val packets = Vector(
MultiPacketEx(Vector(ByteVector.empty)),
MultiPacketEx(Vector(hex"41")),
MultiPacketEx(Vector(hex"41", hex"4142")),
MultiPacketEx(Vector(ByteVector.fill(0xfe)(0x41))),
MultiPacketEx(Vector(ByteVector.fill(0xff)(0x41))),
MultiPacketEx(Vector(ByteVector.fill(0x100)(0x41))),
MultiPacketEx(Vector(ByteVector.fill(0x0000ffff)(0x41))),
MultiPacketEx(Vector(ByteVector.fill(0x00010000)(0x41)))
)
"decode" in {
for(i <- strings.indices) {
MultiPacketEx.decode(strings{i}.bits).require.value mustEqual packets{i}
}
true mustEqual true
}
"encode" in {
for(i <- packets.indices) {
MultiPacketEx.encode(packets{i}).require.toByteVector mustEqual strings{i}
}
true mustEqual true
}
}
}
}