Пример #1
0
func TestExtractMaximumLengthFieldsFromValid11Tag(t *testing.T) {
	buf, r := bufWrap(VALID_TAG)
	buf[len(buf)-3] = 0x00
	buf[len(buf)-2] = 0x01
	buf[len(buf)-1] = 0x0d
	tag, err := mp3agic.ExtractId3v1Tag(r)
	if err != nil {
		t.Error(err)
		return
	}
	assert(t, tag.Comment() == "COMMENT123456789012345678901", "comment", tag.Comment())
	assert(t, tag.Track() == "1", "track", tag.Track())
	assert(t, tag.Genre() == 0x0D, "genre", tag.Genre())
	assert(t, tag.GenreDescription() == "Pop", "genre description", tag.GenreDescription())
}
Пример #2
0
func TestExtractMaximumLengthFieldsFromValid10Tag(t *testing.T) {
	buf, reader := bufWrap(VALID_TAG)
	buf[len(buf)-1] = 0x8D
	tag, err := mp3agic.ExtractId3v1Tag(reader)
	if err != nil {
		t.Error(err)
		return
	}
	assert(t, tag.Title() == "TITLE1234567890123456789012345", "title", tag.Title())
	assert(t, tag.Artist() == "ARTIST123456789012345678901234", "artist", tag.Artist())
	assert(t, tag.Album() == "ALBUM1234567890123456789012345", "album", tag.Album())
	assert(t, tag.Year() == "2001", "year", tag.Year())
	assert(t, tag.Comment() == "COMMENT12345678901234567890123", "comment", tag.Comment())
	assert(t, tag.Track() == "", "track", tag.Track())
	assert(t, tag.Genre() == 0x8D, "genre", tag.Genre())
	assert(t, tag.GenreDescription() == "Synthpop", "genre description", tag.GenreDescription())
}
Пример #3
0
func TestExtractTrimmedFieldsFromValid11TagWithNullspace(t *testing.T) {
	buf, r := bufWrap(strings.Replace(VALID_TAG_WITH_WHITESPACE, " ", "\x00", -1))
	buf[len(buf)-3] = 0x00
	buf[len(buf)-2] = 0x01
	buf[len(buf)-1] = 0x0d
	tag, err := mp3agic.ExtractId3v1Tag(r)
	if err != nil {
		t.Error(err)
		return
	}
	assert(t, tag.Title() == "TITLE", "title", tag.Title())
	assert(t, tag.Artist() == "ARTIST", "artist", tag.Artist())
	assert(t, tag.Album() == "ALBUM", "album", tag.Album())
	assert(t, tag.Year() == "2001", "year", tag.Year())
	assert(t, tag.Comment() == "COMMENT", "comment", tag.Comment())
	assert(t, tag.Track() == "1", "track", tag.Track())
	assert(t, tag.Genre() == 0x0D, "genre", tag.Genre())
	assert(t, tag.GenreDescription() == "Pop", "genre description", tag.GenreDescription())
}
Пример #4
0
func TestReadTagFieldsFromMp3(t *testing.T) {
	f, err := os.Open(RES_DIR+"v1andv23tags.mp3", os.O_RDONLY, 0)
	if err != nil {
		t.Error(err)
		return
	}
	defer f.Close()

	tag, err := mp3agic.ExtractId3v1Tag(f)
	if err != nil {
		t.Error(err)
		return
	}

	assert(t, tag.Track() == "1", "track", tag.Track())
	assert(t, tag.Artist() == "ARTIST123456789012345678901234", "artist", tag.Artist())
	assert(t, tag.Title() == "TITLE1234567890123456789012345", "title", tag.Title())
	assert(t, tag.Album() == "ALBUM1234567890123456789012345", "album", tag.Album())
	assert(t, tag.Year() == "2001", "year", tag.Year())
	assert(t, tag.Genre() == 0x0d, "genre", tag.Genre())
	assert(t, tag.GenreDescription() == "Pop", "genre description", tag.GenreDescription())
	assert(t, tag.Comment() == "COMMENT123456789012345678901", "comment", tag.Comment())
}