Vorbis Comments: Add zero-sized test

This commit is contained in:
Serial 2022-07-11 17:04:40 -04:00
parent 2f62ff9b60
commit d298199a07
No known key found for this signature in database
GPG key ID: DA95198DC17C4568
3 changed files with 11 additions and 9 deletions

View file

@ -549,8 +549,6 @@ mod tests {
use crate::ogg::VorbisComments;
use crate::{Tag, TagExt, TagType};
use std::io::Read;
fn read_tag(tag: &[u8]) -> VorbisComments {
let mut reader = std::io::Cursor::new(tag);
let mut parsed_tag = VorbisComments::default();
@ -597,11 +595,7 @@ mod tests {
#[test]
fn vorbis_comments_to_tag() {
let mut tag_bytes = Vec::new();
std::fs::File::open("tests/tags/assets/test.vorbis")
.unwrap()
.read_to_end(&mut tag_bytes)
.unwrap();
let tag_bytes = std::fs::read("tests/tags/assets/test.vorbis").unwrap();
let mut reader = std::io::Cursor::new(&tag_bytes[..]);
let mut vorbis_comments = VorbisComments::default();
@ -626,4 +620,14 @@ mod tests {
assert_eq!(vorbis_comments.get("TRACKNUMBER"), Some("1"));
assert_eq!(vorbis_comments.get("GENRE"), Some("Classical"));
}
#[test]
fn zero_sized_vorbis_comments() {
let tag_bytes = std::fs::read("tests/tags/assets/zero.vorbis").unwrap();
let mut reader = std::io::Cursor::new(&tag_bytes[..]);
let mut vorbis_comments = VorbisComments::default();
crate::ogg::read::read_comments(&mut reader, &mut vorbis_comments).unwrap();
}
}

View file

@ -5,8 +5,6 @@ use lofty::mp3::Mp3File;
use lofty::mp4::Mp4File;
use lofty::AudioFile;
// TODO: zero-size vorbis comments
fn read_file_with_properties<A: AudioFile>(path: &str) -> bool {
let res = <A as AudioFile>::read_from(&mut std::fs::File::open(path).unwrap(), true);
res.is_ok()

Binary file not shown.