icecomponent_test.go 971 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
  2. // SPDX-License-Identifier: MIT
  3. package webrtc
  4. import (
  5. "testing"
  6. "github.com/stretchr/testify/assert"
  7. )
  8. func TestICEComponent(t *testing.T) {
  9. testCases := []struct {
  10. componentString string
  11. expectedComponent ICEComponent
  12. }{
  13. {unknownStr, ICEComponent(Unknown)},
  14. {"rtp", ICEComponentRTP},
  15. {"rtcp", ICEComponentRTCP},
  16. }
  17. for i, testCase := range testCases {
  18. assert.Equal(t,
  19. newICEComponent(testCase.componentString),
  20. testCase.expectedComponent,
  21. "testCase: %d %v", i, testCase,
  22. )
  23. }
  24. }
  25. func TestICEComponent_String(t *testing.T) {
  26. testCases := []struct {
  27. state ICEComponent
  28. expectedString string
  29. }{
  30. {ICEComponent(Unknown), unknownStr},
  31. {ICEComponentRTP, "rtp"},
  32. {ICEComponentRTCP, "rtcp"},
  33. }
  34. for i, testCase := range testCases {
  35. assert.Equal(t,
  36. testCase.state.String(),
  37. testCase.expectedString,
  38. "testCase: %d %v", i, testCase,
  39. )
  40. }
  41. }