github.com/pion/webrtc/v3@v3.2.24/icecomponent_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 TestICEComponent(t *testing.T) {
    13  	testCases := []struct {
    14  		componentString   string
    15  		expectedComponent ICEComponent
    16  	}{
    17  		{unknownStr, ICEComponent(Unknown)},
    18  		{"rtp", ICEComponentRTP},
    19  		{"rtcp", ICEComponentRTCP},
    20  	}
    21  
    22  	for i, testCase := range testCases {
    23  		assert.Equal(t,
    24  			newICEComponent(testCase.componentString),
    25  			testCase.expectedComponent,
    26  			"testCase: %d %v", i, testCase,
    27  		)
    28  	}
    29  }
    30  
    31  func TestICEComponent_String(t *testing.T) {
    32  	testCases := []struct {
    33  		state          ICEComponent
    34  		expectedString string
    35  	}{
    36  		{ICEComponent(Unknown), unknownStr},
    37  		{ICEComponentRTP, "rtp"},
    38  		{ICEComponentRTCP, "rtcp"},
    39  	}
    40  
    41  	for i, testCase := range testCases {
    42  		assert.Equal(t,
    43  			testCase.state.String(),
    44  			testCase.expectedString,
    45  			"testCase: %d %v", i, testCase,
    46  		)
    47  	}
    48  }