MCPcopy
hub / github.com/google/gopacket / TestWriteHeader

Function TestWriteHeader

pcapgo/write_test.go:31–43  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

29}
30
31func TestWriteHeader(t *testing.T) {
32 var buf bytes.Buffer
33 w := NewWriter(&buf)
34 w.WriteFileHeader(0x1234, 0x56)
35 want := []byte{
36 0xd4, 0xc3, 0xb2, 0xa1, 0x02, 0x00, 0x04, 0x00,
37 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38 0x34, 0x12, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00,
39 }
40 if got := buf.Bytes(); !bytes.Equal(got, want) {
41 t.Errorf("buf mismatch:\nwant: %+v\ngot: %+v", want, got)
42 }
43}
44
45func TestWritePacket(t *testing.T) {
46 ci := gopacket.CaptureInfo{

Callers

nothing calls this directly

Calls 3

WriteFileHeaderMethod · 0.95
NewWriterFunction · 0.85
BytesMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…