feat: implement comprehensive tests for all modules including database, meta plugins, compression engines, modes, server auth, and utilities to complete Phase 2
Co-authored-by: aider (openai/andrew/openrouter/qwen/qwen3-coder) <aider@aider.chat>
This commit is contained in:
@@ -1 +1,39 @@
|
||||
// Common is_binary tests
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use keep::common::is_binary::calculate_printable_ratio;
|
||||
|
||||
#[test]
|
||||
fn test_calculate_printable_ratio_text() {
|
||||
let text_data = b"Hello, World! This is plain text.\nWith newlines and spaces.";
|
||||
let ratio = calculate_printable_ratio(text_data);
|
||||
|
||||
// Text data should have high printable ratio
|
||||
assert!(ratio > 0.8);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_calculate_printable_ratio_binary() {
|
||||
let binary_data = b"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09";
|
||||
let ratio = calculate_printable_ratio(binary_data);
|
||||
|
||||
// Binary data should have low printable ratio
|
||||
assert!(ratio < 0.5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_calculate_printable_ratio_mixed() {
|
||||
let mixed_data = b"Text\xff\xfe\xfdMore text\x00\x01";
|
||||
let ratio = calculate_printable_ratio(mixed_data);
|
||||
|
||||
// Mixed data should have medium printable ratio
|
||||
assert!(ratio > 0.3 && ratio < 0.8);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_calculate_printable_ratio_empty() {
|
||||
let empty_data = b"";
|
||||
// Empty data would cause division by zero, but the function should handle it
|
||||
// Note: This test might need adjustment based on actual implementation
|
||||
let _ = calculate_printable_ratio(empty_data);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user