File: message_internal_test.go

package info (click to toggle)
golang-github-mdlayher-ndp 1.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid, trixie
  • size: 244 kB
  • sloc: makefile: 3
file content (25 lines) | stat: -rw-r--r-- 665 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package ndp

import (
	"testing"

	"github.com/google/go-cmp/cmp"
)

func TestRouterAdvertisementUnmarshalReservedPrf(t *testing.T) {
	// Assume that unmarshaling sets Prf to medium if reserved value received.
	const want = Medium

	b := []byte{0x0, byte(prfReserved) << 3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}

	ra := new(RouterAdvertisement)
	if err := ra.unmarshal(b); err != nil {
		t.Fatalf("failed to unmarshal: %v", err)
	}

	// Assume that unmarshaling ignores any prefix bits longer than the
	// specified length.
	if diff := cmp.Diff(want, ra.RouterSelectionPreference); diff != "" {
		t.Fatalf("unexpected prf (-want +got):\n%s", diff)
	}
}