use depyler_core::transpile_python_to_rust;
#[test]
fn test_hashlib_md5() {
let python = r#"
import hashlib
def hash_md5(data: bytes) -> str:
return hashlib.md5(data)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("md5") || result.contains("Md5"));
assert!(result.contains("hex"));
}
#[test]
fn test_hashlib_sha1() {
let python = r#"
import hashlib
def hash_sha1(data: bytes) -> str:
return hashlib.sha1(data)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("sha1") || result.contains("Sha1"));
assert!(result.contains("hex"));
}
#[test]
fn test_hashlib_sha256() {
let python = r#"
import hashlib
def hash_sha256(data: bytes) -> str:
return hashlib.sha256(data)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("sha256") || result.contains("Sha256"));
assert!(result.contains("hex"));
}
#[test]
fn test_hashlib_sha512() {
let python = r#"
import hashlib
def hash_sha512(data: bytes) -> str:
return hashlib.sha512(data)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("sha512") || result.contains("Sha512"));
assert!(result.contains("hex"));
}
#[test]
fn test_hashlib_sha224() {
let python = r#"
import hashlib
def hash_sha224(data: bytes) -> str:
return hashlib.sha224(data)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("sha224") || result.contains("Sha224"));
assert!(result.contains("hex"));
}
#[test]
fn test_hashlib_sha384() {
let python = r#"
import hashlib
def hash_sha384(data: bytes) -> str:
return hashlib.sha384(data)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("sha384") || result.contains("Sha384"));
assert!(result.contains("hex"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-HASHLIB: Not implemented yet - RED phase"]
fn test_hashlib_sha3_256() {
let python = r#"
import hashlib
def hash_sha3_256(data: bytes) -> str:
return hashlib.sha3_256(data).hexdigest()
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("sha3") || result.contains("Sha3"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-HASHLIB: Not implemented yet - RED phase"]
fn test_hashlib_sha3_512() {
let python = r#"
import hashlib
def hash_sha3_512(data: bytes) -> str:
return hashlib.sha3_512(data).hexdigest()
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("sha3") || result.contains("Sha3"));
}
#[test]
fn test_hashlib_blake2b() {
let python = r#"
import hashlib
def hash_blake2b(data: bytes) -> str:
return hashlib.blake2b(data)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("blake2") || result.contains("Blake2"));
assert!(result.contains("hex"));
}
#[test]
fn test_hashlib_blake2s() {
let python = r#"
import hashlib
def hash_blake2s(data: bytes) -> str:
return hashlib.blake2s(data)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("blake2") || result.contains("Blake2"));
assert!(result.contains("hex"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-HASHLIB: Not implemented yet - RED phase"]
fn test_hashlib_shake_128() {
let python = r#"
import hashlib
def hash_shake_128(data: bytes, length: int) -> str:
return hashlib.shake_128(data).hexdigest(length)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("shake") || result.contains("Shake"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-HASHLIB: Not implemented yet - RED phase"]
fn test_hashlib_shake_256() {
let python = r#"
import hashlib
def hash_shake_256(data: bytes, length: int) -> str:
return hashlib.shake_256(data).hexdigest(length)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("shake") || result.contains("Shake"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-HASHLIB: Not implemented yet - RED phase"]
fn test_hashlib_update() {
let python = r#"
import hashlib
def incremental_hash(data1: bytes, data2: bytes) -> str:
h = hashlib.sha256()
h.update(data1)
h.update(data2)
return h.hexdigest()
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("update") || result.contains("Hasher"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-HASHLIB: Not implemented yet - RED phase"]
fn test_hashlib_digest() {
let python = r#"
import hashlib
def hash_digest(data: bytes) -> bytes:
return hashlib.sha256(data).digest()
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("digest") || result.contains("finalize"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-HASHLIB: Not implemented yet - RED phase"]
fn test_hashlib_new() {
let python = r#"
import hashlib
def hash_with_new(algo: str, data: bytes) -> str:
return hashlib.new(algo, data).hexdigest()
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("new") || result.contains("match"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-HASHLIB: Not implemented yet - RED phase"]
fn test_hashlib_algorithms_available() {
let python = r#"
import hashlib
def get_algorithms() -> set:
return hashlib.algorithms_available
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("algorithms") || result.contains("HashSet"));
}