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_interfaceid_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_interfaceid_test.go')
-rw-r--r-- | dhcpv6/option_interfaceid_test.go | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/dhcpv6/option_interfaceid_test.go b/dhcpv6/option_interfaceid_test.go index 21de822..b8c6b42 100644 --- a/dhcpv6/option_interfaceid_test.go +++ b/dhcpv6/option_interfaceid_test.go @@ -3,6 +3,8 @@ package dhcpv6 import ( "bytes" "testing" + + "github.com/stretchr/testify/require" ) func TestOptInterfaceId(t *testing.T) { @@ -23,11 +25,22 @@ func TestOptInterfaceIdToBytes(t *testing.T) { interfaceId := []byte("DSLAM01 eth2/1/01/21") expected := []byte{00, 18, 00, byte(len(interfaceId))} expected = append(expected, interfaceId...) - opt := OptInterfaceId{ - interfaceId: interfaceId, - } + opt := OptInterfaceId{} + opt.SetInterfaceID(interfaceId) toBytes := opt.ToBytes() if !bytes.Equal(toBytes, expected) { t.Fatalf("Invalid ToBytes result. Expected %v, got %v", expected, toBytes) } } + +func TestOptInterfaceIdString(t *testing.T) { + interfaceId := []byte("DSLAM01 eth2/1/01/21") + opt := OptInterfaceId{} + opt.SetInterfaceID(interfaceId) + require.Contains( + t, + opt.String(), + "68 83 76 65 77 48 49 32 101 116 104 50 47 49 47 48 49 47 50 49", + "String() should return the interfaceId as bytes", + ) +} |