From 5b40a2f3a47cd522e8faed4df3e7fe37aa09793f Mon Sep 17 00:00:00 2001 From: Serial <69764315+Serial-ATA@users.noreply.github.com> Date: Sat, 4 May 2024 16:41:40 -0400 Subject: [PATCH] Tests: Fix Clippy lints --- lofty/src/id3/v2/items/audio_text_frame.rs | 2 +- lofty/src/id3/v2/items/encapsulated_object.rs | 2 +- lofty/src/id3/v2/items/popularimeter.rs | 6 +++--- lofty/src/id3/v2/items/private_frame.rs | 2 +- .../v2/items/relative_volume_adjustment_frame.rs | 2 +- lofty/src/id3/v2/items/sync_text.rs | 2 +- lofty/src/id3/v2/items/unique_file_identifier.rs | 2 +- lofty/src/id3/v2/tag/tests.rs | 2 +- lofty/tests/files/mpeg.rs | 5 ++--- lofty/tests/fuzz/main.rs | 2 ++ lofty/tests/hound.rs | 14 ++++++++++---- ogg_pager/src/lib.rs | 4 ++-- 12 files changed, 26 insertions(+), 19 deletions(-) diff --git a/lofty/src/id3/v2/items/audio_text_frame.rs b/lofty/src/id3/v2/items/audio_text_frame.rs index b6dab34e..c412f692 100644 --- a/lofty/src/id3/v2/items/audio_text_frame.rs +++ b/lofty/src/id3/v2/items/audio_text_frame.rs @@ -239,7 +239,7 @@ mod tests { fn expected() -> AudioTextFrame<'static> { AudioTextFrame { - header: super::FrameHeader::new(super::FRAME_ID, Default::default()), + header: super::FrameHeader::new(super::FRAME_ID, FrameFlags::default()), encoding: TextEncoding::Latin1, mime_type: String::from("audio/mpeg"), flags: AudioTextFrameFlags { scrambling: false }, diff --git a/lofty/src/id3/v2/items/encapsulated_object.rs b/lofty/src/id3/v2/items/encapsulated_object.rs index c6cf9383..94e4c6a3 100644 --- a/lofty/src/id3/v2/items/encapsulated_object.rs +++ b/lofty/src/id3/v2/items/encapsulated_object.rs @@ -133,7 +133,7 @@ mod tests { fn expected() -> GeneralEncapsulatedObject<'static> { GeneralEncapsulatedObject { - header: FrameHeader::new(super::FRAME_ID, Default::default()), + header: FrameHeader::new(super::FRAME_ID, FrameFlags::default()), encoding: TextEncoding::Latin1, mime_type: Some(String::from("audio/mpeg")), file_name: Some(String::from("a.mp3")), diff --git a/lofty/src/id3/v2/items/popularimeter.rs b/lofty/src/id3/v2/items/popularimeter.rs index b54118de..0ddbe9a7 100644 --- a/lofty/src/id3/v2/items/popularimeter.rs +++ b/lofty/src/id3/v2/items/popularimeter.rs @@ -139,7 +139,7 @@ impl<'a> PopularimeterFrame<'a> { #[cfg(test)] mod tests { use crate::id3::v2::items::popularimeter::PopularimeterFrame; - use crate::id3::v2::FrameHeader; + use crate::id3::v2::{FrameFlags, FrameHeader}; fn test_popm(popm: &PopularimeterFrame<'_>) { let email = popm.email.clone(); @@ -165,14 +165,14 @@ mod tests { #[test] fn write_popm() { let popm_u32_boundary = PopularimeterFrame { - header: FrameHeader::new(super::FRAME_ID, Default::default()), + header: FrameHeader::new(super::FRAME_ID, FrameFlags::default()), email: String::from("foo@bar.com"), rating: 255, counter: u64::from(u32::MAX), }; let popm_u40 = PopularimeterFrame { - header: FrameHeader::new(super::FRAME_ID, Default::default()), + header: FrameHeader::new(super::FRAME_ID, FrameFlags::default()), email: String::from("baz@qux.com"), rating: 196, counter: u64::from(u32::MAX) + 1, diff --git a/lofty/src/id3/v2/items/private_frame.rs b/lofty/src/id3/v2/items/private_frame.rs index ac70002e..2c0330ab 100644 --- a/lofty/src/id3/v2/items/private_frame.rs +++ b/lofty/src/id3/v2/items/private_frame.rs @@ -102,7 +102,7 @@ mod tests { fn expected() -> PrivateFrame<'static> { PrivateFrame { - header: FrameHeader::new(super::FRAME_ID, Default::default()), + header: FrameHeader::new(super::FRAME_ID, FrameFlags::default()), owner: String::from("foo@bar.com"), private_data: String::from("some data").into_bytes(), } diff --git a/lofty/src/id3/v2/items/relative_volume_adjustment_frame.rs b/lofty/src/id3/v2/items/relative_volume_adjustment_frame.rs index f89c72f3..7c44fc07 100644 --- a/lofty/src/id3/v2/items/relative_volume_adjustment_frame.rs +++ b/lofty/src/id3/v2/items/relative_volume_adjustment_frame.rs @@ -280,7 +280,7 @@ mod tests { ); RelativeVolumeAdjustmentFrame { - header: FrameHeader::new(super::FRAME_ID, Default::default()), + header: FrameHeader::new(super::FRAME_ID, FrameFlags::default()), identification: String::from("Surround sound"), channels, } diff --git a/lofty/src/id3/v2/items/sync_text.rs b/lofty/src/id3/v2/items/sync_text.rs index 5043c1e0..b3299caf 100644 --- a/lofty/src/id3/v2/items/sync_text.rs +++ b/lofty/src/id3/v2/items/sync_text.rs @@ -270,7 +270,7 @@ mod tests { fn expected(encoding: TextEncoding) -> SynchronizedTextFrame<'static> { SynchronizedTextFrame { - header: FrameHeader::new(super::FRAME_ID, Default::default()), + header: FrameHeader::new(super::FRAME_ID, FrameFlags::default()), encoding, language: *b"eng", timestamp_format: TimestampFormat::MS, diff --git a/lofty/src/id3/v2/items/unique_file_identifier.rs b/lofty/src/id3/v2/items/unique_file_identifier.rs index e6e7a908..db9fdf4d 100644 --- a/lofty/src/id3/v2/items/unique_file_identifier.rs +++ b/lofty/src/id3/v2/items/unique_file_identifier.rs @@ -127,7 +127,7 @@ mod tests { use crate::id3::v2::UniqueFileIdentifierFrame; let ufid_no_owner = UniqueFileIdentifierFrame { - header: FrameHeader::new(FrameId::Valid(Cow::Borrowed("UFID")), Default::default()), + header: FrameHeader::new(FrameId::Valid(Cow::Borrowed("UFID")), FrameFlags::default()), owner: String::new(), identifier: vec![0], }; diff --git a/lofty/src/id3/v2/tag/tests.rs b/lofty/src/id3/v2/tag/tests.rs index 1dd1ec1a..b932c471 100644 --- a/lofty/src/id3/v2/tag/tests.rs +++ b/lofty/src/id3/v2/tag/tests.rs @@ -21,7 +21,7 @@ fn read_tag(path: &str) -> Id3v2Tag { } fn read_tag_raw(bytes: &[u8]) -> Id3v2Tag { - let mut reader = Cursor::new(&bytes[..]); + let mut reader = Cursor::new(bytes); let header = Id3v2Header::parse(&mut reader).unwrap(); crate::id3::v2::read::parse_id3v2(&mut reader, header, ParsingMode::Strict).unwrap() diff --git a/lofty/tests/files/mpeg.rs b/lofty/tests/files/mpeg.rs index c6307edc..ce341bde 100644 --- a/lofty/tests/files/mpeg.rs +++ b/lofty/tests/files/mpeg.rs @@ -340,9 +340,8 @@ fn read_and_write_tpil_frame() { let tag: &Id3v2Tag = mpeg_file.id3v2().unwrap(); - let content = match tag.get(&FrameId::Valid(Cow::Borrowed("TIPL"))).unwrap() { - Frame::KeyValue(content) => content, - _ => panic!("Wrong Frame Value Type for TIPL"), + let Frame::KeyValue(content) = tag.get(&FrameId::Valid(Cow::Borrowed("TIPL"))).unwrap() else { + panic!("Wrong Frame Value Type for TIPL") }; assert_eq!(key_value_pairs, content.key_value_pairs); diff --git a/lofty/tests/fuzz/main.rs b/lofty/tests/fuzz/main.rs index 4d0383b4..7ffb41c0 100644 --- a/lofty/tests/fuzz/main.rs +++ b/lofty/tests/fuzz/main.rs @@ -19,6 +19,7 @@ mod vorbisfile_read_from; mod wavfile_read_from; mod wavpackfile_read_from; +#[allow(clippy::missing_panics_doc)] pub fn get_reader(path: &str) -> Cursor> { let path = Path::new("tests/fuzz/assets").join(path); @@ -26,6 +27,7 @@ pub fn get_reader(path: &str) -> Cursor> { Cursor::new(b) } +#[allow(clippy::missing_panics_doc)] pub fn oom_test(path: &'static str) { let instant = Instant::now(); let thread = thread::spawn(|| { diff --git a/lofty/tests/hound.rs b/lofty/tests/hound.rs index 83846c96..a35d3618 100644 --- a/lofty/tests/hound.rs +++ b/lofty/tests/hound.rs @@ -25,9 +25,12 @@ fn hound() { println!("Name: {}", path.display()); let wav_reader = WavReader::open(&path).unwrap(); let lofty = get_properties(&path).unwrap(); - assert_eq!(lofty.channels() as u16, wav_reader.spec().channels); + assert_eq!(u16::from(lofty.channels()), wav_reader.spec().channels); assert_eq!(lofty.sample_rate(), wav_reader.spec().sample_rate); - assert_eq!(lofty.bit_depth() as u16, wav_reader.spec().bits_per_sample); + assert_eq!( + u16::from(lofty.bit_depth()), + wav_reader.spec().bits_per_sample + ); } } } @@ -43,9 +46,12 @@ fn hound_fuzz() { if let Ok(wav_reader) = WavReader::open(&path) { let lofty = get_properties(&path).unwrap(); println!("{lofty:#?}"); - assert_eq!(lofty.channels() as u16, wav_reader.spec().channels); + assert_eq!(u16::from(lofty.channels()), wav_reader.spec().channels); assert_eq!(lofty.sample_rate(), wav_reader.spec().sample_rate); - assert_eq!(lofty.bit_depth() as u16, wav_reader.spec().bits_per_sample); + assert_eq!( + u16::from(lofty.bit_depth()), + wav_reader.spec().bits_per_sample + ); } else if get_properties(&path).is_ok() { println!("We are even better for this file!"); } diff --git a/ogg_pager/src/lib.rs b/ogg_pager/src/lib.rs index 1782f95d..74b0ad3f 100644 --- a/ogg_pager/src/lib.rs +++ b/ogg_pager/src/lib.rs @@ -238,10 +238,10 @@ mod tests { start: 0, header_type_flag: 2, abgp: 0, - stream_serial: 1759377061, + stream_serial: 1_759_377_061, sequence_number: 0, segments: vec![19], - checksum: 3579522525, + checksum: 3_579_522_525, }, end: 47, };