summaryrefslogtreecommitdiffhomepage
path: root/dhcpv6/option_requestedoption_test.go
diff options
context:
space:
mode:
authorChris Koch <chrisko@google.com>2023-02-19 13:59:24 -0800
committerChris K <c@chrisko.ch>2023-02-19 22:39:16 -0800
commit5369909a5de7c157e56e0feebbfde0b190e7a614 (patch)
treed72fdc57ca90546c5578f1949a95c9945615642a /dhcpv6/option_requestedoption_test.go
parenta3bc2a6d841c820e7297fe54731f8d91d0721426 (diff)
Tests for option deserialization & getters
Tests that for the correct option code, the correct deserialization is applied. Signed-off-by: Chris Koch <chrisko@google.com>
Diffstat (limited to 'dhcpv6/option_requestedoption_test.go')
-rw-r--r--dhcpv6/option_requestedoption_test.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/dhcpv6/option_requestedoption_test.go b/dhcpv6/option_requestedoption_test.go
index e5d7bfc..bb837db 100644
--- a/dhcpv6/option_requestedoption_test.go
+++ b/dhcpv6/option_requestedoption_test.go
@@ -1,11 +1,31 @@
package dhcpv6
import (
+ "reflect"
"testing"
"github.com/stretchr/testify/require"
)
+func TestParseMessageOptionsWithORO(t *testing.T) {
+ buf := []byte{
+ 0, 6, // ORO option
+ 0, 2, // length
+ 0, 3, // IANA Option
+ 0, 6, // ORO
+ 0, 2, // length
+ 0, 4, // IATA
+ }
+
+ want := OptionCodes{OptionIANA, OptionIATA}
+ var mo MessageOptions
+ if err := mo.FromBytes(buf); err != nil {
+ t.Errorf("FromBytes = %v", err)
+ } else if got := mo.RequestedOptions(); !reflect.DeepEqual(got, want) {
+ t.Errorf("ORO = %v, want %v", got, want)
+ }
+}
+
func TestOptRequestedOption(t *testing.T) {
expected := []byte{0, 1, 0, 2}
var o optRequestedOption