mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2025-03-04 14:57:17 +00:00
AIFF: Add zero-sized text chunks test
This commit is contained in:
parent
8e9ab4b1ad
commit
f4ed05ed55
4 changed files with 21 additions and 1 deletions
|
@ -79,6 +79,10 @@ where
|
|||
// so there's no need to replace anything we already read
|
||||
#[cfg(feature = "aiff_text_chunks")]
|
||||
b"COMT" if comments.is_empty() => {
|
||||
if chunks.size < 2 {
|
||||
continue;
|
||||
}
|
||||
|
||||
let num_comments = data.read_u16::<BigEndian>()?;
|
||||
|
||||
for _ in 0..num_comments {
|
||||
|
|
|
@ -539,4 +539,21 @@ mod tests {
|
|||
);
|
||||
assert!(aiff_text.comments.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn zero_sized_text_chunks() {
|
||||
let tag_bytes =
|
||||
crate::tag::utils::test_utils::read_path("tests/tags/assets/zero.aiff_text");
|
||||
|
||||
let aiff_text = super::super::read::read_from(&mut Cursor::new(tag_bytes), false)
|
||||
.unwrap()
|
||||
.text_chunks
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(aiff_text.name, Some(String::new()));
|
||||
assert_eq!(aiff_text.author, Some(String::new()));
|
||||
assert_eq!(aiff_text.annotations, Some(vec![String::new()]));
|
||||
assert_eq!(aiff_text.comments, None); // Comments have additional information we need, so we ignore on empty
|
||||
assert_eq!(aiff_text.copyright, Some(String::new()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ use lofty::AudioFile;
|
|||
// TODO: zero-size vorbis comments
|
||||
// TODO: zero-size APE tag
|
||||
// TODO: zero-size ilst
|
||||
// TODO: zero-size AIFF text chunks
|
||||
|
||||
fn read_file<A: AudioFile>(path: &str) -> bool {
|
||||
let res = <A as AudioFile>::read_from(&mut std::fs::File::open(path).unwrap(), true);
|
||||
|
|
BIN
tests/tags/assets/zero.aiff_text
Normal file
BIN
tests/tags/assets/zero.aiff_text
Normal file
Binary file not shown.
Loading…
Add table
Reference in a new issue