pub use babbel_core::escape::{escape_for_json, escape_for_xml};
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_escape_for_json_basic() {
assert_eq!(escape_for_json("foo"), "foo");
assert_eq!(escape_for_json("\"\\\n\r\t"), "\\\"\\\\\\n\\r\\t");
assert_eq!(escape_for_json("abc\u{1F}"), "abc\\u001f");
}
#[test]
fn test_escape_for_json_control_chars() {
let input = "\x01\x02\x03";
let expected = "\\u0001\\u0002\\u0003";
assert_eq!(escape_for_json(input), expected);
}
#[test]
fn test_escape_for_xml_basic() {
assert_eq!(escape_for_xml("foo"), "foo");
assert_eq!(escape_for_xml("<>&\"'"), "<>&"'");
}
#[test]
fn test_escape_for_xml_mixed() {
let input = "a <b> & 'c' \"d\"";
let expected = "a <b> & 'c' "d"";
assert_eq!(escape_for_xml(input), expected);
}
}