Skip to content

Commit

Permalink
fix: panic when calling SegmentationUPID.ASCIIValue (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
blahspam authored Aug 11, 2023
1 parent 6fe7b84 commit a054f7c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/scte35/segmentation_upid.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func (upid *SegmentationUPID) Name() string {
// range are represented by a dot (".").
func (upid *SegmentationUPID) ASCIIValue() string {
b := upid.valueBytes()
rs := make([]byte, 0, len(b))
rs := make([]byte, len(b))
for i := range b {
if b[i] > 31 && b[i] < 127 {
rs[i] = b[i]
Expand Down
29 changes: 29 additions & 0 deletions pkg/scte35/segmentation_upid_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package scte35_test

import (
"testing"

"github.com/Comcast/scte35-go/pkg/scte35"
"github.com/stretchr/testify/require"
)

func TestSegmentationUPID_ASCIIValue(t *testing.T) {
cases := map[string]struct {
upid scte35.SegmentationUPID
expected string
}{
"Simple": {
upid: scte35.SegmentationUPID{
Type: 0x09,
Value: "SIGNAL:z1sFOMjCnV4AAAAAAAABAQ==",
},
expected: "SIGNAL:z1sFOMjCnV4AAAAAAAABAQ==",
},
}

for k, c := range cases {
t.Run(k, func(t *testing.T) {
require.Equal(t, c.expected, c.upid.ASCIIValue())
})
}
}

0 comments on commit a054f7c

Please sign in to comment.