github.com/pion/webrtc/v4@v4.0.1/sdptype_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 TestNewSDPType(t *testing.T) { 13 testCases := []struct { 14 sdpTypeString string 15 expectedSDPType SDPType 16 }{ 17 {ErrUnknownType.Error(), SDPTypeUnknown}, 18 {"offer", SDPTypeOffer}, 19 {"pranswer", SDPTypePranswer}, 20 {"answer", SDPTypeAnswer}, 21 {"rollback", SDPTypeRollback}, 22 } 23 24 for i, testCase := range testCases { 25 assert.Equal(t, 26 testCase.expectedSDPType, 27 NewSDPType(testCase.sdpTypeString), 28 "testCase: %d %v", i, testCase, 29 ) 30 } 31 } 32 33 func TestSDPType_String(t *testing.T) { 34 testCases := []struct { 35 sdpType SDPType 36 expectedString string 37 }{ 38 {SDPTypeUnknown, ErrUnknownType.Error()}, 39 {SDPTypeOffer, "offer"}, 40 {SDPTypePranswer, "pranswer"}, 41 {SDPTypeAnswer, "answer"}, 42 {SDPTypeRollback, "rollback"}, 43 } 44 45 for i, testCase := range testCases { 46 assert.Equal(t, 47 testCase.expectedString, 48 testCase.sdpType.String(), 49 "testCase: %d %v", i, testCase, 50 ) 51 } 52 }