From 44c5227b7ac262bcbd0aa050e1d3cbb1ba4bc74d Mon Sep 17 00:00:00 2001 From: Pablo Mazzini Date: Sun, 11 Nov 2018 22:48:58 +0000 Subject: OptRelayAgentInformation: increase coverage --- dhcpv4/options_test.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'dhcpv4') 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) { -- cgit v1.2.3