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

Function text_data

nodedb-codec/src/rans.rs:368–377  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

366
367 #[test]
368 fn text_data() {
369 let text = b"the quick brown fox jumps over the lazy dog. ";
370 let data: Vec<u8> = text.iter().copied().cycle().take(10_000).collect();
371 let encoded = encode(&data);
372 let decoded = decode(&encoded).unwrap();
373 assert_eq!(decoded, data);
374
375 let ratio = data.len() as f64 / encoded.len() as f64;
376 assert!(ratio > 1.5, "text should compress >1.5x, got {ratio:.1}x");
377 }
378
379 #[test]
380 fn uniform_random_data() {

Callers

nothing calls this directly

Calls 6

collectMethod · 0.80
encodeFunction · 0.70
decodeFunction · 0.70
takeMethod · 0.45
iterMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected