From 4f74c26e15a0e7a69d993b4761aec665fe8b8a8a Mon Sep 17 00:00:00 2001 From: kitsunecafe Date: Sat, 5 Oct 2024 18:15:44 -0500 Subject: [PATCH] more tests --- src/lib.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 2c63fa1..4861751 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -167,9 +167,22 @@ mod test { #[test] fn bad_format() { - let value = "sha384"; - let integrity = Integrity::try_from(value); - assert_eq!(integrity.unwrap_err(), Error::InvalidSRIFormat); + let values = [ + "sha384", + "sha384=o9w34t98ywhutkjwgjiaroakl", + "ml,goxu904t8y9 sha256olkwtgw,.rt gmwl tow3t", + "sha512,wa.rtgtliworh gtnkrlgtmw", + ]; + + let invalid_sri = values.map(Integrity::try_from); + + for integrity in invalid_sri { + assert_eq!(integrity.unwrap_err(), Error::InvalidSRIFormat); + } + + let undecodable = "sha384-AAAAAAA"; + let integrity = Integrity::try_from(undecodable); + assert!(matches!(integrity.unwrap_err(), Error::UnableToDecode(_))); } #[test]