diff --git a/src/lib.rs b/src/lib.rs index 3517c80..b4a4590 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,9 +11,4 @@ pub mod args; pub use args::Args; #[cfg(test)] -mod tests { - #[test] - fn test_library_structure() { - assert!(true); - } -} +mod tests; diff --git a/src/tests/common/is_binary_tests.rs b/src/tests/common/is_binary_tests.rs index f9b82d9..79c13c6 100644 --- a/src/tests/common/is_binary_tests.rs +++ b/src/tests/common/is_binary_tests.rs @@ -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); } } diff --git a/src/tests/compression/mod.rs b/src/tests/compression/mod.rs index c274057..19c49c5 100644 --- a/src/tests/compression/mod.rs +++ b/src/tests/compression/mod.rs @@ -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; -}