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

Function overlap_produces_shared_chars

nodedb-query/src/chunk_text.rs:466–483  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

464
465 #[test]
466 fn overlap_produces_shared_chars() {
467 let text = "0123456789abcdef";
468 let chunks = chunk_text(text, 8, 4, ChunkStrategy::Character).unwrap();
469 // step = 4. chunk0=[0..8], chunk1=[4..12], chunk2=[8..16]
470 assert_eq!(chunks.len(), 3);
471 // Overlap: last 4 chars of chunk 0 == first 4 chars of chunk 1.
472 let c0_tail: String = chunks[0]
473 .text
474 .chars()
475 .rev()
476 .take(4)
477 .collect::<Vec<_>>()
478 .into_iter()
479 .rev()
480 .collect();
481 let c1_head: String = chunks[1].text.chars().take(4).collect();
482 assert_eq!(c0_tail, c1_head);
483 }
484}

Callers

nothing calls this directly

Calls 3

chunk_textFunction · 0.85
collectMethod · 0.80
takeMethod · 0.45

Tested by

no test coverage detected