mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-19 00:41:41 +00:00
Update PacketTest.java (#301)
Adds unit test to make sure the packet structure doesn't change
This commit is contained in:
@@ -95,4 +95,29 @@ class PacketTest {
|
||||
|
||||
Assertions.assertEquals(t, target);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPacketv2021_1_6() {
|
||||
// From v2021.1.6
|
||||
var simplified =
|
||||
new PhotonPipelineResult(
|
||||
12.34,
|
||||
List.of(
|
||||
new PhotonTrackedTarget(
|
||||
-23, -10, 6, 1, new Transform2d(new Translation2d(1, 2), new Rotation2d(3)))));
|
||||
byte[] bytes = {
|
||||
64, 40, -82, 20, 122, -31, 71, -82, 1, -64, 55, 0, 0, 0, 0, 0, 0, -64, 36, 0, 0, 0, 0, 0, 0,
|
||||
64, 24, 0, 0, 0, 0, 0, 0, 63, -16, 0, 0, 0, 0, 0, 0, 63, -16, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0,
|
||||
0, 0, 0, 0, 64, 101, 124, 101, 19, -54, -47, 122, 0
|
||||
};
|
||||
|
||||
// Let's check that those bytes still mean the same thing
|
||||
Packet packet = new Packet(1);
|
||||
packet.clear();
|
||||
packet.setData(bytes);
|
||||
var ret = new PhotonPipelineResult();
|
||||
ret.createFromPacket(packet);
|
||||
System.out.println(ret);
|
||||
Assertions.assertEquals(simplified, ret);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user