mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2024-12-04 18:09:11 +00:00
Tests: Fix Clippy lints
This commit is contained in:
parent
621ab57fe1
commit
5b40a2f3a4
12 changed files with 26 additions and 19 deletions
|
@ -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 },
|
||||
|
|
|
@ -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")),
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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(),
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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],
|
||||
};
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<Vec<u8>> {
|
||||
let path = Path::new("tests/fuzz/assets").join(path);
|
||||
|
||||
|
@ -26,6 +27,7 @@ pub fn get_reader(path: &str) -> Cursor<Vec<u8>> {
|
|||
Cursor::new(b)
|
||||
}
|
||||
|
||||
#[allow(clippy::missing_panics_doc)]
|
||||
pub fn oom_test<A: AudioFile>(path: &'static str) {
|
||||
let instant = Instant::now();
|
||||
let thread = thread::spawn(|| {
|
||||
|
|
|
@ -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!");
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue