icegatheringstate_test.go 1.1 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 TestNewICEGatheringState(t *testing.T) {
  9. testCases := []struct {
  10. stateString string
  11. expectedState ICEGatheringState
  12. }{
  13. {unknownStr, ICEGatheringState(Unknown)},
  14. {"new", ICEGatheringStateNew},
  15. {"gathering", ICEGatheringStateGathering},
  16. {"complete", ICEGatheringStateComplete},
  17. }
  18. for i, testCase := range testCases {
  19. assert.Equal(t,
  20. testCase.expectedState,
  21. NewICEGatheringState(testCase.stateString),
  22. "testCase: %d %v", i, testCase,
  23. )
  24. }
  25. }
  26. func TestICEGatheringState_String(t *testing.T) {
  27. testCases := []struct {
  28. state ICEGatheringState
  29. expectedString string
  30. }{
  31. {ICEGatheringState(Unknown), unknownStr},
  32. {ICEGatheringStateNew, "new"},
  33. {ICEGatheringStateGathering, "gathering"},
  34. {ICEGatheringStateComplete, "complete"},
  35. }
  36. for i, testCase := range testCases {
  37. assert.Equal(t,
  38. testCase.expectedString,
  39. testCase.state.String(),
  40. "testCase: %d %v", i, testCase,
  41. )
  42. }
  43. }