diff options
author | Ghanan Gowripalan <ghanan@google.com> | 2021-06-30 18:30:47 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-06-30 18:33:49 -0700 |
commit | 07ffecef83bd31e78786af901c49a7be93b20517 (patch) | |
tree | 6f2245a958cdd124ff5cf8160abab38ca0e4f466 /pkg/tcpip/header/ndp_test.go | |
parent | 6ef268409620c57197b9d573e23be8cb05dbf381 (diff) |
Implement fmt.Stringer for NDPRoutePreference
PiperOrigin-RevId: 382427879
Diffstat (limited to 'pkg/tcpip/header/ndp_test.go')
-rw-r--r-- | pkg/tcpip/header/ndp_test.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/pkg/tcpip/header/ndp_test.go b/pkg/tcpip/header/ndp_test.go index 2d55f2289..2a897e938 100644 --- a/pkg/tcpip/header/ndp_test.go +++ b/pkg/tcpip/header/ndp_test.go @@ -1717,3 +1717,32 @@ func TestNDPOptionsIter(t *testing.T) { t.Errorf("got Next = (%x, _, _), want = (nil, _, _)", next) } } + +func TestNDPRoutePreferenceStringer(t *testing.T) { + p := NDPRoutePreference(0) + for { + var wantStr string + switch p { + case 0b01: + wantStr = "HighRoutePreference" + case 0b00: + wantStr = "MediumRoutePreference" + case 0b11: + wantStr = "LowRoutePreference" + case 0b10: + wantStr = "ReservedRoutePreference" + default: + wantStr = fmt.Sprintf("NDPRoutePreference(%d)", p) + } + + if gotStr := p.String(); gotStr != wantStr { + t.Errorf("got NDPRoutePreference(%d).String() = %s, want = %s", p, gotStr, wantStr) + } + + p++ + if p == 0 { + // Overflowed, we hit all values. + break + } + } +} |