ice_test.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
  2. // SPDX-License-Identifier: MIT
  3. package ice
  4. import (
  5. "testing"
  6. "github.com/stretchr/testify/assert"
  7. )
  8. func TestConnectedState_String(t *testing.T) {
  9. testCases := []struct {
  10. connectionState ConnectionState
  11. expectedString string
  12. }{
  13. {ConnectionStateUnknown, "Invalid"},
  14. {ConnectionStateNew, "New"},
  15. {ConnectionStateChecking, "Checking"},
  16. {ConnectionStateConnected, "Connected"},
  17. {ConnectionStateCompleted, "Completed"},
  18. {ConnectionStateFailed, "Failed"},
  19. {ConnectionStateDisconnected, "Disconnected"},
  20. {ConnectionStateClosed, "Closed"},
  21. }
  22. for i, testCase := range testCases {
  23. assert.Equal(t,
  24. testCase.expectedString,
  25. testCase.connectionState.String(),
  26. "testCase: %d %v", i, testCase,
  27. )
  28. }
  29. }
  30. func TestGatheringState_String(t *testing.T) {
  31. testCases := []struct {
  32. gatheringState GatheringState
  33. expectedString string
  34. }{
  35. {GatheringStateUnknown, ErrUnknownType.Error()},
  36. {GatheringStateNew, "new"},
  37. {GatheringStateGathering, "gathering"},
  38. {GatheringStateComplete, "complete"},
  39. }
  40. for i, testCase := range testCases {
  41. assert.Equal(t,
  42. testCase.expectedString,
  43. testCase.gatheringState.String(),
  44. "testCase: %d %v", i, testCase,
  45. )
  46. }
  47. }