github.com/pion/webrtc/v4@v4.0.1/iceconnectionstate_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 TestNewICEConnectionState(t *testing.T) { 13 testCases := []struct { 14 stateString string 15 expectedState ICEConnectionState 16 }{ 17 {ErrUnknownType.Error(), ICEConnectionStateUnknown}, 18 {"new", ICEConnectionStateNew}, 19 {"checking", ICEConnectionStateChecking}, 20 {"connected", ICEConnectionStateConnected}, 21 {"completed", ICEConnectionStateCompleted}, 22 {"disconnected", ICEConnectionStateDisconnected}, 23 {"failed", ICEConnectionStateFailed}, 24 {"closed", ICEConnectionStateClosed}, 25 } 26 27 for i, testCase := range testCases { 28 assert.Equal(t, 29 testCase.expectedState, 30 NewICEConnectionState(testCase.stateString), 31 "testCase: %d %v", i, testCase, 32 ) 33 } 34 } 35 36 func TestICEConnectionState_String(t *testing.T) { 37 testCases := []struct { 38 state ICEConnectionState 39 expectedString string 40 }{ 41 {ICEConnectionStateUnknown, ErrUnknownType.Error()}, 42 {ICEConnectionStateNew, "new"}, 43 {ICEConnectionStateChecking, "checking"}, 44 {ICEConnectionStateConnected, "connected"}, 45 {ICEConnectionStateCompleted, "completed"}, 46 {ICEConnectionStateDisconnected, "disconnected"}, 47 {ICEConnectionStateFailed, "failed"}, 48 {ICEConnectionStateClosed, "closed"}, 49 } 50 51 for i, testCase := range testCases { 52 assert.Equal(t, 53 testCase.expectedString, 54 testCase.state.String(), 55 "testCase: %d %v", i, testCase, 56 ) 57 } 58 }