github.com/cnotch/ipchub@v1.1.0/av/codec/aac/asc_test.go (about) 1 // Copyright (c) 2019,CAOHONGJU All rights reserved. 2 // Use of this source code is governed by a MIT-style 3 // license that can be found in the LICENSE file. 4 5 package aac 6 7 import ( 8 "testing" 9 10 "github.com/stretchr/testify/assert" 11 ) 12 13 func TestAudioSpecificConfig_DecodeString(t *testing.T) { 14 tests := []struct { 15 name string 16 config string 17 wantErr bool 18 objectType uint8 19 sampleRate int 20 channels uint8 21 }{ 22 {"case1", "121056E500", false, 2, 44100, 2}, 23 {"case2", "1190", false, 2, 48000, 2}, 24 } 25 for _, tt := range tests { 26 t.Run(tt.name, func(t *testing.T) { 27 var asc AudioSpecificConfig 28 if err := asc.DecodeString(tt.config); (err != nil) != tt.wantErr { 29 t.Errorf("AudioSpecificConfig.DecodeString() error = %v, wantErr %v", err, tt.wantErr) 30 } 31 assert.Equal(t, asc.ObjectType, tt.objectType) 32 assert.Equal(t, asc.SampleRate, tt.sampleRate) 33 assert.Equal(t, asc.Channels, tt.channels) 34 }) 35 } 36 }