summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorjakka <jakkadoujin@gmail.com>2025-06-04 21:30:40 +0300
committerjakka <jakkadoujin@gmail.com>2025-06-04 21:30:40 +0300
commita7615b9471dfe6fe94a3ace6e4f94e9c78844b51 (patch)
tree360aee3c3c7127e9bc76611af81c0a06c3a72ab1 /src/main.rs
parentf5c4e39405cada1fb8dcf3072b2f40d1590e218c (diff)
added 16 and 24 bit md5sum calculation support
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs64
1 files changed, 61 insertions, 3 deletions
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);
+ }
}