rtptransceiverdirection_test.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 TestNewRTPTransceiverDirection(t *testing.T) {
  9. testCases := []struct {
  10. directionString string
  11. expectedDirection RTPTransceiverDirection
  12. }{
  13. {unknownStr, RTPTransceiverDirection(Unknown)},
  14. {"sendrecv", RTPTransceiverDirectionSendrecv},
  15. {"sendonly", RTPTransceiverDirectionSendonly},
  16. {"recvonly", RTPTransceiverDirectionRecvonly},
  17. {"inactive", RTPTransceiverDirectionInactive},
  18. }
  19. for i, testCase := range testCases {
  20. assert.Equal(t,
  21. NewRTPTransceiverDirection(testCase.directionString),
  22. testCase.expectedDirection,
  23. "testCase: %d %v", i, testCase,
  24. )
  25. }
  26. }
  27. func TestRTPTransceiverDirection_String(t *testing.T) {
  28. testCases := []struct {
  29. direction RTPTransceiverDirection
  30. expectedString string
  31. }{
  32. {RTPTransceiverDirection(Unknown), unknownStr},
  33. {RTPTransceiverDirectionSendrecv, "sendrecv"},
  34. {RTPTransceiverDirectionSendonly, "sendonly"},
  35. {RTPTransceiverDirectionRecvonly, "recvonly"},
  36. {RTPTransceiverDirectionInactive, "inactive"},
  37. }
  38. for i, testCase := range testCases {
  39. assert.Equal(t,
  40. testCase.direction.String(),
  41. testCase.expectedString,
  42. "testCase: %d %v", i, testCase,
  43. )
  44. }
  45. }