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

Function test_subarray

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

Source from the content-addressed store, hash-verified

865
866 #[tokio::test]
867 async fn test_subarray() {
868 test_async_with(|ctx| {
869 Box::pin(async move {
870 init(&ctx).unwrap();
871 ModuleEvaluator::eval_rust::<BufferModule>(ctx.clone(), "buffer")
872 .await
873 .unwrap();
874
875 let data = "hello world".to_string().into_bytes();
876 let module = ModuleEvaluator::eval_js(
877 ctx.clone(),
878 "test",
879 r#"
880 import { Buffer } from 'buffer';
881
882 export async function test(data) {
883 let buffer = Buffer.from(data);
884 let sub = buffer.subarray(6, 11); // "world" part
885 return sub.toString();
886 }
887 "#,
888 )
889 .await
890 .unwrap();
891 let result = call_test::<String, _>(&ctx, &module, (data,)).await;
892 assert_eq!(result, "world");
893 })
894 })
895 .await;
896 }
897
898 #[tokio::test]
899 async fn test_subarray_partial() {

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