From a7615b9471dfe6fe94a3ace6e4f94e9c78844b51 Mon Sep 17 00:00:00 2001 From: jakka Date: Wed, 4 Jun 2025 21:30:40 +0300 Subject: added 16 and 24 bit md5sum calculation support --- src/main.rs | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 3 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index ba95650..89343f1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,65 @@ mod flac; fn main() { - if let Err(error) = flac::encode_file(std::path::Path::new("./1.flac")) { - println!("{}", error) - }; + todo!() +} + +#[cfg(test)] +mod tests { + use super::*; + use metaflac::Tag; + #[test] + fn bit16() { + flac::encode_file(std::path::Path::new("16bit.flac")).unwrap(); + let target_md5 = Tag::read_from_path("16bit.flac.tmp") + .unwrap() + .get_streaminfo() + .unwrap() + .md5 + .clone(); + let source_md5 = Tag::read_from_path("16bit.flac") + .unwrap() + .get_streaminfo() + .unwrap() + .md5 + .clone(); + std::fs::remove_file(std::path::Path::new("16bit.flac.tmp")).unwrap(); + assert_eq!(target_md5, source_md5); + } + #[test] + fn bit24() { + flac::encode_file(std::path::Path::new("24bit.flac")).unwrap(); + let target_md5 = Tag::read_from_path("24bit.flac.tmp") + .unwrap() + .get_streaminfo() + .unwrap() + .md5 + .clone(); + let source_md5 = Tag::read_from_path("24bit.flac") + .unwrap() + .get_streaminfo() + .unwrap() + .md5 + .clone(); + std::fs::remove_file(std::path::Path::new("24bit.flac.tmp")).unwrap(); + assert_eq!(target_md5, source_md5); + } + #[test] + fn bit32() { + flac::encode_file(std::path::Path::new("32bit.flac")).unwrap(); + let target_md5 = Tag::read_from_path("32bit.flac.tmp") + .unwrap() + .get_streaminfo() + .unwrap() + .md5 + .clone(); + let source_md5 = Tag::read_from_path("32bit.flac") + .unwrap() + .get_streaminfo() + .unwrap() + .md5 + .clone(); + std::fs::remove_file(std::path::Path::new("32bit.flac.tmp")).unwrap(); + assert_eq!(target_md5, source_md5); + } } -- cgit v1.3.1