extension_test.go 576 B

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