Skip to content

Commit

Permalink
test: more unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tobbee committed Nov 4, 2024
1 parent 5131098 commit b664ed7
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 0 deletions.
18 changes: 18 additions & 0 deletions mp4/av1c_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package mp4

import (
"testing"

"github.com/Eyevinn/mp4ff/av1"
)

func TestEncodeDecodeAvc1(t *testing.T) {
adc := Av1CBox{
CodecConfRec: av1.CodecConfRec{
Version: 1,
},
}

boxDiffAfterEncodeAndDecode(t, &adc)

}
11 changes: 11 additions & 0 deletions mp4/cdat_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package mp4

import "testing"

func TestEncodeDecodeCdat(t *testing.T) {

cdat := CdatBox{
Data: []byte{0x01, 0x02, 0x03, 0x04},
}
boxDiffAfterEncodeAndDecode(t, &cdat)
}
52 changes: 52 additions & 0 deletions mp4/stsd_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package mp4

import (
"bytes"
"testing"

"github.com/Eyevinn/mp4ff/aac"
)

func TestStsd(t *testing.T) {
stsd := StsdBox{}
samplingFrequency := 48000
asc := &aac.AudioSpecificConfig{
ObjectType: 2,
ChannelConfiguration: 2,
SamplingFrequency: samplingFrequency,
ExtensionFrequency: 0,
SBRPresentFlag: false,
PSPresentFlag: false,
}
buf := &bytes.Buffer{}
err := asc.Encode(buf)
if err != nil {
t.Error(err)
}
ascBytes := buf.Bytes()
esds := CreateEsdsBox(ascBytes)
mp4a := CreateAudioSampleEntryBox("mp4a",
uint16(asc.ChannelConfiguration),
16, uint16(samplingFrequency), esds)
btrt := BtrtBox{
BufferSizeDB: 1536,
MaxBitrate: 96000,
AvgBitrate: 96000,
}
mp4a.AddChild(&btrt)
stsd.AddChild(mp4a)
if len(stsd.Children) != 1 {
t.Error("Expected one child")
}
if stsd.Mp4a == nil {
t.Error("Expected mp4a child")
}
gb := stsd.GetBtrt()
if gb == nil {
t.Error("Expected btrt")
} else {
if *gb != btrt {
t.Errorf("Got btrt %v, expected %v", *gb, btrt)
}
}
}
8 changes: 8 additions & 0 deletions mp4/version_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package mp4

import "fmt"

func ExampleGetVersion() {
fmt.Println(GetVersion())
// Output: v0.46, date: 2024-08-08
}

0 comments on commit b664ed7

Please sign in to comment.