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

Function test_utf_8

modules/llrt_string_decoder/src/lib.rs:47–77  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

45
46 #[tokio::test]
47 async fn test_utf_8() {
48 test_async_with(|ctx| {
49 Box::pin(async move {
50 llrt_buffer::init(&ctx).unwrap();
51 ModuleEvaluator::eval_rust::<StringDecoderModule>(ctx.clone(), "string_decoder")
52 .await
53 .unwrap();
54
55 let module = ModuleEvaluator::eval_js(
56 ctx.clone(),
57 "test",
58 r#"
59 import { StringDecoder } from 'string_decoder';
60
61 export async function test() {
62 const decoder = new StringDecoder('utf-8');
63
64 const cent = Buffer.from([0xC2, 0xA2]);
65
66 return decoder.write(cent);
67 }
68 "#,
69 )
70 .await
71 .unwrap();
72 let result = call_test::<String, _>(&ctx, &module, ()).await;
73 assert_eq!(result, "¢");
74 })
75 })
76 .await;
77 }
78
79 #[tokio::test]
80 async fn test_utf8_byte_by_byte() {

Callers

nothing calls this directly

Calls 3

test_async_withFunction · 0.85
initFunction · 0.50
cloneMethod · 0.45

Tested by

no test coverage detected