I am not sure if the following is expected behavior:
--- tests/reserialize.rs
+++ tests/reserialize.rs
@@ -1,5 +1,8 @@
#![cfg(feature = "parser")]
-use icalendar::parser::unfold;
+
+use std::str::FromStr as _;
+
+use icalendar::{parser::unfold, Calendar, CalendarComponent, Component, Todo};
use pretty_assertions::assert_eq;
const SAMPLE: &str = "\
@@ -50,3 +53,21 @@ fn reserialization() {
println!("{}", reserialized);
assert_eq!(SAMPLE, reserialized);
}
+
+#[test]
+fn reserialization_multi_line_description() {
+ let desc = "multi-\nline\ndescription";
+ let mut todo = Todo::new();
+ todo.summary("summary");
+ todo.description(desc);
+ let calendar = Calendar::from([todo]);
+
+ let serialized = calendar.to_string();
+ let deserialized = Calendar::from_str(&serialized).unwrap();
+ let deserialized_todo = match deserialized.components.as_slice() {
+ [CalendarComponent::Todo(todo)] => todo,
+ _ => unreachable!(),
+ };
+ let deserialized_desc = deserialized_todo.get_description().unwrap();
+ assert_eq!(deserialized_desc, desc);
+}
This test fails:
running 1 test
thread 'reserialization_multi_line_description' panicked at tests/reserialize.rs:72:5:
assertion failed: `(left == right)`
Diff < left / right > :
<multi-\nline\ndescription
>multi-
>line
>description
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
test reserialization_multi_line_description ... FAILED
It seems as if newlines are encoded to \\n (correct) but then never decoded back to \n in this scenario. I'd expect that at the level of a Todo object, I as the user shouldn't have to deal with such encoding matters -- it should all happen transparently. So I am wondering: Is this behavior intended?
I am not sure if the following is expected behavior:
This test fails:
It seems as if newlines are encoded to
\\n(correct) but then never decoded back to\nin this scenario. I'd expect that at the level of aTodoobject, I as the user shouldn't have to deal with such encoding matters -- it should all happen transparently. So I am wondering: Is this behavior intended?