Skip to content

Commit

Permalink
improved tests for ID3v2Tag.setGenreDescription(String)
Browse files Browse the repository at this point in the history
  • Loading branch information
beckchr authored and mpatric committed Jul 9, 2013
1 parent 1908493 commit 3618b7c
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions src/test/java/com/mpatric/mp3agic/ID3v2TagTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,13 @@ public void testShouldSetCombinedGenreOnTag() throws Exception {
assertEquals("(13)Pop", genre);
}

public void testSetKnownGenreDescriptionOn23Tag() throws Exception {
public void testSetGenreDescriptionOn23Tag() throws Exception {
ID3v2 id3tag = new ID3v23Tag();
setTagFields(id3tag);
id3tag.setGenreDescription("Jazz");
assertEquals("Jazz", id3tag.getGenreDescription());
assertEquals(8, id3tag.getGenre());

Map<String, ID3v2FrameSet> frameSets = id3tag.getFrameSets();
ID3v2FrameSet frameSet = (ID3v2FrameSet) frameSets.get("TCON");
List<ID3v2Frame> frames = frameSet.getFrames();
Expand All @@ -209,7 +212,7 @@ public void testSetKnownGenreDescriptionOn23Tag() throws Exception {
assertEquals("(8)Jazz", genre);
}

public void testSetUnknownGenreDescriptionOn23Tag() throws Exception {
public void testSetGenreDescriptionOn23TagWithUnknownGenre() throws Exception {
ID3v2 id3tag = new ID3v23Tag();
setTagFields(id3tag);
try {
Expand All @@ -220,30 +223,20 @@ public void testSetUnknownGenreDescriptionOn23Tag() throws Exception {
fail("expected IllegalArgumentException");
}

public void testSetKnownGenreDescriptionOn24Tag() throws Exception {
public void testSetGenreDescriptionOn24Tag() throws Exception {
ID3v2 id3tag = new ID3v24Tag();
setTagFields(id3tag);
id3tag.setGenreDescription("Jazz");
Map<String, ID3v2FrameSet> frameSets = id3tag.getFrameSets();
ID3v2FrameSet frameSet = (ID3v2FrameSet) frameSets.get("TCON");
List<ID3v2Frame> frames = frameSet.getFrames();
ID3v2Frame frame = (ID3v2Frame) frames.get(0);
byte[] bytes = frame.getData();
String genre = BufferTools.byteBufferToString(bytes, 1, bytes.length - 1);
assertEquals("Jazz", genre);
}
assertEquals("Jazz", id3tag.getGenreDescription());
assertEquals(8, id3tag.getGenre());

public void testSetUnknownGenreDescriptionOn24Tag() throws Exception {
ID3v2 id3tag = new ID3v24Tag();
setTagFields(id3tag);
id3tag.setGenreDescription("Bebop");
Map<String, ID3v2FrameSet> frameSets = id3tag.getFrameSets();
ID3v2FrameSet frameSet = (ID3v2FrameSet) frameSets.get("TCON");
List<ID3v2Frame> frames = frameSet.getFrames();
ID3v2Frame frame = (ID3v2Frame) frames.get(0);
byte[] bytes = frame.getData();
String genre = BufferTools.byteBufferToString(bytes, 1, bytes.length - 1);
assertEquals("Bebop", genre);
assertEquals("Jazz", genre);
}

public void testShouldReadCombinedGenreInTag() throws Exception {
Expand Down

0 comments on commit 3618b7c

Please sign in to comment.