github.com/pion/webrtc/v4@v4.0.1/bundlepolicy_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 TestNewBundlePolicy(t *testing.T) { 13 testCases := []struct { 14 policyString string 15 expectedPolicy BundlePolicy 16 }{ 17 {ErrUnknownType.Error(), BundlePolicyUnknown}, 18 {"balanced", BundlePolicyBalanced}, 19 {"max-compat", BundlePolicyMaxCompat}, 20 {"max-bundle", BundlePolicyMaxBundle}, 21 } 22 23 for i, testCase := range testCases { 24 assert.Equal(t, 25 testCase.expectedPolicy, 26 newBundlePolicy(testCase.policyString), 27 "testCase: %d %v", i, testCase, 28 ) 29 } 30 } 31 32 func TestBundlePolicy_String(t *testing.T) { 33 testCases := []struct { 34 policy BundlePolicy 35 expectedString string 36 }{ 37 {BundlePolicyUnknown, ErrUnknownType.Error()}, 38 {BundlePolicyBalanced, "balanced"}, 39 {BundlePolicyMaxCompat, "max-compat"}, 40 {BundlePolicyMaxBundle, "max-bundle"}, 41 } 42 43 for i, testCase := range testCases { 44 assert.Equal(t, 45 testCase.expectedString, 46 testCase.policy.String(), 47 "testCase: %d %v", i, testCase, 48 ) 49 } 50 }