fix: enable and fix all existing tests by updating module imports and test implementations
Co-authored-by: aider (openai/andrew/openrouter/anthropic/claude-sonnet-4) <aider@aider.chat>
This commit is contained in:
@@ -1,39 +1,40 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use keep::common::is_binary::calculate_printable_ratio;
|
||||
use crate::common::is_binary::is_binary;
|
||||
|
||||
#[test]
|
||||
fn test_calculate_printable_ratio_text() {
|
||||
fn test_is_binary_text() {
|
||||
let text_data = b"Hello, World! This is plain text.\nWith newlines and spaces.";
|
||||
let ratio = calculate_printable_ratio(text_data);
|
||||
let result = is_binary(text_data);
|
||||
|
||||
// Text data should have high printable ratio
|
||||
assert!(ratio > 0.8);
|
||||
// Text data should not be detected as binary
|
||||
assert!(!result);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_calculate_printable_ratio_binary() {
|
||||
fn test_is_binary_binary() {
|
||||
let binary_data = b"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09";
|
||||
let ratio = calculate_printable_ratio(binary_data);
|
||||
let result = is_binary(binary_data);
|
||||
|
||||
// Binary data should have low printable ratio
|
||||
assert!(ratio < 0.5);
|
||||
// Binary data should be detected as binary
|
||||
assert!(result);
|
||||
}
|
||||
|
||||
#[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);
|
||||
fn test_is_binary_png_signature() {
|
||||
let png_data = b"\x89\x50\x4E\x47\x0D\x0A\x1A\x0A";
|
||||
let result = is_binary(png_data);
|
||||
|
||||
// Mixed data should have medium printable ratio
|
||||
assert!(ratio > 0.3 && ratio < 0.8);
|
||||
// PNG signature should be detected as binary
|
||||
assert!(result);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_calculate_printable_ratio_empty() {
|
||||
fn test_is_binary_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);
|
||||
let result = is_binary(empty_data);
|
||||
|
||||
// Empty data should not be detected as binary
|
||||
assert!(!result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,14 +4,3 @@ pub mod gzip_tests;
|
||||
pub mod lz4_tests;
|
||||
#[cfg(test)]
|
||||
pub mod none_tests;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use tempfile::tempdir;
|
||||
use std::io::Write;
|
||||
|
||||
// Import the modules we need for testing
|
||||
use crate::compression_engine::gzip::CompressionEngineGZip;
|
||||
use crate::compression_engine::lz4::CompressionEngineLZ4;
|
||||
use crate::compression_engine::none::CompressionEngineNone;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user