MCPcopy Create free account
hub / github.com/RustCrypto/utils / digest_pad_combinations

Function digest_pad_combinations

block-buffer/tests/mod.rs:85–114  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

83
84#[test]
85fn digest_pad_combinations() {
86 let delim = 0x80;
87 let data: [u8; 7] = array::from_fn(|i| u8::try_from(i).unwrap());
88 let suffix: [u8; 7] = array::from_fn(|i| u8::try_from(i + 0x10).unwrap());
89
90 for data_len in 0..data.len() {
91 for suffix_len in 0..suffix.len() {
92 let data = &data[..data_len];
93 let suffix = &suffix[..suffix_len];
94 let mut buf = EagerBuffer::<U8>::default();
95
96 buf.digest_blocks(data, |_| panic!("should not be called"));
97
98 let mut accum = Vec::with_capacity(2 * buf.size());
99 buf.digest_pad(delim, suffix, |block| accum.extend_from_slice(block));
100
101 assert!(accum.len() <= 2 * buf.size());
102 assert_eq!(buf.get_pos(), 0);
103
104 let (res_data, rem) = accum.split_at(data_len);
105 let (res_delim, rem) = rem.split_at(1);
106 let (res_zeros, res_suffix) = rem.split_at(rem.len() - suffix_len);
107
108 assert_eq!(res_data, data);
109 assert_eq!(res_delim, &[delim]);
110 assert!(res_zeros.iter().all(|&b| b == 0));
111 assert_eq!(res_suffix, suffix);
112 }
113 }
114}
115
116#[test]
117fn test_read() {

Callers

nothing calls this directly

Calls 7

defaultFunction · 0.85
lenMethod · 0.80
digest_blocksMethod · 0.80
digest_padMethod · 0.80
split_atMethod · 0.80
unwrapMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected