pub mod config_tests;
pub mod error_tests;
pub mod preprocess_tests;
pub mod math_tests;
pub mod output_tests;
pub mod ocr_tests;
#[cfg(test)]
mod common {
use std::path::PathBuf;
pub fn fixtures_dir() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("tests")
.join("fixtures")
}
pub fn fixture_path(name: &str) -> PathBuf {
fixtures_dir().join(name)
}
pub fn has_fixture(name: &str) -> bool {
fixture_path(name).exists()
}
pub fn normalize_latex(latex: &str) -> String {
latex
.chars()
.filter(|c| !c.is_whitespace())
.collect::<String>()
.to_lowercase()
}
pub fn string_similarity(a: &str, b: &str) -> f64 {
if a == b {
return 1.0;
}
if a.is_empty() || b.is_empty() {
return 0.0;
}
let max_len = a.len().max(b.len());
let matching = a.chars().zip(b.chars()).filter(|(x, y)| x == y).count();
matching as f64 / max_len as f64
}
}