(t *testing.T)
| 43 | } |
| 44 | |
| 45 | func TestWritePacket(t *testing.T) { |
| 46 | ci := gopacket.CaptureInfo{ |
| 47 | Timestamp: time.Unix(0x01020304, 0xAA*1000), |
| 48 | Length: 0xABCD, |
| 49 | CaptureLength: 10, |
| 50 | } |
| 51 | data := []byte{9, 8, 7, 6, 5, 4, 3, 2, 1, 0} |
| 52 | var buf bytes.Buffer |
| 53 | w := NewWriter(&buf) |
| 54 | w.WritePacket(ci, data) |
| 55 | want := []byte{ |
| 56 | 0x04, 0x03, 0x02, 0x01, 0xAA, 0x00, 0x00, 0x00, |
| 57 | 0x0A, 0x00, 0x00, 0x00, 0xCD, 0xAB, 0x00, 0x00, |
| 58 | 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, |
| 59 | } |
| 60 | if got := buf.Bytes(); !bytes.Equal(got, want) { |
| 61 | t.Errorf("buf mismatch:\nwant: %+v\ngot: %+v", want, got) |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | func BenchmarkWritePacket(b *testing.B) { |
| 66 | b.StopTimer() |
nothing calls this directly
no test coverage detected
searching dependent graphs…