diff --git a/uni_modules/uts-tests/utssdk/TextEncoder.uts b/uni_modules/uts-tests/utssdk/TextEncoder.uts new file mode 100644 index 0000000000000000000000000000000000000000..3b7e16d251065e454dddf1d35a7cacdede45901c --- /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 1cbaadd983caf4729788504fb9ec04b2744da2e9..ccf4605719ac0ca191baf8b1b6a5a1a3a4964b66 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 }