summaryrefslogtreecommitdiffhomepage
path: root/dhcpv4/option_domain_search_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'dhcpv4/option_domain_search_test.go')
-rw-r--r--dhcpv4/option_domain_search_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/dhcpv4/option_domain_search_test.go b/dhcpv4/option_domain_search_test.go
new file mode 100644
index 0000000..4848a83
--- /dev/null
+++ b/dhcpv4/option_domain_search_test.go
@@ -0,0 +1,37 @@
+package dhcpv4
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/require"
+)
+
+func TestParseOptDomainSearch(t *testing.T) {
+ data := []byte{
+ 119, // OptionDNSDomainSearchList
+ 33, // length
+ 7, 'e', 'x', 'a', 'm', 'p', 'l', 'e', 3, 'c', 'o', 'm', 0,
+ 6, 's', 'u', 'b', 'n', 'e', 't', 7, 'e', 'x', 'a', 'm', 'p', 'l', 'e', 3, 'o', 'r', 'g', 0,
+ }
+ opt, err := ParseOptDomainSearch(data)
+ require.NoError(t, err)
+ require.Equal(t, len(opt.DomainSearch), 2)
+ require.Equal(t, opt.DomainSearch[0], "example.com")
+ require.Equal(t, opt.DomainSearch[1], "subnet.example.org")
+}
+
+func TestOptDomainSearchToBytes(t *testing.T) {
+ expected := []byte{
+ 119, // OptionDNSDomainSearchList
+ 33, // length
+ 7, 'e', 'x', 'a', 'm', 'p', 'l', 'e', 3, 'c', 'o', 'm', 0,
+ 6, 's', 'u', 'b', 'n', 'e', 't', 7, 'e', 'x', 'a', 'm', 'p', 'l', 'e', 3, 'o', 'r', 'g', 0,
+ }
+ opt := OptDomainSearch{
+ DomainSearch: []string{
+ "example.com",
+ "subnet.example.org",
+ },
+ }
+ require.Equal(t, opt.ToBytes(), expected)
+}