func BenchmarkUnpack(bn *testing.B) { var p icmpv6.Packet var b packet.Buffer for n := 0; n < bn.N; n++ { b.Init(test_simple) p.Unpack(&b) } }
func TestUnpack(t *testing.T) { var p icmpv6.Packet cmp := MakeTestSimple() var b packet.Buffer b.Init(test_simple) err := p.Unpack(&b) if err != nil { t.Fatalf("Error unpacking: %s", err) } if !p.Equals(cmp) { t.Fatalf("Packet mismatch:\n%s\n%s", &p, cmp) } }
func TestUnpackWithIPv6(t *testing.T) { var p icmpv6.Packet cmp := MakeTestSimple() cmp.Checksum = 0x5bed var b packet.Buffer b.Init(test_with_ipv6) err := p.Unpack(&b) if err != nil { t.Fatalf("Error unpacking: %s", err) } if !p.Equals(cmp) { t.Fatalf("Packet mismatch:\n%s\n%s", &p, cmp) } }