51 lines
1.8 KiB
Rust
51 lines
1.8 KiB
Rust
#[cfg(test)]
|
|
mod tests {
|
|
use std::fs;
|
|
|
|
use day47::{compress, uncompress};
|
|
|
|
#[test]
|
|
fn librs() {
|
|
assert!(compress("src/lib.rs", "compressed1").is_ok());
|
|
assert!(uncompress("compressed1", "uncompressed1").is_ok());
|
|
let original = fs::read("src/lib.rs").unwrap();
|
|
let uncompressed = fs::read("uncompressed1").unwrap();
|
|
assert_eq!(original, uncompressed);
|
|
fs::remove_file("compressed1").unwrap();
|
|
fs::remove_file("uncompressed1").unwrap();
|
|
}
|
|
|
|
#[test]
|
|
fn mainrs() {
|
|
assert!(compress("src/main.rs", "compressed2").is_ok());
|
|
assert!(uncompress("compressed2", "uncompressed2").is_ok());
|
|
let original = fs::read("src/main.rs").unwrap();
|
|
let uncompressed = fs::read("uncompressed2").unwrap();
|
|
assert_eq!(original, uncompressed);
|
|
fs::remove_file("compressed2").unwrap();
|
|
fs::remove_file("uncompressed2").unwrap();
|
|
}
|
|
|
|
#[test]
|
|
fn cargotoml() {
|
|
assert!(compress("Cargo.toml", "compressed3").is_ok());
|
|
assert!(uncompress("compressed3", "uncompressed3").is_ok());
|
|
let original = fs::read("Cargo.toml").unwrap();
|
|
let uncompressed = fs::read("uncompressed3").unwrap();
|
|
assert_eq!(original, uncompressed);
|
|
fs::remove_file("compressed3").unwrap();
|
|
fs::remove_file("uncompressed3").unwrap();
|
|
}
|
|
|
|
#[test]
|
|
fn cargolock() {
|
|
assert!(compress("Cargo.lock", "compressed4").is_ok());
|
|
assert!(uncompress("compressed4", "uncompressed4").is_ok());
|
|
let original = fs::read("Cargo.lock").unwrap();
|
|
let uncompressed = fs::read("uncompressed4").unwrap();
|
|
assert_eq!(original, uncompressed);
|
|
fs::remove_file("compressed4").unwrap();
|
|
fs::remove_file("uncompressed4").unwrap();
|
|
}
|
|
}
|