diff options
author | Chris Koch <chrisko@google.com> | 2023-02-18 20:31:32 -0800 |
---|---|---|
committer | Chris K <c@chrisko.ch> | 2023-02-19 22:39:16 -0800 |
commit | 336d4b9bd652b2bf0bc1bd0feae3f2f51009c13f (patch) | |
tree | 9c99ebb8f3067a39981d8bea07109fd7e7ba0d17 /dhcpv6/option_iaprefix_test.go | |
parent | 1e0fe5ce427973ca92a0dfb1a06a252ddb0dd4be (diff) |
dhcpv6: convert every Parse function to FromBytes
Signed-off-by: Chris Koch <chrisko@google.com>
Diffstat (limited to 'dhcpv6/option_iaprefix_test.go')
-rw-r--r-- | dhcpv6/option_iaprefix_test.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/dhcpv6/option_iaprefix_test.go b/dhcpv6/option_iaprefix_test.go index 27d0c95..be7e232 100644 --- a/dhcpv6/option_iaprefix_test.go +++ b/dhcpv6/option_iaprefix_test.go @@ -17,8 +17,8 @@ func TestOptIAPrefix(t *testing.T) { 36, // prefixLength 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, // ipv6Prefix } - opt, err := ParseOptIAPrefix(buf) - if err != nil { + var opt OptIAPrefix + if err := opt.FromBytes(buf); err != nil { t.Fatal(err) } want := &OptIAPrefix{ @@ -30,7 +30,7 @@ func TestOptIAPrefix(t *testing.T) { }, Options: PrefixOptions{[]Option{}}, } - if !reflect.DeepEqual(want, opt) { + if !reflect.DeepEqual(want, &opt) { t.Errorf("parseIAPrefix = %v, want %v", opt, want) } } @@ -79,7 +79,8 @@ func TestOptIAPrefixParseInvalidTooShort(t *testing.T) { 36, // prefixLength 0, 0, 0, 0, 0, 0, 0, // truncated ipv6Prefix } - if opt, err := ParseOptIAPrefix(buf); err == nil { + var opt OptIAPrefix + if err := opt.FromBytes(buf); err == nil { t.Fatalf("ParseOptIAPrefix: Expected error on truncated option, got %v", opt) } } @@ -91,7 +92,8 @@ func TestOptIAPrefixString(t *testing.T) { 36, // prefixLength 0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // ipv6Prefix } - opt, err := ParseOptIAPrefix(buf) + var opt OptIAPrefix + err := opt.FromBytes(buf) require.NoError(t, err) str := opt.String() |