github.com/pion/webrtc/v4@v4.0.1/icegatheringstate_test.go (about) 1 // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly> 2 // SPDX-License-Identifier: MIT 3 4 package webrtc 5 6 import ( 7 "testing" 8 9 "github.com/stretchr/testify/assert" 10 ) 11 12 func TestNewICEGatheringState(t *testing.T) { 13 testCases := []struct { 14 stateString string 15 expectedState ICEGatheringState 16 }{ 17 {ErrUnknownType.Error(), ICEGatheringStateUnknown}, 18 {"new", ICEGatheringStateNew}, 19 {"gathering", ICEGatheringStateGathering}, 20 {"complete", ICEGatheringStateComplete}, 21 } 22 23 for i, testCase := range testCases { 24 assert.Equal(t, 25 testCase.expectedState, 26 NewICEGatheringState(testCase.stateString), 27 "testCase: %d %v", i, testCase, 28 ) 29 } 30 } 31 32 func TestICEGatheringState_String(t *testing.T) { 33 testCases := []struct { 34 state ICEGatheringState 35 expectedString string 36 }{ 37 {ICEGatheringStateUnknown, ErrUnknownType.Error()}, 38 {ICEGatheringStateNew, "new"}, 39 {ICEGatheringStateGathering, "gathering"}, 40 {ICEGatheringStateComplete, "complete"}, 41 } 42 43 for i, testCase := range testCases { 44 assert.Equal(t, 45 testCase.expectedString, 46 testCase.state.String(), 47 "testCase: %d %v", i, testCase, 48 ) 49 } 50 }