sctptransportstate_test.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 TestNewSCTPTransportState(t *testing.T) {
  9. testCases := []struct {
  10. transportStateString string
  11. expectedTransportState SCTPTransportState
  12. }{
  13. {unknownStr, SCTPTransportState(Unknown)},
  14. {"connecting", SCTPTransportStateConnecting},
  15. {"connected", SCTPTransportStateConnected},
  16. {"closed", SCTPTransportStateClosed},
  17. }
  18. for i, testCase := range testCases {
  19. assert.Equal(t,
  20. testCase.expectedTransportState,
  21. newSCTPTransportState(testCase.transportStateString),
  22. "testCase: %d %v", i, testCase,
  23. )
  24. }
  25. }
  26. func TestSCTPTransportState_String(t *testing.T) {
  27. testCases := []struct {
  28. transportState SCTPTransportState
  29. expectedString string
  30. }{
  31. {SCTPTransportState(Unknown), unknownStr},
  32. {SCTPTransportStateConnecting, "connecting"},
  33. {SCTPTransportStateConnected, "connected"},
  34. {SCTPTransportStateClosed, "closed"},
  35. }
  36. for i, testCase := range testCases {
  37. assert.Equal(t,
  38. testCase.expectedString,
  39. testCase.transportState.String(),
  40. "testCase: %d %v", i, testCase,
  41. )
  42. }
  43. }