github.com/pion/webrtc/v3@v3.2.24/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 {unknownStr, ICERole(Unknown)}, 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 {ICERole(Unknown), unknownStr}, 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 }