github.com/bluenviron/mediacommon@v1.9.3/pkg/codecs/opus/packet_duration_test.go (about)

     1  package opus
     2  
     3  import (
     4  	"testing"
     5  	"time"
     6  
     7  	"github.com/stretchr/testify/require"
     8  )
     9  
    10  var casesPacketDuration = []struct {
    11  	name     string
    12  	byts     []byte
    13  	duration time.Duration
    14  }{
    15  	{
    16  		"aa",
    17  		[]byte{1},
    18  		20 * time.Millisecond,
    19  	},
    20  }
    21  
    22  func TestPacketDuration(t *testing.T) {
    23  	for _, ca := range casesPacketDuration {
    24  		t.Run(ca.name, func(t *testing.T) {
    25  			require.Equal(t, ca.duration, PacketDuration(ca.byts))
    26  		})
    27  	}
    28  }
    29  
    30  func FuzzPacketDuration(f *testing.F) {
    31  	f.Fuzz(func(_ *testing.T, b []byte) {
    32  		PacketDuration(b)
    33  	})
    34  }