diff options
author | Pablo Mazzini <pmazzini@gmail.com> | 2018-08-22 17:27:18 +0100 |
---|---|---|
committer | insomniac <insomniacslk@users.noreply.github.com> | 2018-08-22 17:27:18 +0100 |
commit | 537f1f937790c0bd7826ec6feb6e99fe7ededf58 (patch) | |
tree | 447b52801d5c831f2ffe3c8b97a01cbf5ea6165f /dhcpv6/option_vendorclass_test.go | |
parent | 051f4413e8ae8c174024f754d7b21ec13a5460b9 (diff) |
add OptVendorClass (#148)
Diffstat (limited to 'dhcpv6/option_vendorclass_test.go')
-rw-r--r-- | dhcpv6/option_vendorclass_test.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/dhcpv6/option_vendorclass_test.go b/dhcpv6/option_vendorclass_test.go new file mode 100644 index 0000000..0db278f --- /dev/null +++ b/dhcpv6/option_vendorclass_test.go @@ -0,0 +1,40 @@ +package dhcpv6 + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestParseOptVendorClass(t *testing.T) { + data := []byte{ + 0xaa, 0xbb, 0xcc, 0xdd, // EnterpriseNumber + 0, 10, 'H', 'T', 'T', 'P', 'C', 'l', 'i', 'e', 'n', 't', + 0, 4, 't', 'e', 's', 't', + } + opt, err := ParseOptVendorClass(data) + require.NoError(t, err) + require.Equal(t, len(opt.Data), 2) + require.Equal(t, opt.EnterpriseNumber, uint32(0xaabbccdd)) + require.Equal(t, []byte("HTTPClient"), opt.Data[0]) + require.Equal(t, []byte("test"), opt.Data[1]) +} + +func TestOptVendorClassToBytes(t *testing.T) { + opt := OptVendorClass{ + EnterpriseNumber: uint32(0xaabbccdd), + Data: [][]byte{ + []byte("HTTPClient"), + []byte("test"), + }, + } + data := opt.ToBytes() + expected := []byte{ + 0, 16, // OptionVendorClass + 0, 22, // length + 0xaa, 0xbb, 0xcc, 0xdd, // EnterpriseNumber + 0, 10, 'H', 'T', 'T', 'P', 'C', 'l', 'i', 'e', 'n', 't', + 0, 4, 't', 'e', 's', 't', + } + require.Equal(t, expected, data) +} |