summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/bsdp/bsdp_option_machine_name_test.go
blob: 712bc49089809b9254a9364a3543aa3857e267b9 (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
package bsdp

import (
	"testing"

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

func TestOptMachineNameInterfaceMethods(t *testing.T) {
	o := OptMachineName{"somebox"}
	require.Equal(t, OptionMachineName, o.Code(), "Code")
	require.Equal(t, 7, o.Length(), "Length")
	expectedBytes := []byte{130, 7, 's', 'o', 'm', 'e', 'b', 'o', 'x'}
	require.Equal(t, expectedBytes, o.ToBytes(), "ToBytes")
}

func TestParseOptMachineName(t *testing.T) {
	data := []byte{'s', 'o', 'm', 'e', 'b', 'o', 'x'}
	o, err := ParseOptMachineName(data)
	require.NoError(t, err)
	require.Equal(t, &OptMachineName{"somebox"}, o)
}

func TestOptMachineNameString(t *testing.T) {
	o := OptMachineName{"somebox"}
	require.Equal(t, "BSDP Machine Name -> somebox", o.String())
}