bundlepolicy_test.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
  2. // SPDX-License-Identifier: MIT
  3. package webrtc
  4. import (
  5. "testing"
  6. "github.com/stretchr/testify/assert"
  7. )
  8. func TestNewBundlePolicy(t *testing.T) {
  9. testCases := []struct {
  10. policyString string
  11. expectedPolicy BundlePolicy
  12. }{
  13. {unknownStr, BundlePolicy(Unknown)},
  14. {"balanced", BundlePolicyBalanced},
  15. {"max-compat", BundlePolicyMaxCompat},
  16. {"max-bundle", BundlePolicyMaxBundle},
  17. }
  18. for i, testCase := range testCases {
  19. assert.Equal(t,
  20. testCase.expectedPolicy,
  21. newBundlePolicy(testCase.policyString),
  22. "testCase: %d %v", i, testCase,
  23. )
  24. }
  25. }
  26. func TestBundlePolicy_String(t *testing.T) {
  27. testCases := []struct {
  28. policy BundlePolicy
  29. expectedString string
  30. }{
  31. {BundlePolicy(Unknown), unknownStr},
  32. {BundlePolicyBalanced, "balanced"},
  33. {BundlePolicyMaxCompat, "max-compat"},
  34. {BundlePolicyMaxBundle, "max-bundle"},
  35. }
  36. for i, testCase := range testCases {
  37. assert.Equal(t,
  38. testCase.expectedString,
  39. testCase.policy.String(),
  40. "testCase: %d %v", i, testCase,
  41. )
  42. }
  43. }