diff --git a/pkg/scte35/segmentation_upid.go b/pkg/scte35/segmentation_upid.go index 1a3b8be7c..b1458832c 100644 --- a/pkg/scte35/segmentation_upid.go +++ b/pkg/scte35/segmentation_upid.go @@ -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] diff --git a/pkg/scte35/segmentation_upid_test.go b/pkg/scte35/segmentation_upid_test.go new file mode 100644 index 000000000..3b166bbcf --- /dev/null +++ b/pkg/scte35/segmentation_upid_test.go @@ -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()) + }) + } +}