extern crate escapade; #[allow(unused_must_use)] mod test { use escapade::Escapable; use escapade::EscapedWriter; use escapade::EscapedWrite; #[test] fn escape_unsafe_string() { let mut buffer = EscapedWriter::new(vec![]); buffer.write_str(String::from("&world")); assert_eq!("<hello>&world</hello>", String::from_utf8(buffer.into_inner()).unwrap()); } #[test] fn escape_unsafe_str() { let mut buffer = EscapedWriter::new(vec![]); buffer.write_str("&world"); assert_eq!("<hello>&world</hello>", String::from_utf8(buffer.into_inner()).unwrap()); } #[test] fn escape_safe_str() { let mut buffer = EscapedWriter::new(vec![]); let s = "&world".escape(); buffer.write_str(s); assert_eq!("<hello>&world</hello>", String::from_utf8(buffer.into_inner()).unwrap()); } #[test] fn mark_string_safe() { let mut buffer = EscapedWriter::new(vec![]); buffer.write_str("&world".safe()); assert_eq!("&world", String::from_utf8(buffer.into_inner()).unwrap()); } }