| 208 | /// never panic; it should return None on truncated input. |
| 209 | #[test] |
| 210 | fn fuzz_truncated_buffers() { |
| 211 | let docs = [ |
| 212 | json!({"name": "alice", "age": 30, "score": 9.5}), |
| 213 | json!({"a": 1, "b": 2, "c": 3, "d": 4, "e": 5}), |
| 214 | json!({"nested": {"inner": 42}}), |
| 215 | ]; |
| 216 | |
| 217 | for doc in &docs { |
| 218 | let full = encode(doc); |
| 219 | for truncate_at in 0..full.len() { |
| 220 | let slice = &full[..truncate_at]; |
| 221 | // Must not panic — None is the valid outcome for truncated data. |
| 222 | let _ = FieldIndex::build(slice, 0); |
| 223 | } |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | /// Deterministic random byte sequences — FieldIndex::build must never panic. |
| 228 | #[test] |