github.com/pion/webrtc/v4@v4.0.1/sctptransportstate_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 TestNewSCTPTransportState(t *testing.T) { 13 testCases := []struct { 14 transportStateString string 15 expectedTransportState SCTPTransportState 16 }{ 17 {ErrUnknownType.Error(), SCTPTransportStateUnknown}, 18 {"connecting", SCTPTransportStateConnecting}, 19 {"connected", SCTPTransportStateConnected}, 20 {"closed", SCTPTransportStateClosed}, 21 } 22 23 for i, testCase := range testCases { 24 assert.Equal(t, 25 testCase.expectedTransportState, 26 newSCTPTransportState(testCase.transportStateString), 27 "testCase: %d %v", i, testCase, 28 ) 29 } 30 } 31 32 func TestSCTPTransportState_String(t *testing.T) { 33 testCases := []struct { 34 transportState SCTPTransportState 35 expectedString string 36 }{ 37 {SCTPTransportStateUnknown, ErrUnknownType.Error()}, 38 {SCTPTransportStateConnecting, "connecting"}, 39 {SCTPTransportStateConnected, "connected"}, 40 {SCTPTransportStateClosed, "closed"}, 41 } 42 43 for i, testCase := range testCases { 44 assert.Equal(t, 45 testCase.expectedString, 46 testCase.transportState.String(), 47 "testCase: %d %v", i, testCase, 48 ) 49 } 50 }