From 1b47fc4f6df050469eb2ec3748a996bc523efa7e Mon Sep 17 00:00:00 2001 From: gerow Date: Sat, 5 Jul 2014 18:38:28 -0400 Subject: [PATCH] cleaned up testing of UTF-16 on UnsynchTextFrames fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added a new COMM field to test.mp3 in UTF-16 with the Description: "✓" and text "✓". Opening and closing it two times without a panic should ensure that it is working. Also added a few lines to the open test to explicitly test to make sure that these UTF-16 fields are being read properly. --- id3_test.go | 25 +++++++++++++++++++++---- test.mp3 | Bin 83184 -> 83183 bytes utf16_comm.mp3 | Bin 2048 -> 0 bytes 3 files changed, 21 insertions(+), 4 deletions(-) delete mode 100644 utf16_comm.mp3 diff --git a/id3_test.go b/id3_test.go index b08a91a..2266794 100644 --- a/id3_test.go +++ b/id3_test.go @@ -13,8 +13,7 @@ import ( ) const ( - testFile = "test.mp3" - utf16File = "utf16_comm.mp3" + testFile = "test.mp3" ) func TestOpen(t *testing.T) { @@ -39,6 +38,24 @@ func TestOpen(t *testing.T) { if s := tag.Album(); s != "Chief Life" { t.Errorf("Open: incorrect album, %v", s) } + + parsedFrame := file.Frame("COMM") + resultFrame, ok := parsedFrame.(*v2.UnsynchTextFrame) + if !ok { + t.Error("Couldn't cast frame") + } + + expected := "✓" + actual := resultFrame.Description() + + if expected != actual { + t.Errorf("Expected %q, got %q", expected, actual) + } + + actual = resultFrame.Text() + if expected != actual { + t.Errorf("Expected %q, got %q", expected, actual) + } } func TestClose(t *testing.T) { @@ -124,7 +141,7 @@ func TestUnsynchTextFrame_RoundTrip(t *testing.T) { } func TestUTF16CommPanic(t *testing.T) { - osFile, err := os.Open(utf16File) + osFile, err := os.Open(testFile) if err != nil { t.Error(err) } @@ -135,7 +152,7 @@ func TestUTF16CommPanic(t *testing.T) { io.Copy(tempfile, osFile) osFile.Close() tempfile.Close() - for i := 0; i < 3; i++ { + for i := 0; i < 2; i++ { file, err := Open(tempfile.Name()) if err != nil { t.Error(err) diff --git a/test.mp3 b/test.mp3 index 42a1275f58d7b29b92807ab3b55c4d9f54124410..613f4badcba486c6662c35a8384cb32ef4bb6bcc 100644 GIT binary patch delta 95 zcmey+$@;#NmCMt`n3;irfu+85Vx-c>+5&DS28PLeJPDJldDKLl{e69bl3WZ7jH!9) t>cR{R>cSJbj3?SlfmFTaR^kru4+bg#nPAwwkZ1cs9!78DZ4QhdSO8U?7E}NL delta 80 zcmaFg$@-y_mCMt`n3;irfu+7|vIUPZ69dEKY#ynJTuMy;{%_PN;GW#hqcnLwcRW{s ie=txPNa^I?+?ve?dA1+qVYD-ze1S)C`+s}J4=ezwgcxf8 diff --git a/utf16_comm.mp3 b/utf16_comm.mp3 deleted file mode 100644 index d9c691831a8046fd7617546668c98775636f8622..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2048 zcmeH@%?`mp6h@C&T8Nc}O`o8lo`ANJifY41Sc+6asfE9{$44u%@Cb8fGxN>4b0;SX z`gK&zn@JZ#ZQ4+KJPC-H+0mP;lvS) zpG?(IJ)J5%2+wgyg%;#y70v`S%GsV~^yr&3>?!P&;rM5S!{|H2M8*@;Dxrzu_hqKP UWQuKB1J-~wU=3IU*1$glFEku0BLDyZ