use depyler_core::transpile_python_to_rust;
#[test]
fn test_string_ascii_letters() {
let python = r#"
import string
def get_letters() -> str:
return string.ascii_letters
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("ascii_letters") || result.contains("A-Z"));
}
#[test]
fn test_string_ascii_lowercase() {
let python = r#"
import string
def get_lowercase() -> str:
return string.ascii_lowercase
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("ascii_lowercase") || result.contains("abcdefghijklmnopqrstuvwxyz"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-STRING: Not implemented yet - RED phase"]
fn test_string_ascii_uppercase() {
let python = r#"
import string
def get_uppercase() -> str:
return string.ascii_uppercase
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("ascii_uppercase") || result.contains("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
}
#[test]
fn test_string_digits() {
let python = r#"
import string
def get_digits() -> str:
return string.digits
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("digits") || result.contains("0123456789"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-STRING: Not implemented yet - RED phase"]
fn test_string_hexdigits() {
let python = r#"
import string
def get_hexdigits() -> str:
return string.hexdigits
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("hexdigits") || result.contains("0123456789abcdef"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-STRING: Not implemented yet - RED phase"]
fn test_string_octdigits() {
let python = r#"
import string
def get_octdigits() -> str:
return string.octdigits
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("octdigits") || result.contains("01234567"));
}
#[test]
fn test_string_punctuation() {
let python = r#"
import string
def get_punctuation() -> str:
return string.punctuation
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("punctuation") || result.contains("!"));
}
#[test]
fn test_string_whitespace() {
let python = r#"
import string
def get_whitespace() -> str:
return string.whitespace
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("whitespace") || result.contains("\\t\\n"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-STRING: Not implemented yet - RED phase"]
fn test_string_printable() {
let python = r#"
import string
def get_printable() -> str:
return string.printable
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("printable"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-STRING: Not implemented yet - RED phase"]
fn test_string_template_substitute() {
let python = r#"
import string
def format_template(name: str) -> str:
template = string.Template('Hello $name!')
return template.substitute(name=name)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("format") || result.contains("replace"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-STRING: Not implemented yet - RED phase"]
fn test_string_template_safe_substitute() {
let python = r#"
import string
def safe_format(template_str: str, data: dict) -> str:
template = string.Template(template_str)
return template.safe_substitute(data)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("substitute") || result.contains("replace"));
}
#[test]
fn test_string_capwords() {
let python = r#"
import string
def capitalize_words(text: str) -> str:
return string.capwords(text)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("split") || result.contains("capitalize"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-STRING: Not implemented yet - RED phase"]
fn test_string_formatter_format() {
let python = r#"
import string
def format_string(fmt: str, value: int) -> str:
formatter = string.Formatter()
return formatter.format(fmt, value)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("format"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-STRING: Not implemented yet - RED phase"]
fn test_string_formatter_vformat() {
let python = r#"
import string
def vformat_string(fmt: str, args: list, kwargs: dict) -> str:
formatter = string.Formatter()
return formatter.vformat(fmt, args, kwargs)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("format"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-STRING: Not implemented yet - RED phase"]
fn test_check_if_digit() {
let python = r#"
import string
def is_digit_char(c: str) -> bool:
return c in string.digits
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("digits") || result.contains("is_digit"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-STRING: Not implemented yet - RED phase"]
fn test_check_if_letter() {
let python = r#"
import string
def is_letter(c: str) -> bool:
return c in string.ascii_letters
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("ascii_letters") || result.contains("is_alphabetic"));
}