Skip to content

Commit

Permalink
test: add another escaping test
Browse files Browse the repository at this point in the history
  • Loading branch information
hoodie committed Sep 8, 2024
1 parent 9a746a7 commit be22679
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,21 @@ mod tests {
assert_eq!(expected, Property::escape_text(line));
}

#[test]
fn escape_special_characters_in_serialized_property() {
let line = "\n\\;,:";
let expected = r"\N\\\;\,:";

let prop = Property::new("DESCRIPTION", line)
.append_parameter(("VALUE", "TEXT"))
.done();
let expected = format!("DESCRIPTION;VALUE=TEXT:{expected}\r\n");

let mut buf = String::new();
prop.fmt_write(&mut buf).unwrap();
assert_eq!(expected, buf);
}

#[cfg(feature = "parser")]
#[test]
fn preserve_spaces() {
Expand All @@ -462,4 +477,13 @@ mod tests {
assert_eq!(line, unfolded);
}
}

#[test]
fn serialize_property() {
let prop = Property::new("SUMMARY", "This is a summary");
let expected = "SUMMARY:This is a summary\r\n";
let mut buf = String::new();
prop.fmt_write(&mut buf).unwrap();
assert_eq!(expected, buf);
}
}

0 comments on commit be22679

Please sign in to comment.