提交 89efe926 编写于 作者: M mahaifeng

[textdecoder]添加textdecoder测试用例

上级 488fe7ea
import { describe, test, expect, Result } from './tests.uts'
export function testDecoder() : Result {
return describe("TextDecoder", () => {
test('decoder', () => {
// #TEST TextDecoder.decode
var utf8decoder = new TextDecoder(); // default 'utf-8' or 'utf8'
var u8arr = Uint8Array.of(240, 160, 174, 183);
var i8arr = Int8Array.of(-16, -96, -82, -73);
expect(utf8decoder.decode(u8arr)).toEqual('𠮷')
expect(utf8decoder.decode(i8arr)).toEqual('𠮷')
utf8decoder = new TextDecoder("gbk"); // default 'utf-8' or 'utf8'
expect(utf8decoder.decode(u8arr)).toEqual('馉');
expect(utf8decoder.decode(i8arr)).toEqual('馉')
utf8decoder = new TextDecoder("utf-8");
var arraybuffer = new ArrayBuffer(4)
var dataView = new DataView(arraybuffer)
dataView.setInt8(0, -16)
dataView.setInt8(1, -96)
dataView.setInt8(2, -82)
dataView.setInt8(3, -73)
expect(utf8decoder.decode(dataView)).toEqual('𠮷');
// #END
})
})
}
\ No newline at end of file
...@@ -21,6 +21,7 @@ import { testArrayBuffer } from './ArrayBuffer.uts' ...@@ -21,6 +21,7 @@ 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" import { testEncoder} from "./TextEncoder.uts"
import { testDecoder} from "./TextDecoder.uts"
// Proxy、Reflect、Weakmap、WeakSet 不支持 // Proxy、Reflect、Weakmap、WeakSet 不支持
export function runTests() : UTSJSONObject { export function runTests() : UTSJSONObject {
const ArrayRes = testArray(); const ArrayRes = testArray();
...@@ -49,6 +50,7 @@ export function runTests() : UTSJSONObject { ...@@ -49,6 +50,7 @@ export function runTests() : UTSJSONObject {
const PromiseRes = testPromise(); const PromiseRes = testPromise();
// #ifdef APP-ANDROID || WEB // #ifdef APP-ANDROID || WEB
const TextEncoderRes = testEncoder(); const TextEncoderRes = testEncoder();
const TextDecoderRes = testDecoder();
// #endif // #endif
return { return {
Array: ArrayRes, Array: ArrayRes,
...@@ -72,6 +74,7 @@ export function runTests() : UTSJSONObject { ...@@ -72,6 +74,7 @@ export function runTests() : UTSJSONObject {
// #ifdef APP-ANDROID || WEB // #ifdef APP-ANDROID || WEB
ArrayBuffer: ArrayBufferRes, ArrayBuffer: ArrayBufferRes,
TextEncoder: TextEncoderRes, TextEncoder: TextEncoderRes,
TextDecoder: TextDecoderRes,
// #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.
先完成此消息的编辑!
想要评论请 注册