more tests
This commit is contained in:
parent
cf172f0bde
commit
4f74c26e15
19
src/lib.rs
19
src/lib.rs
|
@ -167,9 +167,22 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn bad_format() {
|
fn bad_format() {
|
||||||
let value = "sha384";
|
let values = [
|
||||||
let integrity = Integrity::try_from(value);
|
"sha384",
|
||||||
assert_eq!(integrity.unwrap_err(), Error::InvalidSRIFormat);
|
"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]
|
#[test]
|
||||||
|
|
Loading…
Reference in a new issue