summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/option_informationrefreshtime_test.go
diff options
context:
space:
mode:
authorPablo Mazzini <pmazzini@gmail.com>2020-08-14 13:50:43 +0100
committerGitHub <noreply@github.com>2020-08-14 13:50:43 +0100
commit2e1bf785d039de3fd451b63cfe937456b32e739c (patch)
tree6bf292909ab9f9c7ef8a7fc8d94ffba014f911ff /dhcpv6/option_informationrefreshtime_test.go
parente10aec901335bf3bfea7ee5faf22cf0256f99420 (diff)
parentf84fcf45711e9c41d21faa408dc85fe73439f3cd (diff)
Merge pull request #394 from mcphailtom/opt_information_refresh
Option: Information Refresh Time https://tools.ietf.org/html/rfc8415
Diffstat (limited to 'dhcpv6/option_informationrefreshtime_test.go')
-rw-r--r--dhcpv6/option_informationrefreshtime_test.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/dhcpv6/option_informationrefreshtime_test.go b/dhcpv6/option_informationrefreshtime_test.go
new file mode 100644
index 0000000..68f0855
--- /dev/null
+++ b/dhcpv6/option_informationrefreshtime_test.go
@@ -0,0 +1,33 @@
+package dhcpv6
+
+import (
+ "bytes"
+ "testing"
+ "time"
+)
+
+func TestOptInformationRefreshTime(t *testing.T) {
+ opt, err := parseOptInformationRefreshTime([]byte{0xaa, 0xbb, 0xcc, 0xdd})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if informationRefreshTime := opt.InformationRefreshtime; informationRefreshTime != time.Duration(0xaabbccdd) * time.Second {
+ t.Fatalf("Invalid information refresh time. Expected 0xaabb, got %v", informationRefreshTime)
+ }
+}
+
+func TestOptInformationRefreshTimeToBytes(t *testing.T) {
+ opt := OptInformationRefreshTime(0)
+ expected := []byte{0, 0, 0, 0}
+ if toBytes := opt.ToBytes(); !bytes.Equal(expected, toBytes) {
+ t.Fatalf("Invalid ToBytes output. Expected %v, got %v", expected, toBytes)
+ }
+}
+
+func TestOptInformationRefreshTimeString(t *testing.T) {
+ opt := OptInformationRefreshTime(3600 * time.Second)
+ expected := "InformationRefreshTime: 1h0m0s"
+ if optString := opt.String(); optString != expected {
+ t.Fatalf("Invalid elapsed time string. Expected %v, got %v", expected, optString)
+ }
+}