diff --git a/parsers/src/rsm.rs b/parsers/src/rsm.rs index 9eb11dd0..af3aa744 100644 --- a/parsers/src/rsm.rs +++ b/parsers/src/rsm.rs @@ -78,10 +78,13 @@ impl From for Element { set.after .map(|after| Element::builder("after", ns::RSM).append(after)), ) - .append_all( - set.before - .map(|before| Element::builder("before", ns::RSM).append(before)), - ) + .append_all(set.before.map(|before| { + let mut builder = Element::builder("before", ns::RSM); + if !before.is_empty() { + builder = builder.append(before); + } + builder + })) .append_all( set.index .map(|index| Element::builder("index", ns::RSM).append(format!("{}", index))), @@ -278,6 +281,21 @@ mod tests { assert_eq!(elem, elem2); } + #[test] + fn test_serialise_empty_before() { + let elem: Element = "" + .parse() + .unwrap(); + let rsm = SetQuery { + max: None, + after: None, + before: Some("".into()), + index: None, + }; + let elem2 = rsm.into(); + assert_eq!(elem, elem2); + } + #[test] fn test_first_index() { let elem: Element =