diff --git a/src/attention.rs b/src/attention.rs index c53040c4..333d1900 100644 --- a/src/attention.rs +++ b/src/attention.rs @@ -25,6 +25,9 @@ impl TryFrom for Attention { for _ in elem.children() { return Err(Error::ParseError("Unknown child in attention element.")); } + for _ in elem.attrs() { + return Err(Error::ParseError("Unknown attribute in attention element.")); + } Ok(Attention) } } @@ -61,6 +64,17 @@ mod tests { assert_eq!(message, "Unknown child in attention element."); } + #[test] + fn test_invalid_attribute() { + let elem: Element = "".parse().unwrap(); + let error = Attention::try_from(elem).unwrap_err(); + let message = match error { + Error::ParseError(string) => string, + _ => panic!(), + }; + assert_eq!(message, "Unknown attribute in attention element."); + } + #[test] fn test_serialise() { let elem: Element = "".parse().unwrap();