diff options
author | Pablo Mazzini <pmazzini@gmail.com> | 2018-11-11 22:48:58 +0000 |
---|---|---|
committer | Pablo Mazzini <pmazzini@gmail.com> | 2018-11-11 22:48:58 +0000 |
commit | 44c5227b7ac262bcbd0aa050e1d3cbb1ba4bc74d (patch) | |
tree | d5e2f1696ebf1718b0978f3b892daa0ba0b8a900 /dhcpv4 | |
parent | 63b2012572c4572c2f992f6efc911cf105750f7e (diff) |
OptRelayAgentInformation: increase coverage
Diffstat (limited to 'dhcpv4')
-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) { |