github.com/pion/webrtc/v4@v4.0.1/rtptransceiverdirection_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 TestNewRTPTransceiverDirection(t *testing.T) { 13 testCases := []struct { 14 directionString string 15 expectedDirection RTPTransceiverDirection 16 }{ 17 {ErrUnknownType.Error(), RTPTransceiverDirectionUnknown}, 18 {"sendrecv", RTPTransceiverDirectionSendrecv}, 19 {"sendonly", RTPTransceiverDirectionSendonly}, 20 {"recvonly", RTPTransceiverDirectionRecvonly}, 21 {"inactive", RTPTransceiverDirectionInactive}, 22 } 23 24 for i, testCase := range testCases { 25 assert.Equal(t, 26 NewRTPTransceiverDirection(testCase.directionString), 27 testCase.expectedDirection, 28 "testCase: %d %v", i, testCase, 29 ) 30 } 31 } 32 33 func TestRTPTransceiverDirection_String(t *testing.T) { 34 testCases := []struct { 35 direction RTPTransceiverDirection 36 expectedString string 37 }{ 38 {RTPTransceiverDirectionUnknown, ErrUnknownType.Error()}, 39 {RTPTransceiverDirectionSendrecv, "sendrecv"}, 40 {RTPTransceiverDirectionSendonly, "sendonly"}, 41 {RTPTransceiverDirectionRecvonly, "recvonly"}, 42 {RTPTransceiverDirectionInactive, "inactive"}, 43 } 44 45 for i, testCase := range testCases { 46 assert.Equal(t, 47 testCase.direction.String(), 48 testCase.expectedString, 49 "testCase: %d %v", i, testCase, 50 ) 51 } 52 }