summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/option_parameter_request_list_test.go
blob: a09aaad817b9aefb43ac8410cd9bf83fc35ac808 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package dhcpv4

import (
	"testing"

	"github.com/stretchr/testify/require"
)

func TestOptParameterRequestListInterfaceMethods(t *testing.T) {
	requestedOpts := []OptionCode{OptionBootfileName, OptionNameServer}
	o := &OptParameterRequestList{RequestedOpts: requestedOpts}
	require.Equal(t, OptionParameterRequestList, o.Code(), "Code")

	expectedBytes := []byte{67, 5}
	require.Equal(t, expectedBytes, o.ToBytes(), "ToBytes")

	expectedString := "Parameter Request List -> Bootfile Name, Name Server"
	require.Equal(t, expectedString, o.String(), "String")
}

func TestParseOptParameterRequestList(t *testing.T) {
	var (
		o   *OptParameterRequestList
		err error
	)
	o, err = ParseOptParameterRequestList([]byte{67, 5})
	require.NoError(t, err)
	expectedOpts := OptionCodeList{OptionBootfileName, OptionNameServer}
	require.Equal(t, expectedOpts, o.RequestedOpts)
}