summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/option_tftp_server_name_test.go
blob: c46b5db936e93c9c61a23ccc5ba3e93a739a7f6d (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
31
32
33
34
35
36
37
package dhcpv4

import (
	"testing"

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

func TestOptTFTPServerNameCode(t *testing.T) {
	opt := OptTFTPServerName{}
	require.Equal(t, OptionTFTPServerName, opt.Code())
}

func TestOptTFTPServerNameToBytes(t *testing.T) {
	opt := OptTFTPServerName{
		TFTPServerName: "linuxboot",
	}
	data := opt.ToBytes()
	expected := []byte{
		'l', 'i', 'n', 'u', 'x', 'b', 'o', 'o', 't',
	}
	require.Equal(t, expected, data)
}

func TestParseOptTFTPServerName(t *testing.T) {
	expected := []byte{
		'l', 'i', 'n', 'u', 'x', 'b', 'o', 'o', 't',
	}
	opt, err := ParseOptTFTPServerName(expected)
	require.NoError(t, err)
	require.Equal(t, "linuxboot", string(opt.TFTPServerName))
}

func TestOptTFTPServerNameString(t *testing.T) {
	o := OptTFTPServerName{TFTPServerName: "testy test"}
	require.Equal(t, "TFTP Server Name -> testy test", o.String())
}