MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / random_access_block

Function random_access_block

nodedb-codec/src/lz4.rs:319–334  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

317
318 #[test]
319 fn random_access_block() {
320 let data: Vec<u8> = (0..20000).map(|i| (i % 256) as u8).collect();
321 let block_size = 4096;
322 let encoded = encode_with_block_size(&data, block_size);
323
324 let block_count = Lz4Decoder::block_count(&encoded).unwrap();
325 assert_eq!(block_count, data.len().div_ceil(block_size));
326
327 // Decompress each block individually and verify.
328 let mut reassembled = Vec::new();
329 for i in 0..block_count {
330 let block = decode_block(&encoded, i).unwrap();
331 reassembled.extend_from_slice(&block);
332 }
333 assert_eq!(reassembled, data);
334 }
335
336 #[test]
337 fn out_of_range_block_index() {

Callers

nothing calls this directly

Calls 4

encode_with_block_sizeFunction · 0.85
block_countFunction · 0.85
collectMethod · 0.80
decode_blockFunction · 0.70

Tested by

no test coverage detected