File: option_parameter_request_list_test.go

package info (click to toggle)
golang-github-insomniacslk-dhcp 0.0~git20220915.043f172-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,168 kB
  • sloc: makefile: 6
file content (28 lines) | stat: -rw-r--r-- 777 bytes parent folder | download | duplicates (3)
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
package dhcpv4

import (
	"testing"

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

func TestOptParameterRequestListInterfaceMethods(t *testing.T) {
	opts := []OptionCode{OptionBootfileName, OptionNameServer}
	o := OptParameterRequestList(opts...)

	require.Equal(t, OptionParameterRequestList, o.Code, "Code")

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

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

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