Exemple #1
0
func TestUnpack(t *testing.T) {
	var p udp.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)
	}
}
Exemple #2
0
func TestUnpackWithIPv4(t *testing.T) {
	var p udp.Packet

	cmp := MakeTestSimple()
	cmp.Checksum = 0x619e

	var b packet.Buffer
	b.Init(test_with_ipv4)

	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)
	}
}