use depyler_core::transpile_python_to_rust;
#[test]
fn test_wrap() {
let python = r#"
import textwrap
def wrap_text(text: str, width: int) -> list:
return textwrap.wrap(text, width)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("current_line") || result.contains("split_whitespace"));
}
#[test]
fn test_fill() {
let python = r#"
import textwrap
def fill_text(text: str, width: int) -> str:
return textwrap.fill(text, width)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("join"));
assert!(result.contains("current_line"));
}
#[test]
fn test_dedent() {
let python = r#"
import textwrap
def remove_indent(text: str) -> str:
return textwrap.dedent(text)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("min_indent"));
assert!(result.contains("is_whitespace"));
}
#[test]
fn test_indent() {
let python = r#"
import textwrap
def add_indent(text: str, prefix: str) -> str:
return textwrap.indent(text, prefix)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("prefix"));
assert!(result.contains("lines"));
}
#[test]
fn test_shorten() {
let python = r#"
import textwrap
def shorten_text(text: str, width: int) -> str:
return textwrap.shorten(text, width)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("placeholder"));
assert!(result.contains("[...]"));
}