diff options
Diffstat (limited to 'dhcpv4/options_test.go')
-rw-r--r-- | dhcpv4/options_test.go | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/dhcpv4/options_test.go b/dhcpv4/options_test.go index 3c1de67..bf869f2 100644 --- a/dhcpv4/options_test.go +++ b/dhcpv4/options_test.go @@ -7,10 +7,20 @@ import ( ) func TestParseOption(t *testing.T) { - // Option subnet mask - option := []byte{1, 4, 255, 255, 255, 0} + // Generic + option := []byte{5, 4, 192, 168, 1, 254} // DNS option opt, err := ParseOption(option) require.NoError(t, err) + generic := opt.(*OptionGeneric) + require.Equal(t, OptionNameServer, generic.Code()) + require.Equal(t, []byte{192, 168, 1, 254}, generic.Data) + require.Equal(t, 4, generic.Length()) + require.Equal(t, "Name Server -> [192 168 1 254]", generic.String()) + + // Option subnet mask + option = []byte{1, 4, 255, 255, 255, 0} + opt, err = ParseOption(option) + require.NoError(t, err) require.Equal(t, OptionSubnetMask, opt.Code(), "Code") require.Equal(t, 4, opt.Length(), "Length") require.Equal(t, option, opt.ToBytes(), "ToBytes") @@ -166,16 +176,6 @@ func TestParseOption(t *testing.T) { require.Equal(t, OptionClientSystemArchitectureType, opt.Code(), "Code") require.Equal(t, 4, opt.Length(), "Length") require.Equal(t, option, opt.ToBytes(), "ToBytes") - - // Generic - option = []byte{5, 4, 192, 168, 1, 254} // DNS option - opt, err = ParseOption(option) - require.NoError(t, err) - generic := opt.(*OptionGeneric) - require.Equal(t, OptionNameServer, generic.Code()) - require.Equal(t, []byte{192, 168, 1, 254}, generic.Data) - require.Equal(t, 4, generic.Length()) - require.Equal(t, "Name Server -> [192 168 1 254]", generic.String()) } func TestParseOptionZeroLength(t *testing.T) { |