()
| 49 | |
| 50 | #[test] |
| 51 | fn test_lazy_digest() { |
| 52 | let mut buf = LazyBuffer::<U4>::default(); |
| 53 | let inputs = [ |
| 54 | &b"01234567"[..], |
| 55 | &b"89"[..], |
| 56 | &b"abcdefghij"[..], |
| 57 | &b"klmnopqrs"[..], |
| 58 | ]; |
| 59 | let expected = [ |
| 60 | (0, &[b"0123"][..]), |
| 61 | (1, &[b"4567"][..]), |
| 62 | (2, &[b"89ab"][..]), |
| 63 | (2, &[b"cdef"][..]), |
| 64 | (3, &[b"ghij"][..]), |
| 65 | (3, &[b"klmn", b"opqr"][..]), |
| 66 | ]; |
| 67 | let exp_poses = [4, 2, 4, 1]; |
| 68 | |
| 69 | let mut n = 0; |
| 70 | for (i, input) in inputs.iter().enumerate() { |
| 71 | buf.digest_blocks(input, |b| { |
| 72 | let (j, exp) = expected[n]; |
| 73 | n += 1; |
| 74 | assert_eq!(i, j); |
| 75 | assert_eq!(b.len(), exp.len()); |
| 76 | assert!(b.iter().zip(exp.iter()).all(|v| v.0[..] == v.1[..])); |
| 77 | }); |
| 78 | assert_eq!(exp_poses[i], buf.get_pos()); |
| 79 | } |
| 80 | assert_eq!(buf.pad_with_zeros()[..], b"s\0\0\0"[..]); |
| 81 | assert_eq!(buf.get_pos(), 0); |
| 82 | } |
| 83 | |
| 84 | #[test] |
| 85 | fn digest_pad_combinations() { |
nothing calls this directly
no test coverage detected