diff options
Diffstat (limited to 'dhcpv6/option_fqdn_test.go')
-rw-r--r-- | dhcpv6/option_fqdn_test.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/dhcpv6/option_fqdn_test.go b/dhcpv6/option_fqdn_test.go new file mode 100644 index 0000000..870ed9d --- /dev/null +++ b/dhcpv6/option_fqdn_test.go @@ -0,0 +1,39 @@ +package dhcpv6 + +import ( + "bytes" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestParseOptFQDN(t *testing.T) { + data := []byte{ + 0, // Flags + 'c', 'n', 'o', 's', '.', 'l', 'o', 'c', 'a', 'l', + 'h', 'o', 's', 't', + } + opt, err := ParseOptFQDN(data) + + require.NoError(t, err) + require.Equal(t, OptionFQDN, opt.Code()) + require.Equal(t, uint8(0), opt.Flags) + require.Equal(t, "cnos.localhost", opt.DomainName) + require.Equal(t, "OptFQDN{flags=0, domainname=cnos.localhost}", opt.String()) +} + +func TestOptFQDNToBytes(t *testing.T) { + opt := OptFQDN{ + Flags: 0, + DomainName: "cnos.localhost", + } + want := []byte{ + 0, // Flags + 'c', 'n', 'o', 's', '.', 'l', 'o', 'c', 'a', 'l', + 'h', 'o', 's', 't', + } + b := opt.ToBytes() + if !bytes.Equal(b, want) { + t.Fatalf("opt.ToBytes()=%v, want %v", b, want) + } +} |