diff --git a/ffprobe_test.go b/ffprobe_test.go index 91e19b2..2952ad4 100644 --- a/ffprobe_test.go +++ b/ffprobe_test.go @@ -111,6 +111,33 @@ func Test_ProbeReader_Error(t *testing.T) { } func validateData(t *testing.T, data *ProbeData) { + validateStreams(t, data) + // Check some Tags + const testMajorBrand = "isom" + if data.Format.Tags.MajorBrand != testMajorBrand { + t.Errorf("MajorBrand format tag is not %s", testMajorBrand) + } + + if val, err := data.Format.TagList.GetString("major_brand"); err != nil { + t.Errorf("retrieving major_brand tag errors: %v", err) + } else if val != testMajorBrand { + t.Errorf("MajorBrand format tag is not %s", testMajorBrand) + } + + // test Format.Duration + duration := data.Format.Duration() + if duration.Seconds() != 5.312 { + t.Errorf("this video is 5.312s.") + } + // test Format.StartTime + startTime := data.Format.StartTime() + if startTime != time.Duration(0) { + t.Errorf("this video starts at 0s.") + } + validateChapters(t, data) +} + +func validateStreams(t *testing.T, data *ProbeData) { // test ProbeData.GetStream stream := data.StreamType(StreamVideo) if len(stream) != 1 { @@ -158,30 +185,9 @@ func validateData(t *testing.T, data *ProbeData) { if len(stream) != 3 { t.Errorf("It should have three streams.") } +} - // Check some Tags - const testMajorBrand = "isom" - if data.Format.Tags.MajorBrand != testMajorBrand { - t.Errorf("MajorBrand format tag is not %s", testMajorBrand) - } - - if val, err := data.Format.TagList.GetString("major_brand"); err != nil { - t.Errorf("retrieving major_brand tag errors: %v", err) - } else if val != testMajorBrand { - t.Errorf("MajorBrand format tag is not %s", testMajorBrand) - } - - // test Format.Duration - duration := data.Format.Duration() - if duration.Seconds() != 5.312 { - t.Errorf("this video is 5.312s.") - } - // test Format.StartTime - startTime := data.Format.StartTime() - if startTime != time.Duration(0) { - t.Errorf("this video starts at 0s.") - } - +func validateChapters(t *testing.T, data *ProbeData) { chapters := data.Chapters if chapters == nil { t.Error("Chapters List was nil")