()
| 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() { |
nothing calls this directly
no test coverage detected