Check attr="" parse to Some("") in Option<String>

xmppftw created

Change summary

parsers/src/util/macro_tests.rs | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)

Detailed changes

parsers/src/util/macro_tests.rs 🔗

@@ -1034,6 +1034,25 @@ fn optional_attribute_extract_positive_present() {
     }
 }
 
+#[test]
+fn optional_attribute_extract_positive_present_empty() {
+    #[allow(unused_imports)]
+    use std::{
+        option::Option::{None, Some},
+        result::Result::{Err, Ok},
+    };
+    match parse_str::<OptionalAttributeExtract>(
+        "<parent xmlns='urn:example:ns1'><child foo=''/></parent>",
+    ) {
+        Ok(OptionalAttributeExtract {
+            contents: Some(contents),
+        }) => {
+            assert_eq!(contents, "");
+        }
+        other => panic!("unexpected result: {:?}", other),
+    }
+}
+
 #[test]
 fn optional_attribute_extract_positive_absent() {
     #[allow(unused_imports)]
@@ -1060,6 +1079,18 @@ fn optional_attribute_extract_roundtrip_present() {
     )
 }
 
+#[test]
+fn optional_attribute_extract_roundtrip_present_empty() {
+    #[allow(unused_imports)]
+    use std::{
+        option::Option::{None, Some},
+        result::Result::{Err, Ok},
+    };
+    roundtrip_full::<OptionalAttributeExtract>(
+        "<parent xmlns='urn:example:ns1'><child foo=''/></parent>",
+    )
+}
+
 #[test]
 fn optional_attribute_extract_roundtrip_absent() {
     #[allow(unused_imports)]