escape text and attribute values
This commit is contained in:
parent
8b50dadb92
commit
052c46635a
2 changed files with 51 additions and 3 deletions
28
src/tests.rs
28
src/tests.rs
|
|
@ -43,6 +43,34 @@ fn writer_works() {
|
|||
assert_eq!(String::from_utf8(writer).unwrap(), TEST_STRING);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn writer_escapes_attributes() {
|
||||
let root = Element::builder("root")
|
||||
.attr("a", "\"Air\" quotes")
|
||||
.build();
|
||||
let mut writer = Vec::new();
|
||||
{
|
||||
root.write_to(&mut writer).unwrap();
|
||||
}
|
||||
assert_eq!(String::from_utf8(writer).unwrap(),
|
||||
r#"<?xml version="1.0" encoding="utf-8"?><root a=""Air" quotes" />"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn writer_escapes_text() {
|
||||
let root = Element::builder("root")
|
||||
.append("<3")
|
||||
.build();
|
||||
let mut writer = Vec::new();
|
||||
{
|
||||
root.write_to(&mut writer).unwrap();
|
||||
}
|
||||
assert_eq!(String::from_utf8(writer).unwrap(),
|
||||
r#"<?xml version="1.0" encoding="utf-8"?><root><3</root>"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn builder_works() {
|
||||
let elem = Element::builder("a")
|
||||
|
|
|
|||
Loading…
Reference in a new issue