MCPcopy Create free account
hub / github.com/awslabs/llrt / test_subarray_out_of_bounds

Function test_subarray_out_of_bounds

modules/llrt_buffer/src/buffer.rs:940–969  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

938 assert_eq!(result, "world");
939 })
940 })
941 .await;
942 }
943
944 #[tokio::test]
945 async fn test_subarray_partial() {
946 test_async_with(|ctx| {
947 Box::pin(async move {
948 crate::init(&ctx).unwrap();
949 ModuleEvaluator::eval_rust::<BufferModule>(ctx.clone(), "buffer")
950 .await
951 .unwrap();
952
953 let data = "hello world".to_string().into_bytes();
954 let module = ModuleEvaluator::eval_js(
955 ctx.clone(),
956 "test",
957 r#"
958 import { Buffer } from 'buffer';
959
960 export async function test(data) {
961 let buffer = Buffer.from(data);
962 let sub = buffer.subarray(0, 5); // "hello" part
963 return sub.toString();
964 }
965 "#,
966 )
967 .await
968 .unwrap();
969 let result = call_test::<String, _>(&ctx, &module, (data,)).await;
970 assert_eq!(result, "hello");
971 })
972 })

Callers

nothing calls this directly

Calls 5

test_async_withFunction · 0.85
into_bytesMethod · 0.80
initFunction · 0.70
cloneMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected