summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/option_generic_test.go
blob: 4c4f2e82507768724a2984cdcafe26afd44c6bc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package dhcpv4

import (
	"testing"

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

func TestOptionGenericCode(t *testing.T) {
	o := OptGeneric(OptionDHCPMessageType, []byte{byte(MessageTypeDiscover)})
	require.Equal(t, OptionDHCPMessageType, o.Code)
	require.Equal(t, []byte{1}, o.Value.ToBytes())
	require.Equal(t, "DHCP Message Type: [1]", o.String())
}

func TestOptionGenericStringUnknown(t *testing.T) {
	o := OptGeneric(optionCode(102), []byte{byte(MessageTypeDiscover)})
	require.Equal(t, "unknown (102): [1]", o.String())
}