Skip to content

Commit

Permalink
chore: updates sequence tests for new PictureFrame sequencing behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
tillt authored and n10v committed Oct 13, 2021
1 parent be8e2d1 commit ca3c642
Showing 1 changed file with 37 additions and 14 deletions.
51 changes: 37 additions & 14 deletions sequence_test.go
Expand Up @@ -13,13 +13,18 @@ func TestSequenceCommentFramesUniqueness(t *testing.T) {
defer putSequence(s)

s.AddFrame(CommentFrame{Language: "A", Description: "A"})
testSequenceA(t, s)
testSequenceCount(t, s, 1)
testFrameUniqueIdentifier(t, s.Frames()[0], "AA")

s.AddFrame(CommentFrame{Language: "B", Description: "B"})
testSequenceAB(t, s)
testSequenceCount(t, s, 2)
testFrameUniqueIdentifier(t, s.Frames()[0], "AA")
testFrameUniqueIdentifier(t, s.Frames()[1], "BB")

s.AddFrame(CommentFrame{Language: "B", Description: "B"})
testSequenceAB(t, s)
testSequenceCount(t, s, 2)
testFrameUniqueIdentifier(t, s.Frames()[0], "AA")
testFrameUniqueIdentifier(t, s.Frames()[1], "BB")
}

func TestSequencePictureFramesUniqueness(t *testing.T) {
Expand All @@ -28,14 +33,27 @@ func TestSequencePictureFramesUniqueness(t *testing.T) {
s := getSequence()
defer putSequence(s)

s.AddFrame(PictureFrame{Description: "A"})
testSequenceA(t, s)

s.AddFrame(PictureFrame{Description: "B"})
testSequenceAB(t, s)
s.AddFrame(PictureFrame{Description: "A", PictureType: 0x00})
testSequenceCount(t, s, 1)
testFrameUniqueIdentifier(t, s.Frames()[0], "00A")

s.AddFrame(PictureFrame{Description: "B"})
testSequenceAB(t, s)
// Test against https://github.com/bogem/id3v2/issues/65 regression.
s.AddFrame(PictureFrame{Description: "A", PictureType: 0x01})
testSequenceCount(t, s, 2)
testFrameUniqueIdentifier(t, s.Frames()[0], "00A")
testFrameUniqueIdentifier(t, s.Frames()[1], "01A")

s.AddFrame(PictureFrame{Description: "B", PictureType: 0x00})
testSequenceCount(t, s, 3)
testFrameUniqueIdentifier(t, s.Frames()[0], "00A")
testFrameUniqueIdentifier(t, s.Frames()[1], "01A")
testFrameUniqueIdentifier(t, s.Frames()[2], "00B")

s.AddFrame(PictureFrame{Description: "B", PictureType: 0x00})
testSequenceCount(t, s, 3)
testFrameUniqueIdentifier(t, s.Frames()[0], "00A")
testFrameUniqueIdentifier(t, s.Frames()[1], "01A")
testFrameUniqueIdentifier(t, s.Frames()[2], "00B")
}

func TestSequenceUSLFsUniqueness(t *testing.T) {
Expand All @@ -45,13 +63,18 @@ func TestSequenceUSLFsUniqueness(t *testing.T) {
defer putSequence(s)

s.AddFrame(UnsynchronisedLyricsFrame{Language: "A", ContentDescriptor: "A"})
testSequenceA(t, s)
testSequenceCount(t, s, 1)
testFrameUniqueIdentifier(t, s.Frames()[0], "AA")

s.AddFrame(UnsynchronisedLyricsFrame{Language: "B", ContentDescriptor: "B"})
testSequenceAB(t, s)
testSequenceCount(t, s, 2)
testFrameUniqueIdentifier(t, s.Frames()[0], "AA")
testFrameUniqueIdentifier(t, s.Frames()[1], "BB")

s.AddFrame(UnsynchronisedLyricsFrame{Language: "B", ContentDescriptor: "B"})
testSequenceAB(t, s)
testSequenceCount(t, s, 2)
testFrameUniqueIdentifier(t, s.Frames()[0], "AA")
testFrameUniqueIdentifier(t, s.Frames()[1], "BB")
}

func TestSequenceUDTFsUniqueness(t *testing.T) {
Expand Down Expand Up @@ -96,7 +119,7 @@ func testSequenceCount(t *testing.T, s *sequence, expected int) {
}

func testFrameUniqueIdentifier(t *testing.T, f Framer, expected string) {
got := f.UniqueIdentifier()[:1]
got := f.UniqueIdentifier()
if got != expected {
t.Errorf("Expected frame with unique identifier %v, got %v", expected, got)
}
Expand Down

0 comments on commit ca3c642

Please sign in to comment.