kopia lustrzana https://github.com/jcs/id3-go
cleaned up testing of UTF-16 on UnsynchTextFrames fix
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.develop
rodzic
cc69456c06
commit
1b47fc4f6d
25
id3_test.go
25
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)
|
||||
|
|
BIN
test.mp3
BIN
test.mp3
Plik binarny nie jest wyświetlany.
BIN
utf16_comm.mp3
BIN
utf16_comm.mp3
Plik binarny nie jest wyświetlany.
Ładowanie…
Reference in New Issue