summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/options_test.go
diff options
context:
space:
mode:
authorChristopher Koch <chrisko@google.com>2019-01-10 16:19:02 -0800
committerinsomniac <insomniacslk@users.noreply.github.com>2019-01-14 23:19:04 +0000
commit81af01ddbffafdc6904a8092cba3adf92008c715 (patch)
tree0bccb58f602c9289cdf4893297d579119591f98f /dhcpv4/options_test.go
parent833f274e1aca3b23320f6d31c246c73eefd38974 (diff)
dhcpv4: change OptionCode to an interface for humanization.
Interface'd OptionCodes can print the correct human string. It sucks because option codes are just a byte, but depending on where you use them, they are interpreted differently. BSDP option codes != DHCP option codes.
Diffstat (limited to 'dhcpv4/options_test.go')
-rw-r--r--dhcpv4/options_test.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/dhcpv4/options_test.go b/dhcpv4/options_test.go
index 6e50768..0c1c1fa 100644
--- a/dhcpv4/options_test.go
+++ b/dhcpv4/options_test.go
@@ -173,7 +173,7 @@ func TestOptionsMarshal(t *testing.T) {
{
opts: Options{
&OptionGeneric{
- OptionCode: 5,
+ OptionCode: optionCode(5),
Data: []byte{1, 2, 3, 4},
},
},
@@ -185,11 +185,11 @@ func TestOptionsMarshal(t *testing.T) {
// Test sorted key order.
opts: Options{
&OptionGeneric{
- OptionCode: 5,
+ OptionCode: optionCode(5),
Data: []byte{1, 2, 3},
},
&OptionGeneric{
- OptionCode: 100,
+ OptionCode: optionCode(100),
Data: []byte{101, 102, 103},
},
},
@@ -202,7 +202,7 @@ func TestOptionsMarshal(t *testing.T) {
// Test RFC 3396.
opts: Options{
&OptionGeneric{
- OptionCode: 5,
+ OptionCode: optionCode(5),
Data: bytes.Repeat([]byte{10}, math.MaxUint8+1),
},
},
@@ -263,7 +263,7 @@ func TestOptionsUnmarshal(t *testing.T) {
},
want: Options{
&OptionGeneric{
- OptionCode: 3,
+ OptionCode: optionCode(3),
Data: []byte{5, 6},
},
},
@@ -277,7 +277,7 @@ func TestOptionsUnmarshal(t *testing.T) {
),
want: Options{
&OptionGeneric{
- OptionCode: 3,
+ OptionCode: optionCode(3),
Data: bytes.Repeat([]byte{10}, math.MaxUint8+5),
},
},
@@ -290,11 +290,11 @@ func TestOptionsUnmarshal(t *testing.T) {
},
want: Options{
&OptionGeneric{
- OptionCode: 10,
+ OptionCode: optionCode(10),
Data: []byte{255, 254},
},
&OptionGeneric{
- OptionCode: 11,
+ OptionCode: optionCode(11),
Data: []byte{5, 5, 5},
},
},
@@ -306,14 +306,14 @@ func TestOptionsUnmarshal(t *testing.T) {
),
want: Options{
&OptionGeneric{
- OptionCode: 10,
+ OptionCode: optionCode(10),
Data: []byte{255, 254},
},
},
},
} {
t.Run(fmt.Sprintf("Test %02d", i), func(t *testing.T) {
- opt, err := OptionsFromBytesWithParser(tt.input, ParseOptionGeneric, true)
+ opt, err := OptionsFromBytesWithParser(tt.input, codeGetter, ParseOptionGeneric, true)
if tt.wantError {
require.Error(t, err)
} else {