diff options
author | David Barr <38654497+davebarrau@users.noreply.github.com> | 2018-10-12 11:09:04 +1100 |
---|---|---|
committer | insomniac <insomniacslk@users.noreply.github.com> | 2018-10-11 17:09:04 -0700 |
commit | dc01165c86340093eacf62c0856ae4e2164a4845 (patch) | |
tree | 9ca76ae4103c3e63cd86620fdec230e5cfe5b78d /dhcpv6/option_domainsearchlist_test.go | |
parent | ee671d361777cc640550bab38cc6b0d412396f80 (diff) |
Add some more DHCPv6 option tests. (#171)
* Add some more DHCPv6 option tests.
* Remove AddRequestedOption() duplicate detection test due to failing on Go 1.9
Diffstat (limited to 'dhcpv6/option_domainsearchlist_test.go')
-rw-r--r-- | dhcpv6/option_domainsearchlist_test.go | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/dhcpv6/option_domainsearchlist_test.go b/dhcpv6/option_domainsearchlist_test.go index 68f93ba..972a5bc 100644 --- a/dhcpv6/option_domainsearchlist_test.go +++ b/dhcpv6/option_domainsearchlist_test.go @@ -13,9 +13,11 @@ func TestParseOptDomainSearchList(t *testing.T) { } opt, err := ParseOptDomainSearchList(data) require.NoError(t, err) - require.Equal(t, len(opt.DomainSearchList), 2) - require.Equal(t, opt.DomainSearchList[0], "example.com") - require.Equal(t, opt.DomainSearchList[1], "subnet.example.org") + 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.Contains(t, opt.String(), "searchlist=[example.com subnet.example.org]", "String() should contain the correct domain search output") } func TestOptDomainSearchListToBytes(t *testing.T) { @@ -31,5 +33,14 @@ func TestOptDomainSearchListToBytes(t *testing.T) { "subnet.example.org", }, } - require.Equal(t, opt.ToBytes(), expected) + require.Equal(t, expected, opt.ToBytes()) +} + +func TestParseOptDomainSearchListInvalidLength(t *testing.T) { + data := []byte{ + 7, 'e', 'x', 'a', 'm', 'p', 'l', 'e', 3, 'c', 'o', 'm', 0, + 6, 's', 'u', 'b', 'n', 'e', 't', 7, 'e', // truncated + } + _, err := ParseOptDomainSearchList(data) + require.Error(t, err, "A truncated OptDomainSearchList should return an error") } |