MCPcopy Create free account
hub / github.com/hashintel/hash / decode_with_very_large_input

Function decode_with_very_large_input

libs/@local/codec/src/bytes.rs:416–441  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

414
415 #[test]
416 fn decode_with_very_large_input() {
417 // Setup
418 let mut decoder = JsonLinesDecoder::<TestItem>::new();
419
420 // Create a large name (10KB)
421 let large_name = "x".repeat(10_000);
422 let test_item = TestItem {
423 id: 999,
424 name: large_name.clone(),
425 };
426
427 // Serialize to JSON manually
428 let mut json =
429 serde_json::to_string(&test_item).expect("should successfully serialize test item");
430 json.push('\n');
431 let mut buffer = BytesMut::from(json.as_bytes());
432
433 // Decode
434 let result = decoder
435 .decode(&mut buffer)
436 .expect("should successfully decode large input");
437 assert!(result.is_some(), "Should decode large input");
438 let item = result.expect("should have a decoded item");
439 assert_eq!(item.id, 999);
440 assert_eq!(item.name, large_name);
441 }
442}

Callers

nothing calls this directly

Calls 6

pushMethod · 0.65
fromFunction · 0.50
cloneMethod · 0.45
expectMethod · 0.45
as_bytesMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected