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

This commit is contained in:
xmppftw 2024-08-04 17:27:41 +02:00 committed by Jonas Schäfer
parent b3fd0b5372
commit aa26d98e2a

View file

@ -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)]