* tests/run-test: Dummy file to inflict happiness upon autotools * tests/EntaggedTest.cs: New tests for M4A, and single/dual-tag mp3. * tests/samples/sample.m4a: Added a tag. * tests/samples/sample_v1_only.mp3, sample_v2_only.mp3, sample_both.mp3: 3 mp3 test cases, with varying tag combinations. * src/Mp3/Util/Id3v23TagReader.cs: Fixed reading of id3v2 comment. * src/Makefile: Fixed building of m4a reader. Index: tests/run-test =================================================================== --- tests/run-test (revision 0) +++ tests/run-test (revision 0) @@ -0,0 +1,2 @@ +#!/bin/sh +echo Property changes on: tests/run-test ___________________________________________________________________ Name: svn:executable + * Index: tests/EntaggedTest.cs =================================================================== --- tests/EntaggedTest.cs (revision 48573) +++ tests/EntaggedTest.cs (working copy) @@ -1,3 +1,28 @@ +/*************************************************************************** + * Copyright 2005 Daniel Drake + ****************************************************************************/ + +/* THIS FILE IS LICENSED UNDER THE MIT LICENSE AS OUTLINED IMMEDIATELY BELOW: + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + using System; using Entagged; using NUnit.Framework; @@ -51,31 +76,117 @@ } [TestFixture] -public class Mp3Test { +public class Mp3BothTest { private AudioFileWrapper afw; [TestFixtureSetUp] public void Init() { - afw = new AudioFileWrapper("samples/sample.mp3"); + afw = new AudioFileWrapper("samples/sample_both.mp3"); } [Test] public void ReadTag() { + Assert.AreEqual("MP3 album v2", afw.Album); + Assert.AreEqual("MP3 artist", afw.Artist); + Assert.AreEqual("MP3 comment v2", afw.Comment); + Assert.AreEqual("Acid Punk", afw.Genre); + Assert.AreEqual("MP3 title v2", afw.Title); + Assert.AreEqual(6, afw.TrackNumber); + Assert.AreEqual(7, afw.TrackCount); + Assert.AreEqual(1234, afw.Year); + } + + [Test] + public void TwoTags() + { + Assert.AreEqual(2, afw.Albums.Length); + Assert.AreEqual(1, afw.Artists.Length); + Assert.AreEqual(2, afw.Comments.Length); + Assert.AreEqual(2, afw.Genres.Length); + Assert.AreEqual(2, afw.TrackNumbers.Length); + Assert.AreEqual(1, afw.TrackCounts.Length); + Assert.AreEqual(2, afw.Years.Length); + } + + [Test] + public void FirstTag() + { + Assert.AreEqual("MP3 title v2", afw.Titles[0] as string); + Assert.AreEqual("MP3 album v2", afw.Albums[0] as string); + Assert.AreEqual("MP3 comment v2", afw.Comments[0] as string); + Assert.AreEqual(1234, (int) afw.Years[0]); + Assert.AreEqual(6, (int) afw.TrackNumbers[0]); + Assert.AreEqual(7, (int) afw.TrackCounts[0]); + } + + [Test] + public void SecondTag() + { + Assert.AreEqual("MP3 title", afw.Titles[1] as string); + Assert.AreEqual("MP3 album", afw.Albums[1] as string); + Assert.AreEqual("MP3 comment", afw.Comments[1] as string); + Assert.AreEqual("MP3 artist", afw.Artists[0] as string); + Assert.AreEqual(1235, (int) afw.Years[1]); + Assert.AreEqual(6, (int) afw.TrackNumbers[1]); + Assert.AreEqual(7, (int) afw.TrackCounts[0]); + } +} + +[TestFixture] +public class Mp3V1Test +{ + private AudioFileWrapper afw; + + [TestFixtureSetUp] + public void Init() + { + afw = new AudioFileWrapper("samples/sample_v1_only.mp3"); + } + + [Test] + public void ReadTag() + { Assert.AreEqual("MP3 album", afw.Album); Assert.AreEqual("MP3 artist", afw.Artist); Assert.AreEqual("MP3 comment", afw.Comment); Assert.AreEqual("Acid Punk", afw.Genre); Assert.AreEqual("MP3 title", afw.Title); Assert.AreEqual(6, afw.TrackNumber); + Assert.AreEqual(1234, afw.Year); + } + +} + +[TestFixture] +public class Mp3V2Test +{ + private AudioFileWrapper afw; + + [TestFixtureSetUp] + public void Init() + { + afw = new AudioFileWrapper("samples/sample_v2_only.mp3"); + } + + [Test] + public void ReadTag() + { + Assert.AreEqual("MP3 album", afw.Album); + Assert.AreEqual("MP3 artist", afw.Artist); + Assert.AreEqual("MP3 comment", afw.Comment); + Assert.AreEqual("Acid Punk", afw.Genre); + Assert.AreEqual("MP3 title", afw.Title); + Assert.AreEqual(6, afw.TrackNumber); Assert.AreEqual(7, afw.TrackCount); Assert.AreEqual(1234, afw.Year); } + } [TestFixture] -public class TestMpc { +public class MpcTest { private AudioFileWrapper afw; [TestFixtureSetUp] @@ -99,12 +210,35 @@ } [TestFixture] -public class TestOgg { +public class M4aTest { private AudioFileWrapper afw; [TestFixtureSetUp] public void Init() { + afw = new AudioFileWrapper("samples/sample.m4a"); + } + + [Test] + public void ReadTag() + { + Assert.AreEqual("M4A album", afw.Album); + Assert.AreEqual("M4A artist", afw.Artist); + Assert.AreEqual("M4A comment", afw.Comment); + Assert.AreEqual("Acid Punk", afw.Genre); + Assert.AreEqual("M4A title", afw.Title); + Assert.AreEqual(6, afw.TrackNumber); + Assert.AreEqual(1234, afw.Year); + } +} + +[TestFixture] +public class OggTest { + private AudioFileWrapper afw; + + [TestFixtureSetUp] + public void Init() + { afw = new AudioFileWrapper("samples/sample.ogg"); } Index: tests/samples/sample.mp3 =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: tests/samples/sample.m4a =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: tests/samples/sample_v1_only.mp3 =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: tests/samples/sample_v1_only.mp3 ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Index: tests/samples/sample_v2_only.mp3 =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: tests/samples/sample_v2_only.mp3 ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Index: tests/samples/sample_both.mp3 =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: src/Mp3/Util/Id3v23TagReader.cs =================================================================== --- src/Mp3/Util/Id3v23TagReader.cs (revision 48573) +++ src/Mp3/Util/Id3v23TagReader.cs (working copy) @@ -79,8 +79,10 @@ break; //string field = Encoding.ASCII.GetString(b); - if (field == "" || field.Length < 4 || field[0] != 'T' || field[1] == 'X') + if (field == "" || field.Length < 4) continue; + if (field != "COMM" && (field[0] != 'T' || field[1] == 'X')) + continue; b = new byte[ frameSize + ((version == Id3Tag.ID3V23) ? 2 : 0) ]; data.Get(b); Index: src/Makefile.am =================================================================== --- src/Makefile.am (revision 48573) +++ src/Makefile.am (working copy) @@ -73,7 +73,7 @@ $(OGG_CSFILES) \ $(MPC_CSFILES) \ $(MP3_CSFILES) \ - $(M4a_CSFILES) + $(M4A_CSFILES) all: $(ASSEMBLY) Index: ChangeLog =================================================================== --- ChangeLog (revision 48573) +++ ChangeLog (working copy) @@ -7,6 +7,14 @@ Fixed some minor reader bugs/omissions which means the tests now pass in full. + * tests/run-test: Dummy file to inflict happiness upon autotools + * tests/EntaggedTest.cs: New tests for M4A, and single/dual-tag mp3. + * tests/samples/sample.m4a: Added a tag. + * tests/samples/sample_v1_only.mp3, sample_v2_only.mp3, sample_both.mp3: + 3 mp3 test cases, with varying tag combinations. + * src/Mp3/Util/Id3v23TagReader.cs: Fixed reading of id3v2 comment. + * src/Makefile: Fixed building of m4a reader. + 2005-08-18 Aaron Bockover * configure.ac: Entagged 0.1.4