use std::io::{BufReader, BufRead}; use std::fs::File; use std::path::PathBuf; #[cfg(test)] pub fn has_files(full_path: PathBuf, file: &str, content: &str, test_id: String) -> bool { if !full_path.exists() { println!("id: {}", test_id.clone()); eprintln!("File '{}' doesn't exists", file); return false; } let f = File::open(full_path).unwrap(); for line in BufReader::new(f).lines(){ if let Ok(line) = line { if line != content { println!("id: {}", test_id); eprintln!("File '{}' is not equal, {} != {}", file, line, content); return false; } return line == content; } } return true; } #[cfg(test)] pub fn has_not_file(full_path: PathBuf, file: &str, test_id: String) -> bool { if full_path.exists() { println!("id: {}", test_id.clone()); eprintln!("File '{}' exists but it shouldn't", file); return false; } return true; } #[cfg(test)] pub fn has_not_dir(full_path: PathBuf, dir: &str, test_id: String) -> bool { if full_path.exists() { println!("id: {}", test_id.clone()); eprintln!("Dir '{}' exists but it shouldn't", dir); return false; } return true; }