github.com/pion/webrtc/v3@v3.2.24/dtlstransportstate_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 TestNewDTLSTransportState(t *testing.T) { 13 testCases := []struct { 14 stateString string 15 expectedState DTLSTransportState 16 }{ 17 {unknownStr, DTLSTransportState(Unknown)}, 18 {"new", DTLSTransportStateNew}, 19 {"connecting", DTLSTransportStateConnecting}, 20 {"connected", DTLSTransportStateConnected}, 21 {"closed", DTLSTransportStateClosed}, 22 {"failed", DTLSTransportStateFailed}, 23 } 24 25 for i, testCase := range testCases { 26 assert.Equal(t, 27 testCase.expectedState, 28 newDTLSTransportState(testCase.stateString), 29 "testCase: %d %v", i, testCase, 30 ) 31 } 32 } 33 34 func TestDTLSTransportState_String(t *testing.T) { 35 testCases := []struct { 36 state DTLSTransportState 37 expectedString string 38 }{ 39 {DTLSTransportState(Unknown), unknownStr}, 40 {DTLSTransportStateNew, "new"}, 41 {DTLSTransportStateConnecting, "connecting"}, 42 {DTLSTransportStateConnected, "connected"}, 43 {DTLSTransportStateClosed, "closed"}, 44 {DTLSTransportStateFailed, "failed"}, 45 } 46 47 for i, testCase := range testCases { 48 assert.Equal(t, 49 testCase.expectedString, 50 testCase.state.String(), 51 "testCase: %d %v", i, testCase, 52 ) 53 } 54 }