MCPcopy Create free account
hub / github.com/Ray-D-Song/lexe / test_subarray_partial

Function test_subarray_partial

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

Source from the content-addressed store, hash-verified

897
898 #[tokio::test]
899 async fn test_subarray_partial() {
900 test_async_with(|ctx| {
901 Box::pin(async move {
902 init(&ctx).unwrap();
903 ModuleEvaluator::eval_rust::<BufferModule>(ctx.clone(), "buffer")
904 .await
905 .unwrap();
906
907 let data = "hello world".to_string().into_bytes();
908 let module = ModuleEvaluator::eval_js(
909 ctx.clone(),
910 "test",
911 r#"
912 import { Buffer } from 'buffer';
913
914 export async function test(data) {
915 let buffer = Buffer.from(data);
916 let sub = buffer.subarray(0, 5); // "hello" part
917 return sub.toString();
918 }
919 "#,
920 )
921 .await
922 .unwrap();
923 let result = call_test::<String, _>(&ctx, &module, (data,)).await;
924 assert_eq!(result, "hello");
925 })
926 })
927 .await;
928 }
929
930 #[tokio::test]
931 async fn test_subarray_out_of_bounds() {

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