- Fix toml version requirement metadata warning - Replace clone() with std::slice::from_ref() - Collapse nested if statements - Add #[allow(dead_code)] to test utility functions - Fix unused imports and variables in tests - Use unwrap_or_else instead of expect with format!
23 lines
747 B
Rust
23 lines
747 B
Rust
//! Test utilities for golden tests
|
|
|
|
use std::fs;
|
|
|
|
/// Read a file and return its contents
|
|
#[allow(dead_code)]
|
|
pub fn read_test_file(path: &str) -> String {
|
|
fs::read_to_string(path).unwrap_or_else(|_| panic!("Failed to read test file: {}", path))
|
|
}
|
|
|
|
/// Write content to a file for testing
|
|
#[allow(dead_code)]
|
|
pub fn write_test_file(path: &str, content: &str) {
|
|
fs::write(path, content).unwrap_or_else(|_| panic!("Failed to write test file: {}", path))
|
|
}
|
|
|
|
/// Compare two strings and panic if they don't match
|
|
#[allow(dead_code)]
|
|
pub fn assert_strings_equal(actual: &str, expected: &str, message: &str) {
|
|
if actual != expected {
|
|
panic!("{}: Strings do not match\nActual:\n{}\nExpected:\n{}", message, actual, expected);
|
|
}
|
|
} |