Debian Codegraph @

util_test.go

raw symbols SCIP
1 // SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>
2 // SPDX-License-Identifier: MIT
3
4 package rtcpscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/
5
6 import (
7 "testingscip-go gomod github.com/golang/go/src go1.24.0 testing/"
8
9 "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/"
10 )
11
12 func TestGetPaddingscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/TestGetPadding().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) {
13 assert := assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Newscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/New().(t)
14 type testCase struct {
15 input int
16 result int
17 }
18
19 cases := []testCase{
20 {input: 0, result: 0},
21 {input: 1, result: 3},
22 {input: 2, result: 2},
23 {input: 3, result: 1},
24 {input: 4, result: 0},
25 {input: 100, result: 0},
26 {input: 500, result: 0},
27 }
28 for _, testCase := range cases {
29 assert.Equalfscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Assertions#Equalf().(
30 getPaddingscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/getPadding().(testCase.input), testCase.result, "Test case returned wrong value for input %d", testCase.input,
31 )
32 }
33 }
34
35 func TestSetNBitsOfUint16scip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/TestSetNBitsOfUint16().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) {
36 for _, test := range []struct {
37 name string
38 source uint16
39 size uint16
40 index uint16
41 value uint16
42 result uint16
43 expectedErr error
44 }{
45 {
46 "setOneBit", 0, 1, 8, 1, 128, nil,
47 },
48 {
49 "setStatusVectorBit", 0, 1, 0, 1, 32768, nil,
50 },
51 {
52 "setStatusVectorSecondBit", 32768, 1, 1, 1, 49152, nil,
53 },
54 {
55 "setStatusVectorInnerBitsAndCutValue", 49152, 2, 6, 11111, 49920, nil,
56 },
57 {
58 "setRunLengthSecondTwoBit", 32768, 2, 1, 1, 40960, nil,
59 },
60 {
61 "setOneBitOutOfBounds", 32768, 2, 15, 1, 0, errInvalidSizeOrStartIndexscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/errInvalidSizeOrStartIndex.,
62 },
63 } {
64 t.Runscip-go gomod github.com/golang/go/src go1.24.0 testing/T#Run().(test.name, func(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) {
65 got, err := setNBitsOfUint16scip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/setNBitsOfUint16().(test.source, test.size, test.index, test.value)
66 if test.expectedErr != nil {
67 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.ErrorIsscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/ErrorIs().(t, err, test.expectedErr)
68 } else {
69 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/NoError().(t, err)
70 }
71
72 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalfscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equalf().(t, test.result, got, "setNBitsOfUint16 %q", test.name)
73 })
74 }
75 }