提交 86ff7baf 编写于 作者: M mahaifeng

[textencoder]添加测试用例

上级 4056fb2f
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
...@@ -19,7 +19,7 @@ import { testType } from './Type.uts' ...@@ -19,7 +19,7 @@ import { testType } from './Type.uts'
export { Result } from './tests.uts' export { Result } from './tests.uts'
import { testArrayBuffer } from './ArrayBuffer.uts' import { testArrayBuffer } from './ArrayBuffer.uts'
import { testNativeCode } from './NativeCode.uts' import { testNativeCode } from './NativeCode.uts'
import { testEncoder} from "./TextEncoder.uts"
// Promise、Proxy、Reflect、Weakmap、WeakSet 不支持 // Promise、Proxy、Reflect、Weakmap、WeakSet 不支持
export function runTests() : UTSJSONObject { export function runTests() : UTSJSONObject {
...@@ -46,6 +46,9 @@ export function runTests() : UTSJSONObject { ...@@ -46,6 +46,9 @@ export function runTests() : UTSJSONObject {
const ArrayBufferRes = testArrayBuffer(); const ArrayBufferRes = testArrayBuffer();
// #endif // #endif
const NativeCodeRes = testNativeCode(); const NativeCodeRes = testNativeCode();
// #ifdef APP-ANDROID || WEB
const TextEncoderRes = testEncoder();
// #endif
return { return {
Array: ArrayRes, Array: ArrayRes,
Date: DateRes, Date: DateRes,
...@@ -67,6 +70,7 @@ export function runTests() : UTSJSONObject { ...@@ -67,6 +70,7 @@ export function runTests() : UTSJSONObject {
UTSJSONObject: UTSJSONObjectRes, UTSJSONObject: UTSJSONObjectRes,
// #ifdef APP-ANDROID || WEB // #ifdef APP-ANDROID || WEB
ArrayBuffer: ArrayBufferRes, ArrayBuffer: ArrayBufferRes,
TextEncoder: TextEncoderRes,
// #endif // #endif
NativeCode: NativeCodeRes NativeCode: NativeCodeRes
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册