diff options
author | Andrea Barberio <insomniac@slackware.it> | 2018-11-20 16:26:37 +0000 |
---|---|---|
committer | insomniac <insomniacslk@users.noreply.github.com> | 2018-11-21 10:39:17 +0000 |
commit | 2bc2f0b62ecb4d77d5236617ef2de88bcc3a611b (patch) | |
tree | 09c6d2b40aeb6f5e9ed6229d6bd79da01d39b688 /dhcpv6/option_domainsearchlist_test.go | |
parent | bbaa1a7aa2044c0d954c7f10f288c2730cba421c (diff) |
rfc1035label: using a structure to hold original data
Diffstat (limited to 'dhcpv6/option_domainsearchlist_test.go')
-rw-r--r-- | dhcpv6/option_domainsearchlist_test.go | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/dhcpv6/option_domainsearchlist_test.go b/dhcpv6/option_domainsearchlist_test.go index 972a5bc..0b4b6b0 100644 --- a/dhcpv6/option_domainsearchlist_test.go +++ b/dhcpv6/option_domainsearchlist_test.go @@ -3,6 +3,7 @@ package dhcpv6 import ( "testing" + "github.com/insomniacslk/dhcp/rfc1035label" "github.com/stretchr/testify/require" ) @@ -14,9 +15,10 @@ func TestParseOptDomainSearchList(t *testing.T) { opt, err := ParseOptDomainSearchList(data) require.NoError(t, err) require.Equal(t, OptionDomainSearchList, opt.Code()) - require.Equal(t, 2, len(opt.DomainSearchList)) - require.Equal(t, "example.com", opt.DomainSearchList[0]) - require.Equal(t, "subnet.example.org", opt.DomainSearchList[1]) + require.Equal(t, 2, len(opt.DomainSearchList.Labels)) + require.Equal(t, len(data), opt.DomainSearchList.Length()) + require.Equal(t, "example.com", opt.DomainSearchList.Labels[0]) + require.Equal(t, "subnet.example.org", opt.DomainSearchList.Labels[1]) require.Contains(t, opt.String(), "searchlist=[example.com subnet.example.org]", "String() should contain the correct domain search output") } @@ -28,9 +30,11 @@ func TestOptDomainSearchListToBytes(t *testing.T) { 6, 's', 'u', 'b', 'n', 'e', 't', 7, 'e', 'x', 'a', 'm', 'p', 'l', 'e', 3, 'o', 'r', 'g', 0, } opt := OptDomainSearchList{ - DomainSearchList: []string{ - "example.com", - "subnet.example.org", + DomainSearchList: &rfc1035label.Labels{ + Labels: []string{ + "example.com", + "subnet.example.org", + }, }, } require.Equal(t, expected, opt.ToBytes()) |