mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2024-12-13 06:02:32 +00:00
Vorbis Comments: Add zero-sized test
This commit is contained in:
parent
2f62ff9b60
commit
d298199a07
3 changed files with 11 additions and 9 deletions
|
@ -549,8 +549,6 @@ mod tests {
|
||||||
use crate::ogg::VorbisComments;
|
use crate::ogg::VorbisComments;
|
||||||
use crate::{Tag, TagExt, TagType};
|
use crate::{Tag, TagExt, TagType};
|
||||||
|
|
||||||
use std::io::Read;
|
|
||||||
|
|
||||||
fn read_tag(tag: &[u8]) -> VorbisComments {
|
fn read_tag(tag: &[u8]) -> VorbisComments {
|
||||||
let mut reader = std::io::Cursor::new(tag);
|
let mut reader = std::io::Cursor::new(tag);
|
||||||
let mut parsed_tag = VorbisComments::default();
|
let mut parsed_tag = VorbisComments::default();
|
||||||
|
@ -597,11 +595,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn vorbis_comments_to_tag() {
|
fn vorbis_comments_to_tag() {
|
||||||
let mut tag_bytes = Vec::new();
|
let tag_bytes = std::fs::read("tests/tags/assets/test.vorbis").unwrap();
|
||||||
std::fs::File::open("tests/tags/assets/test.vorbis")
|
|
||||||
.unwrap()
|
|
||||||
.read_to_end(&mut tag_bytes)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let mut reader = std::io::Cursor::new(&tag_bytes[..]);
|
let mut reader = std::io::Cursor::new(&tag_bytes[..]);
|
||||||
let mut vorbis_comments = VorbisComments::default();
|
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("TRACKNUMBER"), Some("1"));
|
||||||
assert_eq!(vorbis_comments.get("GENRE"), Some("Classical"));
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ use lofty::mp3::Mp3File;
|
||||||
use lofty::mp4::Mp4File;
|
use lofty::mp4::Mp4File;
|
||||||
use lofty::AudioFile;
|
use lofty::AudioFile;
|
||||||
|
|
||||||
// TODO: zero-size vorbis comments
|
|
||||||
|
|
||||||
fn read_file_with_properties<A: AudioFile>(path: &str) -> bool {
|
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);
|
let res = <A as AudioFile>::read_from(&mut std::fs::File::open(path).unwrap(), true);
|
||||||
res.is_ok()
|
res.is_ok()
|
||||||
|
|
BIN
tests/tags/assets/zero.vorbis
Normal file
BIN
tests/tags/assets/zero.vorbis
Normal file
Binary file not shown.
Loading…
Reference in a new issue