()
| 323 | |
| 324 | #[test] |
| 325 | fn decode_incomplete_data() { |
| 326 | // Setup |
| 327 | let mut decoder = JsonLinesDecoder::<TestItem>::new(); |
| 328 | |
| 329 | // Create incomplete JSON (missing closing quote and brace) |
| 330 | let mut buffer = BytesMut::from(&br#"{"id":1,"name":"incomplete"#[..]); |
| 331 | |
| 332 | // Without a newline, the decoder should return None |
| 333 | let result = decoder |
| 334 | .decode(&mut buffer) |
| 335 | .expect("should handle incomplete data without error"); |
| 336 | assert!(result.is_none(), "Should not decode without newline"); |
| 337 | |
| 338 | // Add the closing quote, brace, and newline |
| 339 | buffer.extend_from_slice(b"\"}\n"); |
| 340 | |
| 341 | // Now it should decode successfully |
| 342 | let result = decoder |
| 343 | .decode(&mut buffer) |
| 344 | .expect("should successfully decode"); |
| 345 | assert!(result.is_some(), "Should decode complete data"); |
| 346 | let item = result.expect("should have a decoded item"); |
| 347 | assert_eq!(item.id, 1); |
| 348 | assert_eq!(item.name, "incomplete"); |
| 349 | } |
| 350 | |
| 351 | #[test] |
| 352 | fn max_length() { |
nothing calls this directly
no test coverage detected