github.com/pion/webrtc/v4@v4.0.1/icerole_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 TestNewICERole(t *testing.T) { 13 testCases := []struct { 14 roleString string 15 expectedRole ICERole 16 }{ 17 {ErrUnknownType.Error(), ICERoleUnknown}, 18 {"controlling", ICERoleControlling}, 19 {"controlled", ICERoleControlled}, 20 } 21 22 for i, testCase := range testCases { 23 assert.Equal(t, 24 testCase.expectedRole, 25 newICERole(testCase.roleString), 26 "testCase: %d %v", i, testCase, 27 ) 28 } 29 } 30 31 func TestICERole_String(t *testing.T) { 32 testCases := []struct { 33 proto ICERole 34 expectedString string 35 }{ 36 {ICERoleUnknown, ErrUnknownType.Error()}, 37 {ICERoleControlling, "controlling"}, 38 {ICERoleControlled, "controlled"}, 39 } 40 41 for i, testCase := range testCases { 42 assert.Equal(t, 43 testCase.expectedString, 44 testCase.proto.String(), 45 "testCase: %d %v", i, testCase, 46 ) 47 } 48 }