()
| 181 | /// extract_path must never panic, returning None on truncated input. |
| 182 | #[test] |
| 183 | fn fuzz_truncated_buffers() { |
| 184 | let docs = [ |
| 185 | json!({"name": "alice", "age": 30, "active": true}), |
| 186 | json!({"address": {"city": "tokyo", "zip": "100-0001"}}), |
| 187 | json!({"scores": [10, 20, 30], "ratio": 0.95}), |
| 188 | ]; |
| 189 | |
| 190 | for doc in &docs { |
| 191 | let full = encode(doc); |
| 192 | for truncate_at in 0..full.len() { |
| 193 | let slice = &full[..truncate_at]; |
| 194 | let _ = extract_field(slice, 0, "name"); |
| 195 | let _ = extract_field(slice, 0, "age"); |
| 196 | let _ = extract_field(slice, 0, "missing"); |
| 197 | let _ = extract_path(slice, 0, &["address", "city"]); |
| 198 | let _ = extract_dot_path(slice, 0, "address.city"); |
| 199 | } |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | /// Deterministic random byte sequences — extract_field must never panic. |
| 204 | #[test] |
nothing calls this directly
no test coverage detected