(segments: Vec<Vec<u8>>, num_bytes: usize)
| 744 | #[cfg_attr(miri, ignore)] // slow |
| 745 | fn proptest_copy_to_bytes() { |
| 746 | fn test(segments: Vec<Vec<u8>>, num_bytes: usize) { |
| 747 | let contiguous: Vec<u8> = segments.clone().into_iter().flatten().collect(); |
| 748 | let mut contiguous = Bytes::from(contiguous); |
| 749 | let mut segmented: SegmentedBytes = segments.into_iter().map(Bytes::from).collect(); |
| 750 | |
| 751 | // Cap num_bytes at the size of contiguous. |
| 752 | let num_bytes = contiguous.len() % num_bytes; |
| 753 | let remaining = contiguous.len() - num_bytes; |
| 754 | |
| 755 | let copied_c = contiguous.copy_to_bytes(num_bytes); |
| 756 | let copied_s = segmented.copy_to_bytes(num_bytes); |
| 757 | |
| 758 | assert_eq!(copied_c, copied_s); |
| 759 | |
| 760 | let copied_c = contiguous.copy_to_bytes(remaining); |
| 761 | let copied_s = segmented.copy_to_bytes(remaining); |
| 762 | |
| 763 | assert_eq!(copied_c, copied_s); |
| 764 | } |
| 765 | |
| 766 | proptest!(|(segments in any::<Vec<Vec<u8>>>(), num_bytes in any::<usize>())| { |
| 767 | test(segments, num_bytes); |
nothing calls this directly
no test coverage detected