From 99beeed62e48310d2db5c13763fdcc0da35e8e4a Mon Sep 17 00:00:00 2001 From: mahaifeng Date: Thu, 19 Sep 2024 18:01:13 +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 8cf98cc..7528c7d 100644 --- a/uni_modules/uts-tests/utssdk/index.uts +++ b/uni_modules/uts-tests/utssdk/index.uts @@ -20,7 +20,7 @@ export { Result } from './tests.uts' import { testArrayBuffer } from './ArrayBuffer.uts' import { testNativeCode } from './NativeCode.uts' import { testPromise} from "./Promise.uts" - +import { testEncoder} from "./TextEncoder.uts" // Proxy、Reflect、Weakmap、WeakSet 不支持 export function runTests() : UTSJSONObject { const ArrayRes = testArray(); @@ -46,7 +46,10 @@ export function runTests() : UTSJSONObject { const ArrayBufferRes = testArrayBuffer(); // #endif const NativeCodeRes = testNativeCode(); - const PromiseRes = testPromise(); + const PromiseRes = testPromise(); + // #ifdef APP-ANDROID || WEB + const TextEncoderRes = testEncoder(); + // #endif return { Array: ArrayRes, Date: DateRes, @@ -67,7 +70,8 @@ export function runTests() : UTSJSONObject { console: consoleRes, UTSJSONObject: UTSJSONObjectRes, // #ifdef APP-ANDROID || WEB - ArrayBuffer: ArrayBufferRes, + ArrayBuffer: ArrayBufferRes, + TextEncoder: TextEncoderRes, // #endif NativeCode: NativeCodeRes, Primise: PromiseRes -- GitLab