github.com/pion/dtls/v2@v2.2.12/pkg/protocol/extension/extension_test.go (about) 1 // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly> 2 // SPDX-License-Identifier: MIT 3 4 package extension 5 6 import ( 7 "errors" 8 "testing" 9 ) 10 11 func TestExtensions(t *testing.T) { 12 t.Run("Zero", func(t *testing.T) { 13 extensions, err := Unmarshal([]byte{}) 14 if err != nil || len(extensions) != 0 { 15 t.Fatal("Failed to decode zero extensions") 16 } 17 }) 18 19 t.Run("Invalid", func(t *testing.T) { 20 extensions, err := Unmarshal([]byte{0x00}) 21 if !errors.Is(err, errBufferTooSmall) || len(extensions) != 0 { 22 t.Fatal("Failed to error on invalid extension") 23 } 24 }) 25 }