Skip to content

Commit

Permalink
Add tests for ID3v1 and ID3v1.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
upperstream authored and dhowden committed Jul 16, 2016
1 parent 028d342 commit c119c3e
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/id3v1_testdata.go
39 changes: 39 additions & 0 deletions id3v1_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// This file is subject to the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
// license. Its contents can be found at:
// http://creativecommons.org/publicdomain/zero/1.0

package tag

import (
"bytes"
"testing"
)

//go:generate go-bindata -o id3v1_testdata.go -pkg tag -ignore .txt id3v1_test

func TestReadID3v1Tags(t *testing.T) {
for _, name := range []string{
"id3v1_test/sample_usascii_v1.mp3",
"id3v1_test/sample_ms932_v1.mp3",
"id3v1_test/sample_utf8_v1.mp3"} {
doTest(name, 0, 30, t)
}
for _, name := range []string{
"id3v1_test/sample_usascii_v1.1.mp3",
"id3v1_test/sample_ms932_v1.1.mp3",
"id3v1_test/sample_utf8_v1.1.mp3"} {
doTest(name, 1, 28, t)
}
}

func doTest(name string, track int, length int, t *testing.T) {
mp3 := MustAsset(name)
metadata, _ := ReadID3v1Tags(bytes.NewReader(mp3))
if actual, total := metadata.Track(); actual != track || total != 0 {
t.Errorf("Track number for %s is (%d, %d) where (%d, 0) is expected.", name, actual, total, track)
}
comment := metadata.Raw()["comment"].(string)
if actual := len(comment); actual != length {
t.Errorf("Comment length for %s is %d where %d is expected", name, actual, length)
}
}
3 changes: 3 additions & 0 deletions id3v1_test/NOTICE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
All files in this directory are subject to the CC0 1.0 Universal (CC0 1.0)
Public Domain Dedication license. Its contents can be found at:
http://creativecommons.org/publicdomain/zero/1.0
Binary file added id3v1_test/sample_ms932_v1.1.mp3
Binary file not shown.
Binary file added id3v1_test/sample_ms932_v1.mp3
Binary file not shown.
Binary file added id3v1_test/sample_usascii_v1.1.mp3
Binary file not shown.
Binary file added id3v1_test/sample_usascii_v1.mp3
Binary file not shown.
Binary file added id3v1_test/sample_utf8_v1.1.mp3
Binary file not shown.
Binary file added id3v1_test/sample_utf8_v1.mp3
Binary file not shown.

0 comments on commit c119c3e

Please sign in to comment.