Skip to content

Commit dace0dc

Browse files
committed
Tests: Update TagLib tests for latest changes
1 parent db5e505 commit dace0dc

File tree

4 files changed

+34
-11
lines changed

4 files changed

+34
-11
lines changed

tests/taglib/test_flacpicture.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use lofty::{MimeType, Picture, PictureType};
1+
use lofty::{MimeType, ParsingMode, Picture, PictureType};
22

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

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

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

3333
#[test]
3434
fn test_pass_through() {
35-
let (picture, info) = Picture::from_flac_bytes(DATA, false).unwrap();
35+
let (picture, info) = Picture::from_flac_bytes(DATA, false, ParsingMode::Strict).unwrap();
3636
assert_eq!(DATA, picture.as_flac_bytes(info, false).as_slice());
3737
}

tests/taglib/test_id3v2.rs

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,11 @@ fn test_popm_from_file() {
258258
file.rewind().unwrap();
259259
{
260260
let bar = MpegFile::read_from(&mut file, ParseOptions::new()).unwrap();
261-
let popm_frame = bar.id3v2().unwrap().get("POPM").unwrap();
261+
let popm_frame = bar
262+
.id3v2()
263+
.unwrap()
264+
.get(&FrameId::Valid(Cow::Borrowed("POPM")))
265+
.unwrap();
262266
let popularimeter = match popm_frame.content() {
263267
FrameValue::Popularimeter(popm) => popm,
264268
_ => unreachable!(),
@@ -738,7 +742,10 @@ fn test_itunes_24_frame_size() {
738742
.unwrap()
739743
.contains(&FrameId::Valid(Cow::from("TIT2"))));
740744
assert_eq!(
741-
f.id3v2().unwrap().get_text("TIT2").unwrap(),
745+
f.id3v2()
746+
.unwrap()
747+
.get_text(&FrameId::Valid(Cow::Borrowed("TIT2")))
748+
.unwrap(),
742749
"Sunshine Superman"
743750
);
744751
}
@@ -818,7 +825,13 @@ fn test_update_full_date22() {
818825
let mut file = temp_file!("tests/taglib/data/id3v22-tda.mp3");
819826
let f = MpegFile::read_from(&mut file, ParseOptions::new()).unwrap();
820827
assert!(f.id3v2().is_some());
821-
assert_eq!(f.id3v2().unwrap().get_text("TDRC").unwrap(), "2010-04-03");
828+
assert_eq!(
829+
f.id3v2()
830+
.unwrap()
831+
.get_text(&FrameId::Valid(Cow::Borrowed("TDRC")))
832+
.unwrap(),
833+
"2010-04-03"
834+
);
822835
}
823836

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

838-
let frame = f.id3v2().unwrap().get("APIC").unwrap();
851+
let frame = f
852+
.id3v2()
853+
.unwrap()
854+
.get(&FrameId::Valid(Cow::Borrowed("APIC")))
855+
.unwrap();
839856
let picture = match frame.content() {
840857
FrameValue::Picture(AttachedPictureFrame { picture, .. }) => picture,
841858
_ => unreachable!(),
@@ -856,7 +873,11 @@ fn test_w000() {
856873
.id3v2()
857874
.unwrap()
858875
.contains(&FrameId::Valid(Cow::from("W000"))));
859-
let frame = f.id3v2().unwrap().get("W000").unwrap();
876+
let frame = f
877+
.id3v2()
878+
.unwrap()
879+
.get(&FrameId::Valid(Cow::Borrowed("W000")))
880+
.unwrap();
860881
let url_frame = match frame.content() {
861882
FrameValue::Url(url_frame) => url_frame,
862883
_ => unreachable!(),

tests/taglib/test_wav.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use crate::temp_file;
22
use crate::util::get_file;
3-
use lofty::id3::v2::{Id3v2Tag, Id3v2Version};
3+
use lofty::id3::v2::Id3v2Tag;
44
use lofty::iff::wav::{RIFFInfoList, WavFile, WavFormat};
55
use lofty::{Accessor, AudioFile, ParseOptions, TagType};
6-
use std::io::{Cursor, Read, Seek, SeekFrom, Write};
6+
use std::io::{Cursor, Read, Seek, SeekFrom};
77

88
#[test]
99
fn test_pcm_properties() {

tests/taglib/test_wavpack.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::temp_file;
22
use crate::util::get_file;
3+
use std::fs::File;
34

45
use std::io::Seek;
56

@@ -75,7 +76,8 @@ fn test_tagged_properties() {
7576

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

8183
#[test]

0 commit comments

Comments
 (0)