diff --git a/src/logic/mp4/properties.rs b/src/logic/mp4/properties.rs index 0a51d509..f589fc87 100644 --- a/src/logic/mp4/properties.rs +++ b/src/logic/mp4/properties.rs @@ -14,7 +14,6 @@ pub(crate) fn read_properties(data: &mut R, traks: &[Trak]) -> Result { -// assert_eq!($tag.title(), Some("Title Updated")); -// assert_eq!($tag.artist(), Some("Artist Updated")); -// assert_eq!($tag.track_number(), Some(5)); -// }; -// } -// -// #[test] -// fn test_conversions() { -// let mut tag = Tag::new().read_from_path("tests/assets/a.mp3").unwrap(); -// -// tag.set_title("Title Updated"); -// tag.set_artist("Artist Updated"); -// tag.set_track_number(5); -// convert_tag!(tag); -// -// let tag = tag.to_dyn_tag(TagType::Ape); -// convert_tag!(tag); -// -// let tag = tag.to_dyn_tag(TagType::Mp4); -// convert_tag!(tag); -// -// let tag = tag.to_dyn_tag(TagType::RiffInfo); -// convert_tag!(tag); -// -// let tag = tag.to_dyn_tag(TagType::Ogg(OggFormat::Vorbis)); -// convert_tag!(tag); -// -// let tag = tag.to_dyn_tag(TagType::Id3v2(Id3Format::Aiff)); -// convert_tag!(tag); -// } diff --git a/tests/inner.rs b/tests/inner.rs deleted file mode 100644 index bf82b190..00000000 --- a/tests/inner.rs +++ /dev/null @@ -1,57 +0,0 @@ -// #![cfg(feature = "default")] -// -// use lofty::{AudioTagEdit, Id3Format, OggFormat, OggTag, Tag, TagType, ToAnyTag}; -// -// use std::io::Cursor; -// -// #[test] -// fn test_inner() { -// // Create a new flac OggTag -// let mut flac_data = Cursor::new(std::fs::read("tests/assets/a.flac").unwrap()); -// let mut flac_tag = OggTag::read_from(&mut flac_data, &OggFormat::Flac).unwrap(); -// -// // Set the title of the flac tag -// flac_tag.set_title("Foo title"); -// -// // Turn the VorbisTag into an Id3v2Tag -// let id3tag = flac_tag.to_dyn_tag(TagType::Id3v2(Id3Format::Mp3)); -// -// // Write the Id3v2Tag to `a.mp3` -// id3tag -// .write_to_path("tests/assets/a.mp3") -// .expect("Fail to write!"); -// -// // Read from `a.mp3` -// let id3tag_reload = Tag::new() -// .read_from_path("tests/assets/a.mp3") -// .expect("Fail to read!"); -// -// // Confirm title still matches -// assert_eq!(id3tag_reload.title(), Some("Foo title")); -// -// // Convert Id3v2Tag to id3::Tag -// let mut id3tag_inner: id3::Tag = id3tag_reload.into(); -// -// // Create timestamp and change date_recorded -// let timestamp = id3::Timestamp { -// year: 2013, -// month: Some(2_u8), -// day: Some(5_u8), -// hour: Some(6_u8), -// minute: None, -// second: None, -// }; -// -// id3tag_inner.set_date_recorded(timestamp); -// -// // Write id3::Tag to `a.mp3` -// id3tag_inner -// .write_to_path("tests/assets/a.mp3", id3::Version::Id3v24) -// .expect("Fail to write!"); -// -// // Read from `a.mp3` -// let id3tag_reload = id3::Tag::read_from_path("tests/assets/a.mp3").expect("Fail to read!"); -// -// // Confirm timestamp still matches -// assert_eq!(id3tag_reload.date_recorded(), Some(timestamp)); -// } diff --git a/tests/io.rs b/tests/io.rs deleted file mode 100644 index c5a20f43..00000000 --- a/tests/io.rs +++ /dev/null @@ -1,409 +0,0 @@ -// #![cfg(feature = "default")] -// -// use lofty::{MimeType, Picture, PictureType, Tag}; -// -// use std::borrow::Cow; -// -// macro_rules! full_test { -// ($function:ident, $file:expr) => { -// #[test] -// #[allow(clippy::shadow_same)] -// fn $function() { -// println!("-- Adding tags --"); -// add_tags!($file); -// println!("-- Verifying tags --"); -// verify_write!($file); -// println!("-- Emptying tag --"); -// empty_tag!($file); -// println!("-- Removing tag --"); -// remove_tag!($file); -// } -// }; -// } -// -// macro_rules! add_tags { -// ($file:expr) => { -// println!("Reading file"); -// let mut tag = Tag::default().read_from_path_signature($file).unwrap(); -// -// let file = stringify!($file); -// -// println!("Setting title"); -// tag.set_title("foo title"); -// -// println!("Setting artist"); -// tag.set_artist("foo artist"); -// -// println!("Setting year"); -// tag.set_year(2020); -// -// println!("Setting date"); -// tag.set_date("20200415"); -// -// println!("Setting copyright"); -// tag.set_copyright("1988"); -// -// println!("Setting genre"); -// tag.set_genre("Country"); -// -// if file != stringify!("tests/assets/a.mp3") -// && file != stringify!("tests/assets/a.aiff") -// && file != stringify!("tests/assets/a-id3.wav") -// { -// println!("Setting Lyrics"); -// tag.set_lyrics("foo bar baz"); -// } -// -// println!("Setting BPM"); -// tag.set_bpm(50); -// -// println!("Setting lyricist"); -// tag.set_lyricist("Serial-ATA"); -// -// println!("Setting composer"); -// tag.set_composer("Serial-ATA1"); -// -// println!("Setting encoder"); -// tag.set_encoder("Lofty"); -// -// println!("Setting album title"); -// tag.set_album_title("foo album title"); -// -// println!("Setting album artists"); -// tag.set_album_artist("foo album artist"); -// -// let mut picture_data = vec![0x89, b'P', b'N', b'G']; -// let mut filler_data = vec![0; 50000]; -// -// picture_data.append(&mut filler_data); -// -// let covers = ( -// Picture { -// pic_type: PictureType::CoverFront, -// mime_type: MimeType::Png, -// description: Some(Cow::from("test")), -// width: 0, -// height: 0, -// color_depth: 0, -// num_colors: 0, -// data: Cow::from(picture_data.clone()), -// }, -// Picture { -// pic_type: PictureType::CoverBack, -// mime_type: MimeType::Png, -// description: Some(Cow::from("test")), -// width: 0, -// height: 0, -// color_depth: 0, -// num_colors: 0, -// data: Cow::from(picture_data.clone()), -// }, -// ); -// -// // Skip this since RIFF INFO doesn't store images, and MP4 doesn't specify what pictures are -// if file != stringify!("tests/assets/a.wav") && file != stringify!("tests/assets/a.m4a") { -// println!("Setting front cover"); -// tag.set_front_cover(covers.0.clone()); -// assert_eq!(tag.front_cover(), Some(covers.0)); -// -// println!("Setting back cover"); -// tag.set_back_cover(covers.1.clone()); -// assert_eq!(tag.back_cover(), Some(covers.1)); -// } -// -// // All MP4 Pictures are PictureType::Other -// if file == stringify!("tests/assets/a.m4a") { -// let cover = Picture { -// pic_type: PictureType::Other, -// mime_type: MimeType::Png, -// description: None, -// width: 0, -// height: 0, -// color_depth: 0, -// num_colors: 0, -// data: Cow::from(picture_data), -// }; -// -// println!("Setting cover"); -// tag.set_front_cover(cover.clone()); -// assert_eq!(tag.front_cover(), Some(cover)); -// } -// -// println!("Writing"); -// tag.write_to_path($file).unwrap(); -// }; -// } -// -// macro_rules! verify_write { -// ($file:expr) => { -// println!("Reading file"); -// let tag = Tag::default().read_from_path_signature($file).unwrap(); -// -// let file_name = stringify!($file); -// -// println!("Verifying title"); -// assert_eq!(tag.title(), Some("foo title")); -// -// println!("Verifying artist"); -// assert_eq!(tag.artist(), Some("foo artist")); -// -// // Skip this since RIFF INFO doesn't support year -// if file_name != stringify!("tests/assets/a.wav") { -// println!("Verifying year"); -// assert_eq!(tag.year(), Some(2020)); -// } -// -// if file_name != stringify!("tests/assets/a.m4a") { -// println!("Verifying date"); -// assert_eq!(tag.date(), Some("20200415".to_string())); -// -// if file_name != stringify!("tests/assets/a.wav") { -// println!("Verifying lyricist"); -// assert_eq!(tag.lyricist(), Some("Serial-ATA")); -// -// println!("Verifying composer"); -// assert_eq!(tag.composer(), Some("Serial-ATA1")); -// } -// } -// -// println!("Verifying copyright"); -// assert_eq!(tag.copyright(), Some("1988")); -// -// println!("Verifying genre"); -// assert_eq!(tag.genre(), Some("Country")); -// -// println!("Verifying encoder"); -// assert_eq!(tag.encoder(), Some("Lofty")); -// -// println!("Verifying album title"); -// assert_eq!(tag.album_title(), Some("foo album title")); -// -// let mut picture_data = vec![0x89, b'P', b'N', b'G']; -// let mut filler_data = vec![0; 50000]; -// -// picture_data.append(&mut filler_data); -// -// // Skip this since RIFF INFO doesn't store images -// if file_name != stringify!("tests/assets/a.wav") { -// let covers = if file_name == stringify!("tests/assets/a.m4a") { -// ( -// Picture { -// pic_type: PictureType::Other, -// mime_type: MimeType::Png, -// description: None, -// width: 0, -// height: 0, -// color_depth: 0, -// num_colors: 0, -// data: Cow::from(picture_data.clone()), -// }, -// Picture { -// pic_type: PictureType::Other, -// mime_type: MimeType::Png, -// description: None, -// width: 0, -// height: 0, -// color_depth: 0, -// num_colors: 0, -// data: Cow::from(picture_data), -// }, -// ) -// } else { -// ( -// Picture { -// pic_type: PictureType::CoverFront, -// mime_type: MimeType::Png, -// description: Some(Cow::from("test")), -// width: 0, -// height: 0, -// color_depth: 0, -// num_colors: 0, -// data: Cow::from(picture_data.clone()), -// }, -// Picture { -// pic_type: PictureType::CoverBack, -// mime_type: MimeType::Png, -// description: Some(Cow::from("test")), -// width: 0, -// height: 0, -// color_depth: 0, -// num_colors: 0, -// data: Cow::from(picture_data), -// }, -// ) -// }; -// -// if file_name != stringify!("tests/assets/a.mp3") -// && file_name != stringify!("tests/assets/a.aiff") -// && file_name != stringify!("tests/assets/a-id3.wav") -// { -// println!("Verifying lyrics"); -// assert_eq!(tag.lyrics(), Some("foo bar baz")); -// } -// -// println!("Verifying BPM"); -// assert_eq!(tag.bpm(), Some(50)); -// -// println!("Verifying album artist"); -// assert_eq!(tag.album_artist(), Some("foo album artist")); -// -// println!("Verifying album covers"); -// -// println!("Verifying front cover"); -// assert_eq!(tag.front_cover(), Some(covers.0)); -// -// println!("Verifying back cover"); -// assert_eq!(tag.back_cover(), Some(covers.1)); -// } -// }; -// } -// -// macro_rules! empty_tag { -// ($file:expr) => { -// println!("Reading file"); -// let mut tag = Tag::default().read_from_path_signature($file).unwrap(); -// -// println!("Removing title"); -// tag.remove_title(); -// assert!(tag.title().is_none()); -// tag.remove_title(); // should not panic -// -// println!("Removing artist"); -// tag.remove_artist(); -// assert!(tag.artist().is_none()); -// tag.remove_artist(); -// -// println!("Removing year"); -// tag.remove_year(); -// assert!(tag.year().is_none()); -// tag.remove_year(); -// -// println!("Removing date"); -// tag.remove_date(); -// assert!(tag.date().is_none()); -// tag.remove_date(); -// -// println!("Removing copyright"); -// tag.remove_copyright(); -// assert!(tag.copyright().is_none()); -// tag.remove_copyright(); -// -// println!("Removing genre"); -// tag.remove_genre(); -// assert!(tag.genre().is_none()); -// tag.remove_genre(); -// -// println!("Removing lyricist"); -// tag.remove_lyricist(); -// assert!(tag.lyricist().is_none()); -// tag.remove_lyricist(); -// -// println!("Removing composer"); -// tag.remove_composer(); -// assert!(tag.composer().is_none()); -// tag.remove_composer(); -// -// println!("Removing lyrics"); -// tag.remove_lyrics(); -// assert!(tag.lyrics().is_none()); -// tag.remove_lyrics(); -// -// println!("Removing BPM"); -// tag.remove_bpm(); -// assert!(tag.bpm().is_none()); -// tag.remove_bpm(); -// -// println!("Removing encoder"); -// tag.remove_encoder(); -// assert!(tag.encoder().is_none()); -// tag.remove_encoder(); -// -// println!("Removing album title"); -// tag.remove_album_title(); -// assert!(tag.album_title().is_none()); -// tag.remove_album_title(); -// -// println!("Removing album artists"); -// tag.remove_album_artist(); -// assert!(tag.album_artist().is_none()); -// tag.remove_album_artist(); -// -// println!("Removing album covers"); -// tag.remove_album_covers(); -// assert_eq!(tag.album_covers(), (None, None)); -// tag.remove_album_covers(); -// -// println!("Writing"); -// tag.write_to_path($file).unwrap(); -// }; -// } -// -// macro_rules! remove_tag { -// ($file:expr) => { -// Tag::new().remove_from_path($file).unwrap(); -// }; -// } -// -// // APEv2 -// full_test!(test_ape, "tests/assets/a.ape"); -// -// // ID3v2 -// full_test!(test_mp3, "tests/assets/a.mp3"); -// full_test!(test_aiff, "tests/assets/a.aiff"); -// full_test!(test_wav_id3, "tests/assets/a-id3.wav"); -// -// // RIFF INFO -// full_test!(test_wav_riff_info, "tests/assets/a.wav"); -// -// // Vorbis comments -// full_test!(test_flac, "tests/assets/a.flac"); -// full_test!(test_m4a, "tests/assets/a.m4a"); -// full_test!(test_ogg, "tests/assets/a.ogg"); -// full_test!(test_opus, "tests/assets/a.opus"); -// -// // AIFF text chunks only provide 2 values -// #[test] -// fn test_aiff_text() { -// let file = "tests/assets/a_text.aiff"; -// println!("-- Adding tags --"); -// -// println!("Reading file"); -// let mut tag = Tag::default().read_from_path_signature(file).unwrap(); -// -// println!("Setting title"); -// tag.set_title("foo title"); -// println!("Setting artist"); -// tag.set_artist("foo artist"); -// println!("Setting copyright"); -// tag.set_copyright("1988"); -// -// println!("Writing"); -// tag.write_to_path(file).unwrap(); -// -// println!("-- Verifying tags --"); -// -// println!("Reading file"); -// let mut tag = Tag::default().read_from_path_signature(file).unwrap(); -// -// println!("Verifying title"); -// assert_eq!(tag.title(), Some("foo title")); -// println!("Verifying artist"); -// assert_eq!(tag.artist(), Some("foo artist")); -// println!("Verifying copyright"); -// assert_eq!(tag.copyright(), Some("1988")); -// -// println!("-- Removing tags --"); -// -// println!("Removing title"); -// tag.remove_title(); -// -// // Keep artist around so there's something to read -// // println!("Removing artist"); -// // tag.remove_artist(); -// -// println!("Removing copyright"); -// tag.remove_copyright(); -// -// println!("Writing"); -// tag.write_to_path(file).unwrap() -// } diff --git a/tests/properties.rs b/tests/properties.rs deleted file mode 100644 index b16510f3..00000000 --- a/tests/properties.rs +++ /dev/null @@ -1,69 +0,0 @@ -// use lofty::{FileProperties, Tag}; -// -// use std::time::Duration; -// -// const OPUS_PROPERTIES: FileProperties = -// FileProperties::new(Duration::from_millis(1428), Some(120), Some(48000), Some(2)); -// -// const VORBIS_PROPERTIES: FileProperties = -// FileProperties::new(Duration::from_millis(1450), Some(112), Some(48000), Some(2)); -// -// const FLAC_PROPERTIES: FileProperties = FileProperties::new( -// Duration::from_millis(1428), -// Some(35084), -// Some(48000), -// Some(2), -// ); -// -// const AIFF_PROPERTIES: FileProperties = FileProperties::new( -// Duration::from_millis(1428), -// Some(1536), -// Some(48000), -// Some(2), -// ); -// -// const RIFF_PROPERTIES: FileProperties = FileProperties::new( -// Duration::from_millis(1428), -// Some(1536), -// Some(48000), -// Some(2), -// ); -// -// const MP3_PROPERTIES: FileProperties = -// FileProperties::new(Duration::from_millis(1464), Some(63), Some(48000), Some(2)); -// -// const MP4_PROPERTIES: FileProperties = -// FileProperties::new(Duration::from_millis(1450), Some(129), Some(48000), Some(2)); -// -// const APE_PROPERTIES: FileProperties = -// FileProperties::new(Duration::from_millis(1428), Some(360), Some(48000), Some(2)); -// -// macro_rules! properties_test { -// ($function:ident, $path:expr, $expected:ident) => { -// #[test] -// fn $function() { -// let tag = Tag::new().read_from_path_signature($path).unwrap(); -// let read_properties = tag.properties(); -// -// assert_eq!(read_properties.duration(), $expected.duration()); -// assert_eq!(read_properties.sample_rate(), $expected.sample_rate()); -// assert_eq!(read_properties.channels(), $expected.channels()); -// } -// }; -// } -// -// properties_test!(test_aiff_id3, "tests/assets/a.aiff", AIFF_PROPERTIES); -// properties_test!(test_aiff_text, "tests/assets/a_text.aiff", AIFF_PROPERTIES); -// -// properties_test!(test_opus, "tests/assets/a.opus", OPUS_PROPERTIES); -// properties_test!(test_vorbis, "tests/assets/a.ogg", VORBIS_PROPERTIES); -// properties_test!(test_flac, "tests/assets/a.flac", FLAC_PROPERTIES); -// -// properties_test!(test_wav_id3, "tests/assets/a-id3.wav", RIFF_PROPERTIES); -// properties_test!(test_wav_info, "tests/assets/a.wav", RIFF_PROPERTIES); -// -// properties_test!(test_mp3, "tests/assets/a.mp3", MP3_PROPERTIES); -// -// properties_test!(test_mp4, "tests/assets/a.m4a", MP4_PROPERTIES); -// -// properties_test!(test_ape, "tests/assets/a.ape", APE_PROPERTIES);