From 683d4aa4332c4f340fccc2014a88eaa5bd0ca3c3 Mon Sep 17 00:00:00 2001 From: Serial <69764315+Serial-ATA@users.noreply.github.com> Date: Sun, 14 Apr 2024 13:33:28 -0400 Subject: [PATCH] Tests: Update TagLib tests for new module structure --- tests/taglib/test_aiff.rs | 9 ++++++--- tests/taglib/test_ape.rs | 5 ++++- tests/taglib/test_apetag.rs | 4 +++- tests/taglib/test_fileref.rs | 14 +++++++------- tests/taglib/test_flac.rs | 8 ++++---- tests/taglib/test_flacpicture.rs | 3 ++- tests/taglib/test_id3v2.rs | 9 +++++---- tests/taglib/test_info.rs | 2 +- tests/taglib/test_mp4.rs | 8 ++++---- tests/taglib/test_mpc.rs | 5 ++++- tests/taglib/test_mpeg.rs | 4 +++- tests/taglib/test_ogaflac.rs | 4 +++- tests/taglib/test_ogg.rs | 4 +++- tests/taglib/test_opus.rs | 4 +++- tests/taglib/test_speex.rs | 7 ++++--- tests/taglib/test_wav.rs | 5 ++++- tests/taglib/test_wavpack.rs | 4 +++- tests/taglib/test_xiphcomment.rs | 8 ++++---- tests/taglib/util/mod.rs | 3 ++- 19 files changed, 69 insertions(+), 41 deletions(-) diff --git a/tests/taglib/test_aiff.rs b/tests/taglib/test_aiff.rs index d0854d25b..1a5df78c2 100644 --- a/tests/taglib/test_aiff.rs +++ b/tests/taglib/test_aiff.rs @@ -3,9 +3,12 @@ use crate::{assert_delta, temp_file}; use std::io::Seek; +use lofty::config::{ParseOptions, WriteOptions}; +use lofty::file::{AudioFile, FileType}; use lofty::id3::v2::Id3v2Tag; use lofty::iff::aiff::{AiffCompressionType, AiffFile}; -use lofty::{Accessor, AudioFile, FileType, ParseOptions, Probe, WriteOptions}; +use lofty::probe::Probe; +use lofty::tag::{Accessor, TagType}; #[test] fn test_aiff_properties() { @@ -66,7 +69,7 @@ fn test_save_id3v2() { tfile.set_id3v2(id3v2); file.rewind().unwrap(); tfile.save_to(&mut file, WriteOptions::default()).unwrap(); - assert!(tfile.contains_tag_type(lofty::TagType::Id3v2)); + assert!(tfile.contains_tag_type(TagType::Id3v2)); } file.rewind().unwrap(); @@ -88,7 +91,7 @@ fn test_save_id3v2() { { let tfile = AiffFile::read_from(&mut file, ParseOptions::new()).unwrap(); - assert!(!tfile.contains_tag_type(lofty::TagType::Id3v2)); + assert!(!tfile.contains_tag_type(TagType::Id3v2)); } } diff --git a/tests/taglib/test_ape.rs b/tests/taglib/test_ape.rs index dc2487333..8c167831a 100644 --- a/tests/taglib/test_ape.rs +++ b/tests/taglib/test_ape.rs @@ -5,8 +5,11 @@ use std::io::Seek; use std::time::Duration; use lofty::ape::{ApeFile, ApeItem, ApeTag}; +use lofty::config::{ParseOptions, WriteOptions}; +use lofty::file::{AudioFile, FileType}; use lofty::id3::v1::Id3v1Tag; -use lofty::{Accessor, AudioFile, FileType, ItemValue, ParseOptions, Probe, TagExt, WriteOptions}; +use lofty::probe::Probe; +use lofty::tag::{Accessor, ItemValue, TagExt}; fn test_399(path: &str) { let f = get_file::(path); diff --git a/tests/taglib/test_apetag.rs b/tests/taglib/test_apetag.rs index 077e838e6..981c100da 100644 --- a/tests/taglib/test_apetag.rs +++ b/tests/taglib/test_apetag.rs @@ -3,8 +3,10 @@ use crate::temp_file; use std::io::Seek; use lofty::ape::{ApeItem, ApeTag}; +use lofty::config::{ParseOptions, WriteOptions}; +use lofty::file::AudioFile; use lofty::musepack::MpcFile; -use lofty::{Accessor, AudioFile, ItemValue, ParseOptions, TagExt, WriteOptions}; +use lofty::tag::{Accessor, ItemValue, TagExt}; #[test] fn test_is_empty() { diff --git a/tests/taglib/test_fileref.rs b/tests/taglib/test_fileref.rs index d11db9b6b..722ce5f75 100644 --- a/tests/taglib/test_fileref.rs +++ b/tests/taglib/test_fileref.rs @@ -3,12 +3,11 @@ use crate::temp_file; use std::fs::File; use std::io::{Read, Seek}; +use lofty::config::{GlobalOptions, ParseOptions, WriteOptions}; use lofty::error::ErrorKind; +use lofty::file::{AudioFile, FileType, TaggedFile, TaggedFileExt}; use lofty::resolve::FileResolver; -use lofty::{ - Accessor, AudioFile, FileProperties, FileType, GlobalOptions, ParseOptions, Tag, TagExt, - TagType, TaggedFile, TaggedFileExt, WriteOptions, -}; +use lofty::tag::{Accessor, Tag, TagExt, TagType}; fn file_ref_save(path: &str, expected_file_type: FileType) { let path = format!("tests/taglib/data/{path}"); @@ -214,12 +213,13 @@ fn test_default_file_extensions() { // Marker test, Lofty does not replicate this API } +use lofty::properties::FileProperties; use rusty_fork::rusty_fork_test; rusty_fork_test! { #[test] fn test_file_resolver() { - lofty::apply_global_options(GlobalOptions::new().use_custom_resolvers(true)); + lofty::config::apply_global_options(GlobalOptions::new().use_custom_resolvers(true)); { let file = lofty::read_from_path("tests/taglib/data/xing.mp3").unwrap(); @@ -236,7 +236,7 @@ rusty_fork_test! { impl AudioFile for DummyResolver { type Properties = (); - fn read_from(_: &mut R, _: ParseOptions) -> lofty::Result + fn read_from(_: &mut R, _: ParseOptions) -> lofty::error::Result where R: Read + Seek, Self: Sized, @@ -244,7 +244,7 @@ rusty_fork_test! { Ok(Self) } - fn save_to(&self, _: &mut File, _: WriteOptions) -> lofty::Result<()> { + fn save_to(&self, _: &mut File, _: WriteOptions) -> lofty::error::Result<()> { unimplemented!() } diff --git a/tests/taglib/test_flac.rs b/tests/taglib/test_flac.rs index 8af0805cf..e21ead321 100644 --- a/tests/taglib/test_flac.rs +++ b/tests/taglib/test_flac.rs @@ -3,13 +3,13 @@ use crate::util::get_file; use std::io::{Read, Seek, SeekFrom}; +use lofty::config::{ParseOptions, WriteOptions}; +use lofty::file::AudioFile; use lofty::flac::FlacFile; use lofty::id3::v2::Id3v2Tag; use lofty::ogg::{OggPictureStorage, VorbisComments}; -use lofty::{ - Accessor, AudioFile, MimeType, ParseOptions, Picture, PictureInformation, PictureType, TagExt, - WriteOptions, -}; +use lofty::picture::{MimeType, Picture, PictureInformation, PictureType}; +use lofty::tag::{Accessor, TagExt}; #[test] fn test_signature() { diff --git a/tests/taglib/test_flacpicture.rs b/tests/taglib/test_flacpicture.rs index 2480a5446..981f55d42 100644 --- a/tests/taglib/test_flacpicture.rs +++ b/tests/taglib/test_flacpicture.rs @@ -1,4 +1,5 @@ -use lofty::{MimeType, ParsingMode, Picture, PictureType}; +use lofty::config::ParsingMode; +use lofty::picture::{MimeType, Picture, PictureType}; const DATA: &[u8] = &[ 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x09, 0x69, 0x6D, 0x61, 0x67, 0x65, 0x2F, 0x70, 0x6E, diff --git a/tests/taglib/test_id3v2.rs b/tests/taglib/test_id3v2.rs index ad2ea51c4..5b7dded9a 100644 --- a/tests/taglib/test_id3v2.rs +++ b/tests/taglib/test_id3v2.rs @@ -4,6 +4,8 @@ use std::borrow::Cow; use std::collections::HashMap; use std::io::Seek; +use lofty::config::{ParseOptions, ParsingMode, WriteOptions}; +use lofty::file::AudioFile; use lofty::id3::v2::{ AttachedPictureFrame, ChannelInformation, ChannelType, CommentFrame, Event, EventTimingCodesFrame, EventType, ExtendedTextFrame, ExtendedUrlFrame, Frame, FrameFlags, @@ -13,10 +15,9 @@ use lofty::id3::v2::{ UrlLinkFrame, }; use lofty::mpeg::MpegFile; -use lofty::{ - Accessor, AudioFile, MimeType, ParseOptions, ParsingMode, Picture, PictureType, TagExt, - TextEncoding, WriteOptions, -}; +use lofty::picture::{MimeType, Picture, PictureType}; +use lofty::tag::{Accessor, TagExt}; +use lofty::TextEncoding; #[test] fn test_unsynch_decode() { diff --git a/tests/taglib/test_info.rs b/tests/taglib/test_info.rs index f1bce457d..31231d75b 100644 --- a/tests/taglib/test_info.rs +++ b/tests/taglib/test_info.rs @@ -1,5 +1,5 @@ use lofty::iff::wav::RIFFInfoList; -use lofty::Accessor; +use lofty::tag::Accessor; #[test] fn test_title() { diff --git a/tests/taglib/test_mp4.rs b/tests/taglib/test_mp4.rs index adc844c68..714ace314 100644 --- a/tests/taglib/test_mp4.rs +++ b/tests/taglib/test_mp4.rs @@ -4,11 +4,11 @@ use crate::util::get_file; use std::borrow::Cow; use std::io::{Read, Seek}; +use lofty::config::{ParseOptions, WriteOptions}; +use lofty::file::AudioFile; use lofty::mp4::{Atom, AtomData, AtomIdent, Ilst, Mp4Codec, Mp4File}; -use lofty::{ - Accessor, AudioFile, MimeType, ParseOptions, Picture, PictureType, TagExt, TagType, - WriteOptions, -}; +use lofty::picture::{MimeType, Picture, PictureType}; +use lofty::tag::{Accessor, TagExt, TagType}; #[test] fn test_properties_aac() { diff --git a/tests/taglib/test_mpc.rs b/tests/taglib/test_mpc.rs index 145e5361e..32ba5889d 100644 --- a/tests/taglib/test_mpc.rs +++ b/tests/taglib/test_mpc.rs @@ -4,9 +4,12 @@ use crate::util::get_file; use std::io::Seek; use lofty::ape::ApeTag; +use lofty::config::{ParseOptions, WriteOptions}; +use lofty::file::AudioFile; use lofty::id3::v1::Id3v1Tag; use lofty::musepack::{MpcFile, MpcProperties}; -use lofty::{Accessor, AudioFile, ParseOptions, Probe, TagExt, WriteOptions}; +use lofty::probe::Probe; +use lofty::tag::{Accessor, TagExt}; #[test] fn test_properties_sv8() { diff --git a/tests/taglib/test_mpeg.rs b/tests/taglib/test_mpeg.rs index 23173ba13..56bf709b4 100644 --- a/tests/taglib/test_mpeg.rs +++ b/tests/taglib/test_mpeg.rs @@ -5,10 +5,12 @@ use std::fs::File; use std::io::Seek; use lofty::ape::ApeTag; +use lofty::config::{ParseOptions, WriteOptions}; +use lofty::file::AudioFile; use lofty::id3::v1::Id3v1Tag; use lofty::id3::v2::{Id3v2Tag, Id3v2Version}; use lofty::mpeg::MpegFile; -use lofty::{Accessor, AudioFile, ParseOptions, WriteOptions}; +use lofty::tag::Accessor; #[test] fn test_audio_properties_xing_header_cbr() { diff --git a/tests/taglib/test_ogaflac.rs b/tests/taglib/test_ogaflac.rs index ad7492066..6f55d36bc 100644 --- a/tests/taglib/test_ogaflac.rs +++ b/tests/taglib/test_ogaflac.rs @@ -2,9 +2,11 @@ use crate::temp_file; use std::io::{Seek, SeekFrom}; +use lofty::config::{ParseOptions, WriteOptions}; +use lofty::file::AudioFile; use lofty::flac::FlacFile; use lofty::ogg::VorbisComments; -use lofty::{Accessor, AudioFile, ParseOptions, WriteOptions}; +use lofty::tag::Accessor; // TODO: We don't support FLAC in OGA (#172) #[test] diff --git a/tests/taglib/test_ogg.rs b/tests/taglib/test_ogg.rs index 9111343e9..43e5376d8 100644 --- a/tests/taglib/test_ogg.rs +++ b/tests/taglib/test_ogg.rs @@ -4,8 +4,10 @@ use crate::util::get_file; use std::io::{Read, Seek, SeekFrom}; use byteorder::{LittleEndian, ReadBytesExt}; +use lofty::config::{ParseOptions, WriteOptions}; +use lofty::file::AudioFile; use lofty::ogg::VorbisFile; -use lofty::{Accessor, AudioFile, ParseOptions, WriteOptions}; +use lofty::tag::Accessor; #[test] fn test_simple() { diff --git a/tests/taglib/test_opus.rs b/tests/taglib/test_opus.rs index 71771ee81..6caac3ec5 100644 --- a/tests/taglib/test_opus.rs +++ b/tests/taglib/test_opus.rs @@ -3,8 +3,10 @@ use crate::util::get_file; use std::io::Seek; +use lofty::config::{ParseOptions, WriteOptions}; +use lofty::file::AudioFile; use lofty::ogg::OpusFile; -use lofty::{Accessor, AudioFile, ParseOptions, WriteOptions}; +use lofty::tag::Accessor; #[test] fn test_audio_properties() { diff --git a/tests/taglib/test_speex.rs b/tests/taglib/test_speex.rs index 1c914c43b..764a0a2b7 100644 --- a/tests/taglib/test_speex.rs +++ b/tests/taglib/test_speex.rs @@ -1,11 +1,12 @@ use crate::temp_file; use crate::util::get_file; +use lofty::config::{ParseOptions, WriteOptions}; +use lofty::file::AudioFile; +use lofty::ogg::{SpeexFile, VorbisComments}; +use lofty::tag::Accessor; use std::io::Seek; -use lofty::ogg::{SpeexFile, VorbisComments}; -use lofty::{Accessor, AudioFile, ParseOptions, WriteOptions}; - #[test] fn test_audio_properties() { let f = get_file::("tests/taglib/data/empty.spx"); diff --git a/tests/taglib/test_wav.rs b/tests/taglib/test_wav.rs index e909ae205..dec415a80 100644 --- a/tests/taglib/test_wav.rs +++ b/tests/taglib/test_wav.rs @@ -1,8 +1,11 @@ use crate::temp_file; use crate::util::get_file; +use lofty::config::{ParseOptions, WriteOptions}; +use lofty::file::AudioFile; use lofty::id3::v2::Id3v2Tag; use lofty::iff::wav::{RIFFInfoList, WavFile, WavFormat}; -use lofty::{Accessor, AudioFile, ParseOptions, TagType, WriteOptions}; +use lofty::tag::{Accessor, TagType}; + use std::io::{Cursor, Read, Seek, SeekFrom}; #[test] diff --git a/tests/taglib/test_wavpack.rs b/tests/taglib/test_wavpack.rs index b0288a77e..74d673ddd 100644 --- a/tests/taglib/test_wavpack.rs +++ b/tests/taglib/test_wavpack.rs @@ -5,9 +5,11 @@ use std::fs::File; use std::io::Seek; use lofty::ape::ApeTag; +use lofty::config::{ParseOptions, WriteOptions}; +use lofty::file::AudioFile; use lofty::id3::v1::Id3v1Tag; +use lofty::tag::Accessor; use lofty::wavpack::WavPackFile; -use lofty::{Accessor, AudioFile, ParseOptions, WriteOptions}; #[test] fn test_no_length_properties() { diff --git a/tests/taglib/test_xiphcomment.rs b/tests/taglib/test_xiphcomment.rs index af46839f7..9acb2ca94 100644 --- a/tests/taglib/test_xiphcomment.rs +++ b/tests/taglib/test_xiphcomment.rs @@ -2,11 +2,11 @@ use crate::temp_file; use std::io::Seek; +use lofty::config::{ParseOptions, WriteOptions}; +use lofty::file::AudioFile; use lofty::ogg::{OggPictureStorage, VorbisComments, VorbisFile}; -use lofty::{ - Accessor, AudioFile, MimeType, ParseOptions, Picture, PictureInformation, PictureType, TagExt, - WriteOptions, -}; +use lofty::picture::{MimeType, Picture, PictureInformation, PictureType}; +use lofty::tag::{Accessor, TagExt}; #[test] fn test_year() { diff --git a/tests/taglib/util/mod.rs b/tests/taglib/util/mod.rs index 81042ce47..78201d106 100644 --- a/tests/taglib/util/mod.rs +++ b/tests/taglib/util/mod.rs @@ -1,4 +1,5 @@ -use lofty::{AudioFile, ParseOptions}; +use lofty::config::ParseOptions; +use lofty::file::AudioFile; use std::fs::File; pub fn get_file(path: &str) -> F {