| 8 | |
| 9 | #[test] |
| 10 | fn test_split() { |
| 11 | let mut buf = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; |
| 12 | let inout: InOutBuf<'_, '_, u8> = buf.as_mut_slice().into(); |
| 13 | |
| 14 | let expected: Vec<&[u8]> = vec![ |
| 15 | &[1, 2], |
| 16 | &[3, 4], |
| 17 | &[5, 6], |
| 18 | &[7, 8], |
| 19 | &[9, 10], |
| 20 | &[11, 12], |
| 21 | &[13, 14], |
| 22 | &[15, 16], |
| 23 | ]; |
| 24 | let mut expected = expected.into_iter(); |
| 25 | |
| 26 | let (blocks, _tail) = inout.into_chunks::<U8>(); |
| 27 | for block in blocks.into_iter() { |
| 28 | type SubBlock = Array<u8, U2>; |
| 29 | |
| 30 | let subblocks = Array::<InOut<'_, '_, SubBlock>, U4>::from(block); |
| 31 | |
| 32 | for subblock in subblocks { |
| 33 | assert_eq!(Some(subblock.get_in().as_slice()), expected.next()); |
| 34 | } |
| 35 | } |
| 36 | } |