()
| 83 | |
| 84 | #[test] |
| 85 | fn 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] |
| 117 | fn test_read() { |
nothing calls this directly
no test coverage detected