Skip to content

Commit

Permalink
Tests: Update TagLib tests for latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Serial-ATA committed Oct 17, 2023
1 parent 1469366 commit 8a0804e
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 11 deletions.
6 changes: 3 additions & 3 deletions tests/taglib/test_flacpicture.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use lofty::{MimeType, Picture, PictureType};
use lofty::{MimeType, ParsingMode, Picture, PictureType};

const DATA: &[u8] = &[
0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x09, 0x69, 0x6D, 0x61, 0x67, 0x65, 0x2F, 0x70, 0x6E,
Expand All @@ -18,7 +18,7 @@ const DATA: &[u8] = &[

#[test]
fn test_parse() {
let (picture, info) = Picture::from_flac_bytes(DATA, false).unwrap();
let (picture, info) = Picture::from_flac_bytes(DATA, false, ParsingMode::Strict).unwrap();

assert_eq!(picture.pic_type(), PictureType::CoverFront);
assert_eq!(info.width, 1);
Expand All @@ -32,6 +32,6 @@ fn test_parse() {

#[test]
fn test_pass_through() {
let (picture, info) = Picture::from_flac_bytes(DATA, false).unwrap();
let (picture, info) = Picture::from_flac_bytes(DATA, false, ParsingMode::Strict).unwrap();
assert_eq!(DATA, picture.as_flac_bytes(info, false).as_slice());
}
31 changes: 26 additions & 5 deletions tests/taglib/test_id3v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,11 @@ fn test_popm_from_file() {
file.rewind().unwrap();
{
let bar = MpegFile::read_from(&mut file, ParseOptions::new()).unwrap();
let popm_frame = bar.id3v2().unwrap().get("POPM").unwrap();
let popm_frame = bar
.id3v2()
.unwrap()
.get(&FrameId::Valid(Cow::Borrowed("POPM")))
.unwrap();
let popularimeter = match popm_frame.content() {
FrameValue::Popularimeter(popm) => popm,
_ => unreachable!(),
Expand Down Expand Up @@ -738,7 +742,10 @@ fn test_itunes_24_frame_size() {
.unwrap()
.contains(&FrameId::Valid(Cow::from("TIT2"))));
assert_eq!(
f.id3v2().unwrap().get_text("TIT2").unwrap(),
f.id3v2()
.unwrap()
.get_text(&FrameId::Valid(Cow::Borrowed("TIT2")))
.unwrap(),
"Sunshine Superman"
);
}
Expand Down Expand Up @@ -818,7 +825,13 @@ fn test_update_full_date22() {
let mut file = temp_file!("tests/taglib/data/id3v22-tda.mp3");
let f = MpegFile::read_from(&mut file, ParseOptions::new()).unwrap();
assert!(f.id3v2().is_some());
assert_eq!(f.id3v2().unwrap().get_text("TDRC").unwrap(), "2010-04-03");
assert_eq!(
f.id3v2()
.unwrap()
.get_text(&FrameId::Valid(Cow::Borrowed("TDRC")))
.unwrap(),
"2010-04-03"
);
}

#[test]
Expand All @@ -835,7 +848,11 @@ fn test_compressed_frame_with_broken_length() {
.unwrap()
.contains(&FrameId::Valid(Cow::from("APIC"))));

let frame = f.id3v2().unwrap().get("APIC").unwrap();
let frame = f
.id3v2()
.unwrap()
.get(&FrameId::Valid(Cow::Borrowed("APIC")))
.unwrap();
let picture = match frame.content() {
FrameValue::Picture(AttachedPictureFrame { picture, .. }) => picture,
_ => unreachable!(),
Expand All @@ -856,7 +873,11 @@ fn test_w000() {
.id3v2()
.unwrap()
.contains(&FrameId::Valid(Cow::from("W000"))));
let frame = f.id3v2().unwrap().get("W000").unwrap();
let frame = f
.id3v2()
.unwrap()
.get(&FrameId::Valid(Cow::Borrowed("W000")))
.unwrap();
let url_frame = match frame.content() {
FrameValue::Url(url_frame) => url_frame,
_ => unreachable!(),
Expand Down
4 changes: 2 additions & 2 deletions tests/taglib/test_wav.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::temp_file;
use crate::util::get_file;
use lofty::id3::v2::{Id3v2Tag, Id3v2Version};
use lofty::id3::v2::Id3v2Tag;
use lofty::iff::wav::{RIFFInfoList, WavFile, WavFormat};
use lofty::{Accessor, AudioFile, ParseOptions, TagType};
use std::io::{Cursor, Read, Seek, SeekFrom, Write};
use std::io::{Cursor, Read, Seek, SeekFrom};

#[test]
fn test_pcm_properties() {
Expand Down
4 changes: 3 additions & 1 deletion tests/taglib/test_wavpack.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::temp_file;
use crate::util::get_file;
use std::fs::File;

use std::io::Seek;

Expand Down Expand Up @@ -75,7 +76,8 @@ fn test_tagged_properties() {

#[test]
fn test_fuzzed_file() {
let _f = get_file::<WavPackFile>("tests/taglib/data/infloop.wv");
let mut f = File::open("tests/taglib/data/infloop.wv").unwrap();
assert!(WavPackFile::read_from(&mut f, ParseOptions::new()).is_err());
}

#[test]
Expand Down

0 comments on commit 8a0804e

Please sign in to comment.