Debian Codegraph @

dhcp6opts/remoteid_test.go

raw symbols SCIP
1 package dhcp6optsscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6opts`/
2
3 import (
4 "bytesscip-go gomod github.com/golang/go/src go1.12 bytes/"
5 "ioscip-go gomod github.com/golang/go/src go1.12 io/"
6 "reflectscip-go gomod github.com/golang/go/src go1.12 reflect/"
7 "testingscip-go gomod github.com/golang/go/src go1.12 testing/"
8 )
9
10 func TestRemoteIdentifierMarshalBinaryscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6opts`/TestRemoteIdentifierMarshalBinary().(t *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) {
11 var tests = []struct {
12 desc string
13 buf []byte
14 remoteIdentifier *RemoteIdentifierscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6opts`/RemoteIdentifier#
15 }{
16 {
17 desc: "all zero values",
18 buf: bytesscip-go gomod github.com/golang/go/src go1.12 bytes/.Repeatscip-go gomod github.com/golang/go/src go1.12 bytes/Repeat().([]byte{0}, 5),
19 remoteIdentifier: &RemoteIdentifierscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6opts`/RemoteIdentifier#{
20 RemoteIDscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6opts`/RemoteIdentifier#RemoteID.: []byte{0},
21 },
22 },
23 {
24 desc: "[0, 0, 5, 0x58] EnterpriseNumber, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xe, 0xf] RemoteID",
25 buf: []byte{0, 0, 5, 0x58, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xe, 0xf},
26 remoteIdentifier: &RemoteIdentifierscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6opts`/RemoteIdentifier#{
27 EnterpriseNumberscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6opts`/RemoteIdentifier#EnterpriseNumber.: 1368,
28 RemoteIDscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6opts`/RemoteIdentifier#RemoteID.: []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xe, 0xf},
29 },
30 },
31 }
32
33 for i, tt := range tests {
34 want := tt.buf
35 got, err := tt.remoteIdentifier.MarshalBinaryscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6opts`/RemoteIdentifier#MarshalBinary().()
36 if err != nil {
37 t.Fatalscip-go gomod github.com/golang/go/src go1.12 testing/common#Fatal().(err)
38 }
39 if !bytesscip-go gomod github.com/golang/go/src go1.12 bytes/.Equalscip-go gomod github.com/golang/go/src go1.12 bytes/Equal().(want, got) {
40 t.Fatalfscip-go gomod github.com/golang/go/src go1.12 testing/common#Fatalf().("[%02d] test %q, unexpected RemoteIdentifier bytes for MarshalBinary(%v)\n- want: %v\n- got: %v",
41 i, tt.desc, tt.buf, want, got)
42 }
43 }
44 }
45
46 func TestRemoteIdentifierUnmarshalBinaryscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6opts`/TestRemoteIdentifierUnmarshalBinary().(t *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) {
47 var tests = []struct {
48 buf []byte
49 remoteIdentifier *RemoteIdentifierscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6opts`/RemoteIdentifier#
50 err error
51 }{
52 {
53 buf: []byte{0, 0, 5, 0x58, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xe, 0xf},
54 remoteIdentifier: &RemoteIdentifierscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6opts`/RemoteIdentifier#{
55 EnterpriseNumberscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6opts`/RemoteIdentifier#EnterpriseNumber.: 1368,
56 RemoteIDscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6opts`/RemoteIdentifier#RemoteID.: []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xe, 0xf},
57 },
58 },
59 {
60 buf: bytesscip-go gomod github.com/golang/go/src go1.12 bytes/.Repeatscip-go gomod github.com/golang/go/src go1.12 bytes/Repeat().([]byte{0}, 4),
61 err: ioscip-go gomod github.com/golang/go/src go1.12 io/.ErrUnexpectedEOFscip-go gomod github.com/golang/go/src go1.12 io/ErrUnexpectedEOF.,
62 },
63 }
64
65 for i, tt := range tests {
66 remoteIdentifier := new(RemoteIdentifierscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6opts`/RemoteIdentifier#)
67 if want, got := tt.err, remoteIdentifier.UnmarshalBinaryscip-go gomod github.com/mdlayher/dhcp6 . `github.com/mdlayher/dhcp6/dhcp6opts`/RemoteIdentifier#UnmarshalBinary().(tt.buf); want != got {
68 t.Fatalfscip-go gomod github.com/golang/go/src go1.12 testing/common#Fatalf().("[%02d] unexpected error for parseRemoteIdentifier(%v):\n- want: %v\n- got: %v", i, tt.buf, want, got)
69 }
70
71 if tt.err == nil {
72 if want, got := tt.remoteIdentifier, remoteIdentifier; !reflectscip-go gomod github.com/golang/go/src go1.12 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.12 reflect/DeepEqual().(want, got) {
73 t.Fatalfscip-go gomod github.com/golang/go/src go1.12 testing/common#Fatalf().("[%02d] unexpected RemoteIdentifier for parseRemoteIdentifier(%v):\n- want: %v\n- got: %v", i, tt.buf, want, got)
74 }
75 }
76 }
77 }