diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /third_party/rust/sha2/tests/mod.rs | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/sha2/tests/mod.rs')
-rw-r--r-- | third_party/rust/sha2/tests/mod.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/third_party/rust/sha2/tests/mod.rs b/third_party/rust/sha2/tests/mod.rs new file mode 100644 index 0000000000..91df4683b7 --- /dev/null +++ b/third_party/rust/sha2/tests/mod.rs @@ -0,0 +1,35 @@ +use digest::dev::{feed_rand_16mib, fixed_reset_test}; +use digest::new_test; +use hex_literal::hex; +use sha2::{Digest, Sha224, Sha256, Sha384, Sha512, Sha512_224, Sha512_256}; + +new_test!(sha224_main, "sha224", Sha224, fixed_reset_test); +new_test!(sha256_main, "sha256", Sha256, fixed_reset_test); +new_test!(sha512_224_main, "sha512_224", Sha512_224, fixed_reset_test); +new_test!(sha512_256_main, "sha512_256", Sha512_256, fixed_reset_test); +new_test!(sha384_main, "sha384", Sha384, fixed_reset_test); +new_test!(sha512_main, "sha512", Sha512, fixed_reset_test); + +#[test] +fn sha256_rand() { + let mut h = Sha256::new(); + feed_rand_16mib(&mut h); + assert_eq!( + h.finalize()[..], + hex!("45f51fead87328fe837a86f4f1ac0eb15116ab1473adc0423ef86c62eb2320c7")[..] + ); +} + +#[test] +#[rustfmt::skip] +fn sha512_rand() { + let mut h = Sha512::new(); + feed_rand_16mib(&mut h); + assert_eq!( + h.finalize()[..], + hex!(" + 9084d75a7c0721541d737b6171eb465dc9ba08a119a182a8508484aa27a176cd + e7c2103b108393eb024493ced4aac56be6f57222cac41b801f11494886264997 + ")[..] + ); +} |