diff options
Diffstat (limited to 'dhcpv4/option_userclass_test.go')
-rw-r--r-- | dhcpv4/option_userclass_test.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/dhcpv4/option_userclass_test.go b/dhcpv4/option_userclass_test.go index fe39b04..cbfd38b 100644 --- a/dhcpv4/option_userclass_test.go +++ b/dhcpv4/option_userclass_test.go @@ -64,3 +64,29 @@ func TestOptUserClassToBytesMultiple(t *testing.T) { } require.Equal(t, expected, data) } + +func TestParseOptUserClassLongerThanLength(t *testing.T) { + expected := []byte{ + 77, 10, 9, 'l', 'i', 'n', 'u', 'x', 'b', 'o', 'o', 't', 'X', + } + opt, err := ParseOptUserClass(expected) + require.NoError(t, err) + require.Equal(t, 1, len(opt.UserClasses)) + require.Equal(t, []byte("linuxboot"), opt.UserClasses[0]) +} + +func TestParseOptUserClassShorterThanLength(t *testing.T) { + expected := []byte{ + 77, 10, 10, 'l', 'i', 'n', 'u', 'x', 'b', 'o', 'o', 't', + } + _, err := ParseOptUserClass(expected) + require.Error(t, err) +} + +func TestParseOptUserClassShorterTotalLength(t *testing.T) { + expected := []byte{ + 77, 11, 10, 'l', 'i', 'n', 'u', 'x', 'b', 'o', 'o', 't', + } + _, err := ParseOptUserClass(expected) + require.Error(t, err) +} |