summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorjakka <jakkadoujin@gmail.com>2025-06-10 20:45:35 +0300
committerjakka <jakkadoujin@gmail.com>2025-06-10 20:45:35 +0300
commit9450972d8414065b005827198340adcd8a3e864a (patch)
tree475f6dc49fc799aa89cc0e1a1fa524d63af35140 /src/main.rs
parent6637e834af047c76eb18cfcce512995d7f8c9d8f (diff)
edited tests, finished writing encoder for all bitrates
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/main.rs b/src/main.rs
index 07b1c89..3f73a25 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2,7 +2,7 @@ mod db;
mod flac;
fn main() {
- if let Err(err) = flac::encode_file(std::path::Path::new("16bit.flac")) {
+ if let Err(err) = flac::encode_file(std::path::Path::new("32bit.flac")) {
println!("{}", err)
};
}
@@ -11,56 +11,64 @@ fn main() {
mod tests {
use super::*;
use metaflac::Tag;
+
#[test]
fn bit16() {
+ std::fs::copy("16bit.flac", "16bit.flac.temp").unwrap();
flac::encode_file(std::path::Path::new("16bit.flac")).unwrap();
- let target_md5 = Tag::read_from_path("16bit.flac.tmp")
+ let target_md5 = Tag::read_from_path("16bit.flac.temp")
.unwrap()
.get_streaminfo()
.unwrap()
.md5
.clone();
- let source_md5 = Tag::read_from_path("16bit.flac")
+ let encoded_md5 = Tag::read_from_path("16bit.flac")
.unwrap()
.get_streaminfo()
.unwrap()
.md5
.clone();
- assert_eq!(target_md5, source_md5);
+ std::fs::remove_file("16bit.flac.temp").unwrap();
+ assert_eq!(target_md5, encoded_md5);
}
+
#[test]
fn bit24() {
+ std::fs::copy("24bit.flac", "24bit.flac.temp").unwrap();
flac::encode_file(std::path::Path::new("24bit.flac")).unwrap();
- let target_md5 = Tag::read_from_path("24bit.flac.tmp")
+ let target_md5 = Tag::read_from_path("24bit.flac.temp")
.unwrap()
.get_streaminfo()
.unwrap()
.md5
.clone();
- let source_md5 = Tag::read_from_path("24bit.flac")
+ let encoded_md5 = Tag::read_from_path("24bit.flac")
.unwrap()
.get_streaminfo()
.unwrap()
.md5
.clone();
- assert_eq!(target_md5, source_md5);
+ std::fs::remove_file("24bit.flac.temp").unwrap();
+ assert_eq!(target_md5, encoded_md5);
}
+
#[test]
- #[should_panic]
fn bit32() {
+ std::fs::copy("32bit.flac", "32bit.flac.temp").unwrap();
flac::encode_file(std::path::Path::new("32bit.flac")).unwrap();
- let target_md5 = Tag::read_from_path("32bit.flac.tmp")
+ let target_md5 = Tag::read_from_path("32bit.flac.temp")
.unwrap()
.get_streaminfo()
.unwrap()
.md5
.clone();
- let source_md5 = Tag::read_from_path("32bit.flac")
+ let encoded_md5 = Tag::read_from_path("32bit.flac")
.unwrap()
.get_streaminfo()
.unwrap()
.md5
.clone();
- assert_eq!(target_md5, source_md5);
+ std::fs::remove_file("32bit.flac.temp").unwrap();
+ assert_eq!(target_md5, encoded_md5);
}
}