(t *testing.T)
| 85 | } |
| 86 | |
| 87 | func testFragmentedLCM(t *testing.T) { |
| 88 | lcm := LCM{} |
| 89 | |
| 90 | err := lcm.DecodeFromBytes(fragmentedPacket, gopacket.NilDecodeFeedback) |
| 91 | if err != nil { |
| 92 | t.Fatal(err) |
| 93 | } |
| 94 | |
| 95 | if lcm.Magic != LCMFragmentedHeaderMagic { |
| 96 | t.Errorf("Expected LCM Magic %x, but decoded %x.\n", |
| 97 | LCMFragmentedHeaderMagic, lcm.Magic) |
| 98 | } |
| 99 | |
| 100 | if lcm.SequenceNumber != 0x01 { |
| 101 | t.Errorf("Expected an LCM Sequence Number of %x, but decoded %x.\n", |
| 102 | 0x01, lcm.SequenceNumber) |
| 103 | } |
| 104 | |
| 105 | if lcm.PayloadSize != 0x0d { |
| 106 | t.Errorf("Expected an LCM Payload Size of %x, but decoded %x.\n", 0x0d, |
| 107 | lcm.PayloadSize) |
| 108 | } |
| 109 | |
| 110 | if lcm.FragmentOffset != 0x2d { |
| 111 | t.Errorf("Expected an LCM Fragment Offset of %x, but decoded %x.\n", |
| 112 | 0x2d, lcm.FragmentOffset) |
| 113 | } |
| 114 | |
| 115 | if lcm.FragmentNumber != 0x00 { |
| 116 | t.Errorf("Expected the first LCM fragment (%x), but decoded %x.\n", |
| 117 | 0x00, lcm.FragmentNumber) |
| 118 | } |
| 119 | |
| 120 | if lcm.TotalFragments != 0x02 { |
| 121 | t.Errorf("Expected two LCM fragments (%x), but decoded %x.\n", 0x02, |
| 122 | lcm.TotalFragments) |
| 123 | } |
| 124 | |
| 125 | if lcm.ChannelName != expectedChannel { |
| 126 | t.Errorf("Expected LCM Channel Name %s but decoded %s\n", |
| 127 | expectedChannel, lcm.ChannelName) |
| 128 | } |
| 129 | |
| 130 | if !lcm.Fragmented { |
| 131 | t.Errorf("Misinterpreted fragmented packet as non-fragmented.") |
| 132 | } |
| 133 | |
| 134 | for i, val := range lcm.LayerContents() { |
| 135 | if val != fragmentedPacket[i] { |
| 136 | t.Errorf("\nLCM Payload: expected\n%sbut received\n%s", |
| 137 | hex.Dump(fragmentedPacket[:22]), hex.Dump(lcm.Payload())) |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | for i, val := range lcm.Payload() { |
| 142 | if val != fragmentedPacket[i+34] { |
| 143 | t.Errorf("\nLCM Payload: expected\n%sbut received\n%s", |
| 144 | hex.Dump(fragmentedPacket[34:]), hex.Dump(lcm.Payload())) |
no test coverage detected
searching dependent graphs…