MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / test

Function test

src/ore/src/bytes.rs:746–764  ·  view source on GitHub ↗
(segments: Vec<Vec<u8>>, num_bytes: usize)

Source from the content-addressed store, hash-verified

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);

Callers

nothing calls this directly

Calls 14

copy_to_bytesMethod · 0.80
unwrapMethod · 0.80
seekMethod · 0.80
collectMethod · 0.45
flattenMethod · 0.45
into_iterMethod · 0.45
cloneMethod · 0.45
mapMethod · 0.45
lenMethod · 0.45
readerMethod · 0.45
maxMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected