diff --git a/uni_modules/uts-tests/utssdk/UTSJSONObject.uts b/uni_modules/uts-tests/utssdk/UTSJSONObject.uts index f5fa83deb0c445adc3d32c8305b888a5780823ba..da74536cade7c24b1a2aa4e9e7557ae76901b62e 100644 --- a/uni_modules/uts-tests/utssdk/UTSJSONObject.uts +++ b/uni_modules/uts-tests/utssdk/UTSJSONObject.uts @@ -1,7 +1,5 @@ import { describe, test, expect, expectNumber, Result } from './tests.uts' - - export function testUTSJSONObject() : Result { return describe("utsjsonobject", () => { test('keys', () => { @@ -12,6 +10,7 @@ export function testUTSJSONObject() : Result { expect(UTSJSONObject.keys(obj).length).toEqual(2); console.log(UTSJSONObject.keys(obj)) }) + test('toJSONObject', () => { // #ifdef APP-ANDROID let result = {} @@ -36,8 +35,7 @@ export function testUTSJSONObject() : Result { // #endif }) - - + test('assign-notype', () => { // #ifdef APP-ANDROID const target = { a: 1, b: 2 }; @@ -87,6 +85,24 @@ export function testUTSJSONObject() : Result { // #endif }) + + test('get-speed', () => { + // #ifdef APP-ANDROID + const utsObj: UTSJSONObject = {} as any as UTSJSONObject + for (let i = 0; i < 100; i++) { + utsObj.set('' + i, '' + i) + } + + console.log('--start--') + let startTime = Date.now() + for (let i = 0; i < 10000; i++) { + utsObj.getString('0') + } + let spendTime = Date.now() - startTime + expect(spendTime < 300).toEqual(true); + // #endif + }) + test('assign-withtype', () => { // #ifdef APP-ANDROID type User = { @@ -102,4 +118,4 @@ export function testUTSJSONObject() : Result { // #endif }) }) -} \ No newline at end of file +}