Skip to content

Commit

Permalink
add: refers_element_field_implementation test
Browse files Browse the repository at this point in the history
  • Loading branch information
kurotakazuki committed May 5, 2024
1 parent 3931b54 commit e27bf16
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion xml_schema_derive/src/xsd/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ mod tests {

#[test]
fn refers_element_field_implementation() {
//
// <xs:element ref="OwnedType" />
let element = Element {
name: "".to_string(),
kind: None,
Expand All @@ -298,5 +298,26 @@ mod tests {
.unwrap();

assert_eq!(implementation.to_string(), expected.to_string());

// <xs:element ref="OwnedType" minOccurs="0" maxOccurs="unbounded" />
let element = Element {
name: "".to_string(),
kind: None,
refers: Some("OwnedType".to_string()),
min_occurences: Some(0),
max_occurences: Some(MaxOccurences::Unbounded),
complex_type: None,
simple_type: None,
annotation: None,
};

let implementation = element.get_field_implementation(&context, &None);

let expected = TokenStream::from_str(&format!(
r#"#[yaserde(rename = "OwnedType")] pub owned_type_list : Vec < xml_schema_types :: OwnedType > ,"#
))
.unwrap();

assert_eq!(implementation.to_string(), expected.to_string());
}
}

0 comments on commit e27bf16

Please sign in to comment.