提交 99beeed6 编写于 作者: M mahaifeng

[textencoder]添加测试用例

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