summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/dhcpv4_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'dhcpv4/dhcpv4_test.go')
-rw-r--r--dhcpv4/dhcpv4_test.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/dhcpv4/dhcpv4_test.go b/dhcpv4/dhcpv4_test.go
index 065b6e0..4e4f7b5 100644
--- a/dhcpv4/dhcpv4_test.go
+++ b/dhcpv4/dhcpv4_test.go
@@ -300,6 +300,28 @@ func TestNewToBytes(t *testing.T) {
require.Equal(t, expected, got)
}
+func TestGetOption(t *testing.T) {
+ d, err := New()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ hostnameOpt := &OptionGeneric{OptionCode: OptionHostName, Data: []byte("darkstar")}
+ bootFileOpt1 := &OptionGeneric{OptionCode: OptionBootfileName, Data: []byte("boot.img")}
+ bootFileOpt2 := &OptionGeneric{OptionCode: OptionBootfileName, Data: []byte("boot2.img")}
+ d.AddOption(hostnameOpt)
+ d.AddOption(bootFileOpt1)
+ d.AddOption(bootFileOpt2)
+
+ require.Equal(t, d.GetOption(OptionHostName), []Option{hostnameOpt})
+ require.Equal(t, d.GetOption(OptionBootfileName), []Option{bootFileOpt1, bootFileOpt2})
+ require.Equal(t, d.GetOption(OptionRouter), []Option{})
+
+ require.Equal(t, d.GetOneOption(OptionHostName), hostnameOpt)
+ require.Equal(t, d.GetOneOption(OptionBootfileName), bootFileOpt1)
+ require.Equal(t, d.GetOneOption(OptionRouter), nil)
+}
+
// TODO
// test broadcast/unicast flags
// test Options setter/getter