Add ID3v2 multi-value tests

Add tests for ID3v2 multi-value text frames.
parent 4510210a
...@@ -69,6 +69,21 @@ public final class Id3DecoderTest { ...@@ -69,6 +69,21 @@ public final class Id3DecoderTest {
assertThat(textInformationFrame.description).isEqualTo("Hello World"); assertThat(textInformationFrame.description).isEqualTo("Hello World");
assertThat(textInformationFrame.values).isEmpty(); assertThat(textInformationFrame.values).isEmpty();
// Test multiple values.
rawId3 = buildSingleFrameTag(
"TXXX",
new byte[] {
1, 0, 72, 0, 101, 0, 108, 0, 108, 0, 111, 0, 32, 0, 87, 0, 111, 0, 114, 0, 108, 0,
100, 0, 0, 0, 70, 0, 111, 0, 111, 0, 0, 0, 66, 0, 97, 0, 114, 0, 0
});
metadata = decoder.decode(rawId3, rawId3.length);
assertThat(metadata.length()).isEqualTo(1);
textInformationFrame = (TextInformationFrame) metadata.get(0);
assertThat(textInformationFrame.description).isEqualTo("Hello World");
assertThat(textInformationFrame.values.length).isEqualTo(2);
assertThat(textInformationFrame.values[0]).isEqualTo("Foo");
assertThat(textInformationFrame.values[1]).isEqualTo("Bar");
// Test empty. // Test empty.
rawId3 = buildSingleFrameTag("TXXX", new byte[0]); rawId3 = buildSingleFrameTag("TXXX", new byte[0]);
metadata = decoder.decode(rawId3, rawId3.length); metadata = decoder.decode(rawId3, rawId3.length);
...@@ -98,6 +113,15 @@ public final class Id3DecoderTest { ...@@ -98,6 +113,15 @@ public final class Id3DecoderTest {
assertThat(textInformationFrame.values.length).isEqualTo(1); assertThat(textInformationFrame.values.length).isEqualTo(1);
assertThat(textInformationFrame.values[0]).isEqualTo("Hello World"); assertThat(textInformationFrame.values[0]).isEqualTo("Hello World");
// Test multiple values.
rawId3 = buildSingleFrameTag("TIT2", new byte[] {3, 70, 111, 111, 0, 66, 97, 114, 0});
metadata = decoder.decode(rawId3, rawId3.length);
assertThat(metadata.length()).isEqualTo(1);
textInformationFrame = (TextInformationFrame) metadata.get(0);
assertThat(textInformationFrame.values.length).isEqualTo(2);
assertThat(textInformationFrame.values[0]).isEqualTo("Foo");
assertThat(textInformationFrame.values[1]).isEqualTo("Bar");
// Test empty. // Test empty.
rawId3 = buildSingleFrameTag("TIT2", new byte[0]); rawId3 = buildSingleFrameTag("TIT2", new byte[0]);
metadata = decoder.decode(rawId3, rawId3.length); metadata = decoder.decode(rawId3, rawId3.length);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment