From 47cac296d0babb552fedb6cca9b13c18ff7fc488 Mon Sep 17 00:00:00 2001 From: Florian Lehner Date: Thu, 13 May 2021 09:32:08 +0200 Subject: [PATCH] extend test Signed-off-by: Florian Lehner --- m_action_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/m_action_test.go b/m_action_test.go index 8c5954d..2520255 100644 --- a/m_action_test.go +++ b/m_action_test.go @@ -83,4 +83,24 @@ func TestAction(t *testing.T) { t.Fatalf("unexpected error: %v", err) } }) + + t.Run("unmarshalAction(unknown)", func(t *testing.T) { + info := &Action{} + if err := unmarshalAction(generateActUnknown(t), info); err == nil { + t.Fatal("Expected error but got none") + } + }) +} + +func generateActUnknown(t *testing.T) []byte { + t.Helper() + options := []tcOption{} + options = append(options, tcOption{Interpretation: vtString, Type: tcaActKind, Data: "unknown"}) + options = append(options, tcOption{Interpretation: vtBytes, Type: tcaActOptions, Data: []byte{0x42}}) + + data, err := marshalAttributes(options) + if err != nil { + t.Fatalf("could not generate test data: %v", err) + } + return data }