Skip to content

Commit

Permalink
frame: skip frame hash test if no MD5 hash was set in StreamInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
mewmew committed Nov 18, 2023
1 parent 50b27ff commit fbea67c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion frame/frame_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ var golden = []struct {
}

func TestFrameHash(t *testing.T) {
var zeroHash [md5.Size]byte
for _, g := range golden {
t.Run(g.path, func(t *testing.T) {
stream, err := flac.Open(g.path)
Expand All @@ -103,6 +104,13 @@ func TestFrameHash(t *testing.T) {
}
defer stream.Close()

// Skip frame hash test if no MD5 hash was set in StreamInfo.
want := stream.Info.MD5sum[:]
if bytes.Equal(want, zeroHash[:]) {
t.Skipf("path=%q, skipping frame hash test as no MD5 hash was set in StreamInfo", g.path)
return
}

md5sum := md5.New()
for frameNum := 0; ; frameNum++ {
frame, err := stream.ParseNext()
Expand All @@ -115,7 +123,6 @@ func TestFrameHash(t *testing.T) {
}
frame.Hash(md5sum)
}
want := stream.Info.MD5sum[:]
got := md5sum.Sum(nil)
// Verify the decoded audio samples by comparing the MD5 checksum that is
// stored in StreamInfo with the computed one.
Expand Down

0 comments on commit fbea67c

Please sign in to comment.