From 86ff7bafc9654ef01798104769e2d59c8ba7e4c3 Mon Sep 17 00:00:00 2001 From: mahaifeng Date: Fri, 11 Oct 2024 13:04:20 +0800 Subject: [PATCH] =?UTF-8?q?[textencoder]=E6=B7=BB=E5=8A=A0=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uni_modules/uts-tests/utssdk/TextEncoder.uts | 14 ++++++++++++++ uni_modules/uts-tests/utssdk/index.uts | 10 +++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 uni_modules/uts-tests/utssdk/TextEncoder.uts diff --git a/uni_modules/uts-tests/utssdk/TextEncoder.uts b/uni_modules/uts-tests/utssdk/TextEncoder.uts new file mode 100644 index 0000000..3b7e16d --- /dev/null +++ b/uni_modules/uts-tests/utssdk/TextEncoder.uts @@ -0,0 +1,14 @@ +import { describe, test, expect, Result } from './tests.uts' + +export function testEncoder() : Result { + return describe("TextEncoder", () => { + test('encoder', () => { + // #TEST TextEncoder.encode + const encoder = new TextEncoder() + const int8 = encoder.encode("€"); + console.log(int8); // Uint8Array(3) [226, 130, 172] + // #END + expect(int8.toString()).toEqual("226,130,172"); + }) + }) +} \ No newline at end of file diff --git a/uni_modules/uts-tests/utssdk/index.uts b/uni_modules/uts-tests/utssdk/index.uts index 1cbaadd..ccf4605 100644 --- a/uni_modules/uts-tests/utssdk/index.uts +++ b/uni_modules/uts-tests/utssdk/index.uts @@ -19,7 +19,7 @@ import { testType } from './Type.uts' export { Result } from './tests.uts' import { testArrayBuffer } from './ArrayBuffer.uts' import { testNativeCode } from './NativeCode.uts' - +import { testEncoder} from "./TextEncoder.uts" // Promise、Proxy、Reflect、Weakmap、WeakSet 不支持 export function runTests() : UTSJSONObject { @@ -45,7 +45,10 @@ export function runTests() : UTSJSONObject { // #ifdef APP-ANDROID || WEB const ArrayBufferRes = testArrayBuffer(); // #endif - const NativeCodeRes = testNativeCode(); + const NativeCodeRes = testNativeCode(); + // #ifdef APP-ANDROID || WEB + const TextEncoderRes = testEncoder(); + // #endif return { Array: ArrayRes, Date: DateRes, @@ -66,7 +69,8 @@ export function runTests() : UTSJSONObject { console: consoleRes, UTSJSONObject: UTSJSONObjectRes, // #ifdef APP-ANDROID || WEB - ArrayBuffer: ArrayBufferRes, + ArrayBuffer: ArrayBufferRes, + TextEncoder: TextEncoderRes, // #endif NativeCode: NativeCodeRes } -- GitLab