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 TestOptRootPathInterfaceMethods(t *testing.T) {
o := OptRootPath{Path: "/foo/bar/baz"}
require.Equal(t, OptionRootPath, o.Code(), "Code")
wantBytes := []byte{
'/', 'f', 'o', 'o', '/', 'b', 'a', 'r', '/', 'b', 'a', 'z',
}
require.Equal(t, wantBytes, o.ToBytes(), "ToBytes")
}
func TestParseOptRootPath(t *testing.T) {
data := []byte{byte(OptionRootPath), 4, '/', 'f', 'o', 'o'}
o, err := ParseOptRootPath(data[2:])
require.NoError(t, err)
require.Equal(t, &OptRootPath{Path: "/foo"}, o)
}
func TestOptRootPathString(t *testing.T) {
o := OptRootPath{Path: "/foo/bar/baz"}
require.Equal(t, "Root Path -> /foo/bar/baz", o.String())
}
|