提交 7fb1f2dc 编写于 作者: H hu0475

完成commonlibrary子系统process,lightweightmap,linkedlist模块的跨平台测试套

Signed-off-by: Nhu0475 <huyanqiang5@huawei.com>
上级 cca3df90
......@@ -29,6 +29,9 @@ group("crossplatform") {
"commonlibrarytreesetetstest:ActsCrossplatformTreeSetTest",
"commonlibraryurietstest:ActsCrossplatformUriTest",
"commonlibraryurletstest:ActsCrossplatformUrlTest",
"commonlibraryutiletstest:ActsCrossplatformLightWeightMapTest",
"commonlibraryutiletstest:ActsCrossplatformLinkedListTest",
"commonlibraryutiletstest:ActsCrossplatformProcessTest",
"commonlibraryutiletstest:ActsCrossplatformUtilTest",
]
}
......
{
"app": {
"bundleName": "ohos.acts.commonlibrary.crossplatform.LightWeightMap.normal",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"minAPIVersion": 10,
"targetAPIVersion": 10,
"car": {
"apiCompatibleVersion": 10,
"singleUser": false
}
}
}
# Copyright (C) 2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsCrossplatformLightWeightMapTest") {
hap_profile = "src/main/module.json"
deps = [
":windowStage_js_assets",
":windowStage_resources",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
# hap_name: HAP的名字,可选,默认为目标名
hap_name = "ActsCrossplatformLightWeightMapTest"
subsystem_name = "commonlibrary"
part_name = "ets_utils"
}
ohos_app_scope("windowStage_app_profile") {
# app_profile: HAP的AppScope中的app.json,只在Stage模型下使用
app_profile = "AppScope/app.json"
# sources: 资源文件路径
sources = [ "AppScope/resources" ]
}
ohos_js_assets("windowStage_js_assets") {
# source_dir: js或ets代码路径,兼容FA模型的单ability配置到ability目录
source_dir = "src/main/ets"
}
ohos_resources("windowStage_resources") {
# sources: 资源文件路径
sources = [ "src/main/resources" ]
# deps: 当前目标的依赖
deps = [ ":windowStage_app_profile" ]
# hap_profile: HAP的config.json,Stage模型对应module.json
hap_profile = "src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "60000",
"shell-timeout": "60000",
"bundle-name": "ohos.acts.commonlibrary.crossplatform.LightWeightMap.normal",
"module-name": "entry_test"
},
"kits": [
{
"test-file-name": [
"ActsCrossplatformLightWeightMapTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License')
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import UIAbility from '@ohos.app.ability.UIAbility';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
import hilog from '@ohos.hilog';
import { Hypium } from '@ohos/hypium';
import testsuite from '../test/List.test';
import window from '@ohos.window';
export default class TestAbility extends UIAbility {
onCreate(want, launchParam) {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate');
hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? '');
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!');
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy');
}
onWindowStageCreate(windowStage: window.WindowStage) {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate');
windowStage.loadContent('TestAbility/pages/Index', (err, data) => {
if (err.code) {
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s',
JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy');
}
onForeground() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground');
}
onBackground() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground');
}
}
\ No newline at end of file
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import hilog from '@ohos.hilog';
@Entry
@Component
struct Index {
aboutToAppear() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear');
}
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(()=>{
})
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
import hilog from '@ohos.hilog';
import TestRunner from '@ohos.application.testRunner';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
async function onAbilityCreateCallback() {
hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err: any) {
hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');
}
async onRun() {
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run');
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName
var debug = abilityDelegatorArguments.parameters['-D']
if (debug == 'true')
{
cmd += ' -D'
}
hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd);
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? '');
})
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end');
}
}
\ No newline at end of file
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License')
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import LightWeightMap from "@ohos.util.LightWeightMap";
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
export default function LightWeightMapTest() {
describe("LightWeightMapTest", function () {
/**
* @tc.number: TEST_CONSTRUCTOR_001
* @tc.name: testConstructor001
* @tc.desc: Create an LightWeightMap instance. For example: let lightWeightMap = new LightWeightMap().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testConstructor001", 0, function () {
try {
let lightWeightMap = new LightWeightMap();
expect(lightWeightMap != undefined).assertEqual(true);
} catch (err) {
expect(err.name).assertEqual("BusinessError");
expect(err.code).assertEqual(10200012);
expect(err.message).assertEqual("The LightWeightMap's constructor cannot be directly invoked");
}
});
/**
* @tc.number: TEST_LENGTH_001
* @tc.name: testLength001
* @tc.desc: Get the number of key value pairs in the lightWeightMap instance. For example: lightWeightMap.length.
* @tc.size: MediumTest
* @tc.type: Field
* @tc.level: level 1
*/
it("testLength001", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
lightWeightMap.set(3, "C");
lightWeightMap.set(4, "D");
lightWeightMap.set(5, "E");
let res = lightWeightMap.length;
expect(res).assertEqual(5);
});
/**
* @tc.number: TEST_HASALL_001
* @tc.name: testHasAll001
* @tc.desc: Judge whether a lightweightmap contains all key value pairs in another lightweightmap.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testHasAll001", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("a", "A");
lightWeightMap.set("b", "B");
lightWeightMap.set("c", "C");
lightWeightMap.set("d", "D");
lightWeightMap.set("e", "E");
let lightWeightMap1 = new LightWeightMap();
lightWeightMap1.set("a", "A");
lightWeightMap1.set("d", "D");
let res = lightWeightMap.hasAll(lightWeightMap1);
expect(res).assertEqual(true);
});
/**
* @tc.number: TEST_HASALL_002
* @tc.name: testHasAll002
* @tc.desc: Judge whether a lightweightmap contains all key value pairs in another lightweightmap.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testHasAll002", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("a", "A");
lightWeightMap.set("b", "B");
lightWeightMap.set("c", "C");
lightWeightMap.set("d", "D");
lightWeightMap.set("e", "E");
let lightWeightMap1 = new LightWeightMap();
lightWeightMap1.set("a1", "A1");
lightWeightMap1.set("d1", "D1");
let res = lightWeightMap.hasAll(lightWeightMap1);
expect(res).assertEqual(false);
});
/**
* @tc.number: TEST_HASALL_003
* @tc.name: testHasAll003
* @tc.desc: Judge whether a lightweightmap contains all key value pairs in another lightweightmap.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testHasAll003", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("a", "A");
lightWeightMap.set("b", "B");
lightWeightMap.set("c", "C");
lightWeightMap.set("d", "D");
lightWeightMap.set("e", "E");
let lightWeightMap1 = new LightWeightMap();
lightWeightMap1.set("a", "A1");
lightWeightMap1.set("d", "D1");
let res = lightWeightMap.hasAll(lightWeightMap1);
expect(res).assertEqual(false);
});
/**
* @tc.number: TEST_HASALL_004
* @tc.name: testHasAll004
* @tc.desc: Judge whether a lightweightmap contains all key value pairs in another lightweightmap.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testHasAll004", 0, function () {
let lightWeightMap = new LightWeightMap();
let lightWeightMap1 = new LightWeightMap();
let res = lightWeightMap.hasAll(lightWeightMap1);
expect(res).assertEqual(true);
});
/**
* @tc.number: TEST_HASALL_005
* @tc.name: testHasAll005
* @tc.desc: Judge whether a lightweightmap contains all key value pairs in another lightweightmap.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testHasAll005", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("a", "A");
lightWeightMap.set("b", "B");
lightWeightMap.set("c", "C");
lightWeightMap.set("d", "D");
lightWeightMap.set("e", "E");
let lightWeightMap1 = new LightWeightMap();
lightWeightMap1.set("a", "A");
lightWeightMap1.set("d", "D1");
let res = lightWeightMap.hasAll(lightWeightMap1);
expect(res).assertEqual(false);
});
/**
* @tc.number: TEST_HASALL_006
* @tc.name: testHasAll006
* @tc.desc: Judge whether a lightweightmap contains all key value pairs in another lightweightmap.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testHasAll006", 0, function () {
let lightWeightMap = new LightWeightMap();
try {
//@ts-ignore
lightWeightMap.hasAll([1, 2, 3]);
expect(true).assertEqual(false);
} catch (err) {
expect(err.name).assertEqual("BusinessError");
expect(err.code).assertEqual(401);
expect(err.message).assertEqual(`The type of "map" must be LightWeightMap. Received value is: 1,2,3`);
}
});
/**
* @tc.number: TEST_HASKEY_001
* @tc.name: testHasKey001
* @tc.desc: Determine whether the LightWeightMap contains the specified key. For example: lightWeightMap.hasKey("a").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testHasKey001", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("a", "A");
lightWeightMap.set("b", "B");
lightWeightMap.set("c", "C");
lightWeightMap.set("d", "D");
lightWeightMap.set("e", "E");
let res = lightWeightMap.hasKey("a");
expect(res).assertEqual(true);
let res1 = lightWeightMap.hasKey(1);
expect(res1).assertEqual(false);
});
/**
* @tc.number: TEST_HASVALUE_001
* @tc.name: testHasValue001
* @tc.desc: Determine whether the LightWeightMap contains the specified value.
* For example: lightWeightMap.hasValue("A").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testHasValue001", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("a", "A");
lightWeightMap.set("b", "B");
lightWeightMap.set("c", "C");
lightWeightMap.set("d", "D");
lightWeightMap.set("e", "E");
let res = lightWeightMap.hasValue("A");
expect(res).assertEqual(true);
let res1 = lightWeightMap.hasValue(1);
expect(res1).assertEqual(false);
});
/**
* @tc.number: TEST_INCREASECAPACITYTO_001
* @tc.name: testIncreaseCapacityTo001
* @tc.desc: Expand the LightWeightMap instance capacity to the specified value.
* For example: lightWeightMap.increaseCapacityTo(3).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testIncreaseCapacityTo001", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("a", "A");
lightWeightMap.set("b", "B");
lightWeightMap.set("c", "C");
lightWeightMap.set("d", "D");
lightWeightMap.set("e", "E");
lightWeightMap.increaseCapacityTo(3);
let length = lightWeightMap.length;
expect(length).assertEqual(5);
});
/**
* @tc.number: TEST_INCREASECAPACITYTO_002
* @tc.name: testIncreaseCapacityTo002
* @tc.desc: Expand the LightWeightMap instance capacity to the specified value.
* For example: lightWeightMap.increaseCapacityTo(10).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testIncreaseCapacityTo002", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("a", "A");
lightWeightMap.set("b", "B");
lightWeightMap.set("c", "C");
lightWeightMap.set("d", "D");
lightWeightMap.set("e", "E");
let res = lightWeightMap.increaseCapacityTo(10);
expect(res).assertEqual(undefined);
});
/**
* @tc.number: TEST_INCREASECAPACITYTO_003
* @tc.name: testIncreaseCapacityTo003
* @tc.desc: Expand the LightWeightMap instance capacity to the specified value.
* For example: lightWeightMap.increaseCapacityTo("qwe").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testIncreaseCapacityTo003", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("a", "A");
lightWeightMap.set("b", "B");
lightWeightMap.set("c", "C");
lightWeightMap.set("d", "D");
lightWeightMap.set("e", "E");
try {
//@ts-ignore
lightWeightMap.increaseCapacityTo("qwe");
expect(true).assertEqual(false);
} catch (err) {
expect(err.name).assertEqual("BusinessError");
expect(err.code).assertEqual(401);
expect(err.message).assertEqual(`The type of "minimumCapacity" must be number. Received value is: qwe`);
}
});
/**
* @tc.number: TEST_ENTRIES_001
* @tc.name: testEntries001
* @tc.desc: Get all key value pairs collection in lightWeightMap.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testEntries001", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
lightWeightMap.set(3, "C");
lightWeightMap.set(4, "D");
lightWeightMap.set(5, "E");
let res = lightWeightMap.entries();
expect(JSON.stringify(res.next().value)).assertEqual('[1,"A"]');
expect(JSON.stringify(res.next().value)).assertEqual('[2,"B"]');
expect(JSON.stringify(res.next().value)).assertEqual('[3,"C"]');
expect(JSON.stringify(res.next().value)).assertEqual('[4,"D"]');
expect(JSON.stringify(res.next().value)).assertEqual('[5,"E"]');
});
/**
* @tc.number: TEST_GET_001
* @tc.name: testGet001
* @tc.desc: Get the corresponding value through the key. For example: lightWeightMap.get(4).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGet001", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
lightWeightMap.set(3, "C");
lightWeightMap.set(4, "D");
lightWeightMap.set(5, "E");
let res = lightWeightMap.get(4);
expect(res).assertEqual("D");
});
/**
* @tc.number: TEST_GET_002
* @tc.name: testGet002
* @tc.desc: Get the corresponding value through the key. For example: lightWeightMap.get(10).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGet002", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
lightWeightMap.set(3, "C");
lightWeightMap.set(4, "D");
lightWeightMap.set(5, "E");
let res = lightWeightMap.get(10);
expect(res).assertEqual(undefined);
});
/**
* @tc.number: TEST_GETINDEXOFKEY_001
* @tc.name: testGetIndexOfKey001
* @tc.desc: Find the index of the key value pair according to the corresponding key.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
* If no key is specified, return -1.
*/
it("testGetIndexOfKey001", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
lightWeightMap.set(3, "C");
lightWeightMap.set(4, "D");
lightWeightMap.set(5, "E");
let res = lightWeightMap.getIndexOfKey(2);
expect(res).assertEqual(1);
});
/**
* @tc.number: TEST_GETINDEXOFKEY_002
* @tc.name: testGetIndexOfKey002
* @tc.desc: Find the index of the key value pair according to the corresponding key.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
* If no key is specified, return -1.
*/
it("testGetIndexOfKey002", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
lightWeightMap.set(3, "C");
lightWeightMap.set(4, "D");
lightWeightMap.set(5, "E");
let res = lightWeightMap.getIndexOfKey(10);
expect(res).assertEqual(-1);
});
/**
* @tc.number: TEST_GETINDEXOFVALUE_001
* @tc.name: testGetIndexOfValue001
* @tc.desc: Find the index of the key value pair according to the corresponding value.
* If no key is specified, return -1.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGetIndexOfValue001", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
lightWeightMap.set(3, "C");
lightWeightMap.set(4, "D");
lightWeightMap.set(5, "E");
lightWeightMap.setValueAt(4, "F");
let res = lightWeightMap.getIndexOfValue("F");
expect(res).assertEqual(4);
});
/**
* @tc.number: TEST_GETINDEXOFVALUE_002
* @tc.name: testGetIndexOfValue002
* @tc.desc: Find the index of the key value pair according to the corresponding value.
* If no key is specified, return -1.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGetIndexOfValue002", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
lightWeightMap.set(3, "C");
lightWeightMap.set(4, "D");
lightWeightMap.set(5, "E");
lightWeightMap.setValueAt(4, "F");
let res = lightWeightMap.getIndexOfValue("H");
expect(res).assertEqual(-1);
});
/**
* @tc.number: TEST_ISEMPTY_001
* @tc.name: testIsEmpty001
* @tc.desc: Determine whether the LightWeightMap instance is empty. For example: lightWeightMap.isEmpty().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testIsEmpty001", 0, function () {
let lightWeightMap = new LightWeightMap();
let res1 = lightWeightMap.isEmpty();
expect(res1).assertEqual(true);
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
lightWeightMap.set(3, "C");
lightWeightMap.set(4, "D");
lightWeightMap.set(5, "E");
let res2 = lightWeightMap.isEmpty();
expect(res2).assertEqual(false);
});
/**
* @tc.number: TEST_GETKEYAT_001
* @tc.name: testGetKeyAt001
* @tc.desc: Find the key of the key value pair according to the corresponding index.
* For example: lightWeightMap.getKeyAt(1).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGetKeyAt001", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
lightWeightMap.set(3, "C");
lightWeightMap.set(4, "D");
lightWeightMap.set(5, "E");
let res = lightWeightMap.getKeyAt(1);
expect(res).assertEqual(2);
});
/**
* @tc.number: TEST_GETKEYAT_002
* @tc.name: testGetKeyAt002
* @tc.desc: Find the key of the key value pair according to the corresponding index.
* For example: lightWeightMap.getKeyAt("a").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGetKeyAt002", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
lightWeightMap.set(3, "C");
lightWeightMap.set(4, "D");
lightWeightMap.set(5, "E");
try {
//@ts-ignore
let res = lightWeightMap.getKeyAt("a");
expect(true).assertEqual(false);
} catch (err) {
expect(err.name).assertEqual("BusinessError");
expect(err.code).assertEqual(401);
expect(err.message).assertEqual(`The type of "index" must be number. Received value is: a`);
}
});
/**
* @tc.number: TEST_GETKEYAT_003
* @tc.name: testGetKeyAt003
* @tc.desc: Find the key of the key value pair according to the corresponding index.
* For example: lightWeightMap.getKeyAt(6).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGetKeyAt003", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
lightWeightMap.set(3, "C");
lightWeightMap.set(4, "D");
lightWeightMap.set(5, "E");
try {
let res = lightWeightMap.getKeyAt(6);
expect(true).assertEqual(false);
} catch (err) {
expect(err.name).assertEqual("BusinessError");
expect(err.code).assertEqual(10200001);
expect(err.message).assertEqual(`The value of "index" is out of range. It must be >= 0 && <= 4. Received value is: 6`);
}
});
/**
* @tc.number: TEST_KEYS_001
* @tc.name: testKeys001
* @tc.desc: Get a collection of all the keys in the LightWeightMap. For example: lightWeightMap.keys().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testKeys001", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
lightWeightMap.set(3, "C");
lightWeightMap.set(4, "D");
lightWeightMap.set(5, "E");
let res = lightWeightMap.keys();
expect(res.next().value).assertEqual(1);
expect(res.next().value).assertEqual(2);
expect(res.next().value).assertEqual(3);
expect(res.next().value).assertEqual(4);
expect(res.next().value).assertEqual(5);
});
/**
* @tc.number: TEST_SETALL_001
* @tc.name: testSetAll001
* @tc.desc: Copy key value pairs from one LightWeightMap to another.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testSetAll001", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
lightWeightMap.set(3, "C");
lightWeightMap.set(4, "D");
lightWeightMap.set(5, "E");
let lightWeightMap1 = new LightWeightMap();
lightWeightMap1.set(6, "A");
lightWeightMap1.set(7, "B");
lightWeightMap.setAll(lightWeightMap1);
for (let i = 1; i < 8; i++) {
expect(lightWeightMap.hasKey(i)).assertEqual(true);
}
});
/**
* @tc.number: TEST_SETALL_002
* @tc.name: testSetAll002
* @tc.desc: Copy key value pairs from one LightWeightMap to another.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testSetAll002", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
try {
//@ts-ignore
lightWeightMap.setAll([1, 2, 3]);
expect(true).assertEqual(false);
} catch (err) {
expect(err.name).assertEqual("BusinessError");
expect(err.code).assertEqual(401);
expect(err.message).assertEqual(`The type of "map" must be LightWeightMap. Received value is: 1,2,3`);
}
});
/**
* @tc.number: TEST_SET_001
* @tc.name: testSet001
* @tc.desc: Add a pair of key value pairs to the LightWeightMap. For example: lightWeightMap.set(1, "A").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testSet001", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
let res = lightWeightMap.hasValue("A");
expect(res).assertEqual(true);
let res1 = lightWeightMap.hasKey(1);
expect(res1).assertEqual(true);
});
/**
* @tc.number: TEST_SET_002
* @tc.name: testSet002
* @tc.desc: Add a pair of key value pairs to the LightWeightMap. For example: lightWeightMap.set("a", "A").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testSet002", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("a", "A");
let res = lightWeightMap.hasValue("A");
expect(res).assertEqual(true);
let res1 = lightWeightMap.hasKey("a");
expect(res1).assertEqual(true);
});
/**
* @tc.number: TEST_SET_003
* @tc.name: testSet003
* @tc.desc: Add a pair of key value pairs to the LightWeightMap. For example: lightWeightMap.set("a", "A").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testSet003", 0, function () {
let lightWeightMap = new LightWeightMap();
let a = [1, 2, 3, 4];
lightWeightMap.set(1, a);
let res = lightWeightMap.hasValue(a);
expect(res).assertEqual(true);
let res1 = lightWeightMap.hasKey(1);
expect(res1).assertEqual(true);
});
/**
* @tc.number: TEST_SET_004
* @tc.name: testSet004
* @tc.desc: Add a pair of key value pairs to the LightWeightMap.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testSet004", 0, function () {
let lightWeightMap = new LightWeightMap();
let c = {name: "lili", age: "13"};
lightWeightMap.set(1, c);
let res = lightWeightMap.hasValue(c);
expect(res).assertEqual(true);
let res1 = lightWeightMap.hasKey(1);
expect(res1).assertEqual(true);
});
/**
* @tc.number: TEST_SET_005
* @tc.name: testSet005
* @tc.desc: Add a pair of key value pairs to the LightWeightMap. For example: lightWeightMap.set(1, null).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testSet005", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, null);
let res = lightWeightMap.hasValue(null);
expect(res).assertEqual(true);
let res1 = lightWeightMap.hasKey(1);
expect(res1).assertEqual(true);
});
/**
* @tc.number: TEST_SET_006
* @tc.name: testSet006
* @tc.desc: Add a pair of key value pairs to the LightWeightMap. For example: lightWeightMap.set(null, null).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testSet006", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(null, null);
let res = lightWeightMap.hasValue(null);
expect(res).assertEqual(true);
let res1 = lightWeightMap.hasKey(null);
expect(res1).assertEqual(true);
});
/**
* @tc.number: TEST_SET_007
* @tc.name: testSet007
* @tc.desc: Add a pair of key value pairs to the LightWeightMap. For example: lightWeightMap.set(true, false).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testSet007", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(true, false);
let res = lightWeightMap.hasValue(false);
expect(res).assertEqual(true);
let res1 = lightWeightMap.hasKey(true);
expect(res1).assertEqual(true);
});
/**
* @tc.number: TEST_SET_008
* @tc.name: testSet008
* @tc.desc: Add a pair of key value pairs to the LightWeightMap. For example: lightWeightMap.set(1.23, 321).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testSet008", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1.23, 321);
let res = lightWeightMap.hasValue(321);
expect(res).assertEqual(true);
let res1 = lightWeightMap.hasKey(1.23);
expect(res1).assertEqual(true);
});
/**
* @tc.number: TEST_SET_009
* @tc.name: testSet009
* @tc.desc: Add a pair of key value pairs to the LightWeightMap.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testSet009", 0, function () {
let lightWeightMap = new LightWeightMap();
for (let i = 0; i < 100; i++) {
lightWeightMap.set(i, "A");
}
let res = lightWeightMap.get(99);
expect(res).assertEqual("A");
let res1 = lightWeightMap.length;
expect(res1).assertEqual(100);
});
/**
* @tc.number: TEST_SET_010
* @tc.name: testSet010
* @tc.desc: Add a pair of key value pairs to the LightWeightMap.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testSet010", 0, function () {
let lightWeightMap = new LightWeightMap();
for (let i = 0; i < 100; i++) {
lightWeightMap.set(1, i);
}
let res = lightWeightMap.get(1);
expect(res).assertEqual(99);
let res1 = lightWeightMap.length;
expect(res1).assertEqual(1);
});
/**
* @tc.number: TEST_SET_011
* @tc.name: testSet011
* @tc.desc: Add a pair of key value pairs to the LightWeightMap.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testSet011", 0, function () {
let lightWeightMap = new LightWeightMap();
for (let i = 0; i < 10000; i++) {
lightWeightMap.set(i, i);
}
let res1 = lightWeightMap.length;
expect(res1).assertEqual(10000);
for (let index = 0; index < 10000; index++) {
let resKey = lightWeightMap.hasKey(index);
expect(resKey).assertEqual(true);
let resValue = lightWeightMap.hasValue(index);
expect(resValue).assertEqual(true);
}
});
/**
* @tc.number: TEST_SET_012
* @tc.name: testSet012
* @tc.desc: Add a pair of key value pairs to the LightWeightMap.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testSet012", 0, function () {
let lightWeightMap = new LightWeightMap();
for (let i = 0; i < 5000; i++) {
lightWeightMap.set(i, i);
}
for (let i = -1; i > -5001; i--) {
lightWeightMap.set(i, i);
}
let res1 = lightWeightMap.length;
expect(res1).assertEqual(10000);
for (let index = 0; index < 5000; index++) {
let resKey = lightWeightMap.hasKey(index);
expect(resKey).assertEqual(true);
let resValue = lightWeightMap.hasValue(index);
expect(resValue).assertEqual(true);
}
for (let i = -1; i > -5001; i--) {
let resKey = lightWeightMap.hasKey(i);
expect(resKey).assertEqual(true);
let resValue = lightWeightMap.hasValue(i);
expect(resValue).assertEqual(true);
}
});
/**
* @tc.number: TEST_SET_013
* @tc.name: testSet013
* @tc.desc: Add a pair of key value pairs to the LightWeightMap.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testSet013", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(true, 0.001);
let res = lightWeightMap.hasValue(0.001);
expect(res).assertEqual(true);
let res1 = lightWeightMap.hasKey(true);
expect(res1).assertEqual(true);
});
/**
* @tc.number: TEST_SET_014
* @tc.name: testSet014
* @tc.desc: Add a pair of key value pairs to the LightWeightMap.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testSet014", 0, function () {
let lightWeightMap = new LightWeightMap();
let a = [1, 2, 3, 4];
lightWeightMap.set(a, 1);
let res = lightWeightMap.hasValue(1);
expect(res).assertEqual(true);
let res1 = lightWeightMap.hasKey(a);
expect(res1).assertEqual(true);
});
/**
* @tc.number: TEST_SET_015
* @tc.name: testSet015
* @tc.desc: Add a pair of key value pairs to the LightWeightMap.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testSet015", 0, function () {
let lightWeightMap = new LightWeightMap();
let a = {abc: 1};
lightWeightMap.set(a, "");
let res = lightWeightMap.hasValue("");
expect(res).assertEqual(true);
let res1 = lightWeightMap.hasKey(a);
expect(res1).assertEqual(true);
});
/**
* @tc.number: TEST_REMOVE_001
* @tc.name: testRemove001
* @tc.desc: Delete key value pairs according to key. For example: lightWeightMap.remove(3).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemove001", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
lightWeightMap.set(3, "C");
lightWeightMap.set(4, "D");
lightWeightMap.set(5, "E");
let res = lightWeightMap.remove(3);
expect(res).assertEqual("C");
let res1 = lightWeightMap.hasValue("C");
expect(res1).assertEqual(false);
});
/**
* @tc.number: TEST_REMOVE_002
* @tc.name: testRemove002
* @tc.desc: Delete key value pairs according to key. For example: lightWeightMap.remove(3).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemove002", 0, function () {
let lightWeightMap = new LightWeightMap();
let res = lightWeightMap.remove(3);
expect(res).assertEqual(undefined);
});
/**
* @tc.number: TEST_REMOVEAT_001
* @tc.name: testRemoveAt001
* @tc.desc: Delete key value pairs according to index. For example: lightWeightMap.removeAt(1).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemoveAt001", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
lightWeightMap.set(3, "C");
lightWeightMap.set(4, "D");
lightWeightMap.set(5, "E");
let res = lightWeightMap.removeAt(1);
expect(res).assertEqual(true);
let res1 = lightWeightMap.hasValue("A");
expect(res1).assertEqual(true);
let res2 = lightWeightMap.hasValue("B");
expect(res2).assertEqual(false);
let res3 = lightWeightMap.removeAt(10);
expect(res3).assertEqual(false);
});
/**
* @tc.number: TEST_REMOVEAT_002
* @tc.name: testRemoveAt002
* @tc.desc: Delete key value pairs according to index. For example: lightWeightMap.removeAt(1).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemoveAt002", 0, function () {
let lightWeightMap = new LightWeightMap();
let res = lightWeightMap.removeAt(1);
expect(res).assertEqual(false);
});
/**
* @tc.number: TEST_REMOVEAT_003
* @tc.name: testRemoveAt003
* @tc.desc: Delete key value pairs according to index. For example: lightWeightMap.removeAt("a").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemoveAt003", 0, function () {
let lightWeightMap = new LightWeightMap();
try {
//@ts-ignore
let res = lightWeightMap.removeAt("a");
expect(true).assertEqual(false);
} catch (err) {
expect(err.name).assertEqual("BusinessError");
expect(err.code).assertEqual(401);
expect(err.message).assertEqual(`The type of "index" must be number. Received value is: a`);
}
});
/**
* @tc.number: TEST_CLEAR_001
* @tc.name: testClear001
* @tc.desc: Clear all key value pairs in LightWeightMap. For example: lightWeightMap.clear().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testClear001", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
lightWeightMap.set(3, "C");
lightWeightMap.set(4, "D");
lightWeightMap.set(5, "E");
lightWeightMap.clear();
let res = lightWeightMap.length;
expect(res).assertEqual(0);
let isEmpty = lightWeightMap.isEmpty();
expect(isEmpty).assertEqual(true);
});
/**
* @tc.number: TEST_SETVALUEAT_001
* @tc.name: testSetValueAt001
* @tc.desc: Modify the value of the key value pair according to the corresponding index.
* For example: setValueAt(0, "a").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testSetValueAt001", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
lightWeightMap.set(3, "C");
lightWeightMap.set(4, "D");
lightWeightMap.set(5, "E");
lightWeightMap.setValueAt(0, "a");
let res = lightWeightMap.get(1);
expect(res).assertEqual("a");
});
/**
* @tc.number: TEST_FOREACH_001
* @tc.name: testForEach001
* @tc.desc: Traverse all key value pairs in the LightWeightMap instance.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testForEach001", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
lightWeightMap.set(3, "C");
lightWeightMap.set(4, "D");
lightWeightMap.set(5, "E");
let arr = [];
lightWeightMap.forEach((value, index) => {
arr.push(value);
});
let arr1 = ["A", "B", "C", "D", "E"];
for (let i = 0; i < arr1.length; i++) {
expect(arr[i]).assertEqual(arr1[i]);
}
});
/**
* @tc.number: TEST_ITERATOR_001
* @tc.name: testIterator001
* @tc.desc: Iterate over all key value pairs in the LightWeightMap.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testIterator001", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
lightWeightMap.set(3, "C");
lightWeightMap.set(4, "D");
lightWeightMap.set(5, "E");
let iters = lightWeightMap[Symbol.iterator]();
let flag = true;
for (let i = 0, len = lightWeightMap.length; i < len; i++) {
let entry = iters.next().value;
let res = lightWeightMap.get(entry[0]);
if (res != entry[1]) {
flag = false;
break;
}
}
expect(flag).assertEqual(true);
});
/**
* @tc.number: TEST_TOSTRING_001
* @tc.name: testToString001
* @tc.desc: Use "," to splice the elements in the LightWeightMap instance into a string.
* For example: lightWeightMap.toString().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testToString001", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
lightWeightMap.set(3, "C");
let res = lightWeightMap.toString();
expect(res).assertEqual("1:A,2:B,3:C");
});
/**
* @tc.number: TEST_GETVALUEAT_001
* @tc.name: testGetValueAt001
* @tc.desc: Get the value of the key value pair according to the corresponding index.
* For example: lightWeightMap.getValueAt(1).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGetValueAt001", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
lightWeightMap.set(3, "C");
lightWeightMap.set(4, "D");
lightWeightMap.set(5, "E");
let res = lightWeightMap.getValueAt(1);
expect(res).assertEqual("B");
});
/**
* @tc.number: TEST_GETVALUEAT_002
* @tc.name: testGetValueAt002
* @tc.desc: Get the value of the key value pair according to the corresponding index.
* For example: lightWeightMap.getValueAt("a").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGetValueAt002", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
lightWeightMap.set(3, "C");
lightWeightMap.set(4, "D");
lightWeightMap.set(5, "E");
try {
//@ts-ignore
let res = lightWeightMap.getValueAt("a");
expect(true).assertEqual(false);
} catch (err) {
expect(err.name).assertEqual("BusinessError");
expect(err.code).assertEqual(401);
expect(err.message).assertEqual(`The type of "index" must be number. Received value is: a`);
}
});
/**
* @tc.number: TEST_GETVALUEAT_003
* @tc.name: testGetValueAt003
* @tc.desc: Get the value of the key value pair according to the corresponding index.
* For example: lightWeightMap.getValueAt(6).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGetValueAt003", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
lightWeightMap.set(3, "C");
lightWeightMap.set(4, "D");
lightWeightMap.set(5, "E");
try {
lightWeightMap.getValueAt(6);
expect(true).assertEqual(false);
} catch (err) {
expect(err.name).assertEqual("BusinessError");
expect(err.code).assertEqual(10200001);
expect(err.message).assertEqual(`The value of "index" is out of range. It must be >= 0 && <= 4. Received value is: 6`);
}
});
/**
* @tc.number: TEST_VALUES_001
* @tc.name: testValues001
* @tc.desc: Get a collection of all the values in the LightWeightMap. For example: lightWeightMap.values().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testValues001", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
lightWeightMap.set(3, "C");
lightWeightMap.set(4, "D");
lightWeightMap.set(5, "E");
let res = lightWeightMap.values();
expect(res.next().value).assertEqual("A");
expect(res.next().value).assertEqual("B");
expect(res.next().value).assertEqual("C");
expect(res.next().value).assertEqual("D");
expect(res.next().value).assertEqual("E");
});
});
}
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License')
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import LightWeightMap from './LightWeightMap.test'
export default function testsuite() {
LightWeightMap()
}
\ No newline at end of file
{
"module": {
"name": "entry_test",
"type": "feature",
"description": "$string:module_test_desc",
"mainElement": "TestAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:test_pages",
"abilities": [
{
"name": "TestAbility",
"srcEntry": "./ets/TestAbility/TestAbility.ets",
"description": "$string:TestAbility_desc",
"icon": "$media:icon",
"label": "$string:TestAbility_label",
"exported": true,
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
}
]
}
}
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_test_desc",
"value": "test ability description"
},
{
"name": "TestAbility_desc",
"value": "the test ability"
},
{
"name": "TestAbility_label",
"value": "test label"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "ohos.acts.commonlibrary.crossplatform.LinkedList.normal",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"minAPIVersion": 10,
"targetAPIVersion": 10,
"car": {
"apiCompatibleVersion": 10,
"singleUser": false
}
}
}
# Copyright (C) 2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsCrossplatformLinkedListTest") {
hap_profile = "src/main/module.json"
deps = [
":windowStage_js_assets",
":windowStage_resources",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
# hap_name: HAP的名字,可选,默认为目标名
hap_name = "ActsCrossplatformLinkedListTest"
subsystem_name = "commonlibrary"
part_name = "ets_utils"
}
ohos_app_scope("windowStage_app_profile") {
# app_profile: HAP的AppScope中的app.json,只在Stage模型下使用
app_profile = "AppScope/app.json"
# sources: 资源文件路径
sources = [ "AppScope/resources" ]
}
ohos_js_assets("windowStage_js_assets") {
# source_dir: js或ets代码路径,兼容FA模型的单ability配置到ability目录
source_dir = "src/main/ets"
}
ohos_resources("windowStage_resources") {
# sources: 资源文件路径
sources = [ "src/main/resources" ]
# deps: 当前目标的依赖
deps = [ ":windowStage_app_profile" ]
# hap_profile: HAP的config.json,Stage模型对应module.json
hap_profile = "src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "60000",
"shell-timeout": "60000",
"bundle-name": "ohos.acts.commonlibrary.crossplatform.LinkedList.normal",
"module-name": "entry_test"
},
"kits": [
{
"test-file-name": [
"ActsCrossplatformLinkedListTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License')
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import UIAbility from '@ohos.app.ability.UIAbility';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
import hilog from '@ohos.hilog';
import { Hypium } from '@ohos/hypium';
import testsuite from '../test/List.test';
import window from '@ohos.window';
export default class TestAbility extends UIAbility {
onCreate(want, launchParam) {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate');
hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? '');
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!');
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy');
}
onWindowStageCreate(windowStage: window.WindowStage) {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate');
windowStage.loadContent('TestAbility/pages/Index', (err, data) => {
if (err.code) {
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s',
JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy');
}
onForeground() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground');
}
onBackground() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground');
}
}
\ No newline at end of file
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License')
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import hilog from '@ohos.hilog';
@Entry
@Component
struct Index {
aboutToAppear() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear');
}
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(()=>{
})
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
import hilog from '@ohos.hilog';
import TestRunner from '@ohos.application.testRunner';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
async function onAbilityCreateCallback() {
hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err: any) {
hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');
}
async onRun() {
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run');
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName
var debug = abilityDelegatorArguments.parameters['-D']
if (debug == 'true')
{
cmd += ' -D'
}
hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd);
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? '');
})
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end');
}
}
\ No newline at end of file
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License')
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import LinkedList from "@ohos.util.LinkedList";
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
export default function LinkedListTest() {
describe("LinkedListTest", function () {
/**
* @tc.number:TEST_CONSTRUCTOR_001
* @tc.name: testConstructor001
* @tc.desc: Create an LinkedList instance. For example: let linkedList = new LinkedList().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testConstructor001", 0, function () {
try {
let linkedList = new LinkedList();
} catch (err) {
expect(err.name).assertEqual("BusinessError");
expect(err.code).assertEqual(10200012);
expect(err.message).assertEqual("The LinkedList's constructor cannot be directly invoked");
}
});
/**
* @tc.number:TEST_LENGTH_001
* @tc.name: testLength001
* @tc.desc: Get the number of elements in the LinkedList instance. For example: linkedList.length.
* @tc.size: MediumTest
* @tc.type: Field
* @tc.level: level 1
*/
it("testLength001", 0, function () {
let linkedList = new LinkedList();
linkedList.add(4);
linkedList.add(3);
linkedList.add(1);
linkedList.add(2);
linkedList.add(14);
let res = linkedList.length;
expect(res).assertEqual(5);
});
/**
* @tc.number:TEST_ADD_001
* @tc.name: testAdd001
* @tc.desc: Add a element to the end of the LinkedList instance. For example: linkedList.add("四").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level:level 2
*/
it("testAdd001", 0, function () {
let linkedList = new LinkedList();
linkedList.add("四");
let res = linkedList.get(0);
expect(res).assertEqual("四");
});
/**
* @tc.number:TEST_ADD_002
* @tc.name: testAdd002
* @tc.desc: Add a element to the end of the LinkedList instance. For example: linkedList.add(8).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level:level 2
*/
it("testAdd002", 0, function () {
let linkedList = new LinkedList();
linkedList.add(8);
let res = linkedList.get(0);
expect(res).assertEqual(8);
});
/**
* @tc.number:TEST_ADD_003
* @tc.name: testAdd003
* @tc.desc: Add a element to the end of the LinkedList instance.
* For example: let a = [1, 2, 3, 4];linkedList.add(a).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level:level 2
*/
it("testAdd003", 0, function () {
let linkedList = new LinkedList();
let a = [1, 2, 3, 4];
linkedList.add(a);
let res = linkedList.get(0);
expect(res).assertEqual(a);
});
/**
* @tc.number:TEST_ADD_004
* @tc.name: testAdd004
* @tc.desc: Add a element to the end of the LinkedList instance.
* For example: let a = {name: "lala", age: "13"};linkedList.add(a).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level:level 2
*/
it("testAdd004", 0, function () {
let linkedList = new LinkedList();
let a = {name: "lala", age: "13"};
linkedList.add(a);
let res = linkedList.get(0);
expect(res).assertEqual(a);
});
/**
* @tc.number:TEST_ADD_005
* @tc.name: testAdd005
* @tc.desc: Add a element to the end of the LinkedList instance. For example: let a = ".";linkedList.add(a).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level:level 2
*/
it("testAdd005", 0, function () {
let linkedList = new LinkedList();
let a = ".";
linkedList.add(a);
let res = linkedList.get(0);
expect(res).assertEqual(a);
});
/**
* @tc.number:TEST_ADD_006
* @tc.name: testAdd006
* @tc.desc: Add a element to the end of the LinkedList instance. For example: let a = "*";linkedList.add(a).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level:level 2
*/
it("testAdd006", 0, function () {
let linkedList = new LinkedList();
let a = "*";
linkedList.add(a);
let res = linkedList.get(0);
expect(res).assertEqual(a);
});
/**
* @tc.number:TEST_ADD_007
* @tc.name: testAdd007
* @tc.desc: Add a element to the end of the LinkedList instance. For example: let a = "/";linkedList.add(a).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level:level 2
*/
it("testAdd007", 0, function () {
let linkedList = new LinkedList();
let a = '/"';
linkedList.add(a);
let res = linkedList.get(0);
expect(res).assertEqual(a);
});
/**
* @tc.number:TEST_ADD_008
* @tc.name: testAdd008
* @tc.desc: Add a element to the end of the LinkedList instance. For example: let a = "";linkedList.add(a).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level:level 2
*/
it("testAdd008", 0, function () {
let linkedList = new LinkedList();
let a = "";
linkedList.add(a);
let res = linkedList.get(0);
expect(res).assertEqual(a);
});
/**
* @tc.number:TEST_ADD_009
* @tc.name: testAdd009
* @tc.desc: Add a element to the end of the LinkedList instance. For example: let a = "a";linkedList.add(a).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level:level 2
*/
it("testAdd009", 0, function () {
let linkedList = new LinkedList();
let a = "a";
linkedList.add(a);
linkedList.add(a);
let res = linkedList.get(0);
expect(res).assertEqual(a);
let res1 = linkedList.get(1);
expect(res1).assertEqual(a);
});
/**
* @tc.number:TEST_ADD_010
* @tc.name: testAdd010
* @tc.desc: Add a element to the end of the LinkedList instance.
* For example: for (let i = 0; i < 100; i++) {linkedList.add(i);}.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level:level 2
*/
it("testAdd010", 0, function () {
let linkedList = new LinkedList();
for (let i = 0; i < 100; i++) {
linkedList.add(i);
}
let res = linkedList.get(99);
expect(res).assertEqual(99);
});
/**
* @tc.number:TEST_ADD_011
* @tc.name: testAdd011
* @tc.desc: Add a element to the end of the LinkedList instance. For example: linkedList.add(null).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level:level 2
*/
it("testAdd054", 0, function () {
let linkedList = new LinkedList();
linkedList.add(null);
let res = linkedList.get(0);
expect(res).assertEqual(null);
});
/**
* @tc.number:TEST_ADD_012
* @tc.name: testAdd012
* @tc.desc: Add a element to the end of the LinkedList instance. For example: linkedList.add(0.1).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level:level 2
*/
it("testAdd055", 0, function () {
let linkedList = new LinkedList();
linkedList.add(0.1);
let res = linkedList.get(0);
expect(res).assertEqual(0.1);
});
/**
* @tc.number:TEST_ADD_013
* @tc.name: testAdd013
* @tc.desc: Add a element to the end of the LinkedList instance. For example: linkedList.add(-1).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level:level 2
*/
it("testAdd056", 0, function () {
let linkedList = new LinkedList();
linkedList.add(-1);
let res = linkedList.get(0);
expect(res).assertEqual(-1);
});
/**
* @tc.number:TEST_ADD_014
* @tc.name: testAdd014
* @tc.desc: Add a element to the end of the LinkedList instance. For example: const obj = {}; linkedList.add(obj).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testAdd014", 0, function () {
let linkedList = new LinkedList();
const obj = {};
linkedList.add(obj);
let res = linkedList.get(0);
expect(res).assertEqual(obj);
});
/**
* @tc.number:TEST_ADD_015
* @tc.name: testAdd015
* @tc.desc: Add a element to the end of the LinkedList instance. For example: linkedList.add.bind({}, obj)().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testAdd015", 0, function () {
let linkedList = new LinkedList();
try {
linkedList.add.bind({}, "a")();
expect(true).assertEqual(false);
} catch (err) {
expect(err.name).assertEqual("BusinessError");
expect(err.code).assertEqual(10200011);
expect(err.message).assertEqual(`The add method cannot be bound`);
}
});
/**
* @tc.number:TEST_INSERT_001
* @tc.name: testInsert001
* @tc.desc: Insert an element into the middle of the LinkedList instance. For example: linkedList.insert(3, "d").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testInsert001", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.insert(3, "d");
let arr = [];
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["a", "b", "c", "d", "a", "b"];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_INSERT_002
* @tc.name: testInsert002
* @tc.desc: Insert an element into the middle of the LinkedList instance. For example: linkedList.insert(0, "d").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testInsert002", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.insert(0, "d");
let arr = [];
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["d", "a", "b", "c", "a", "b"];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_INSERT_003
* @tc.name: testInsert003
* @tc.desc: Insert an element into the middle of the LinkedList instance. For example: linkedList.insert(5, "d").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testInsert003", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.insert(5, "d");
let arr = [];
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["a", "b", "c", "a", "b", "d"];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_INSERT_004
* @tc.name: testInsert004
* @tc.desc: Insert an element into the middle of the LinkedList instance. For example: linkedList.insert(9, "d").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testInsert004", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
try {
let res = linkedList.insert(8, "d");
expect(true).assertEqual(false);
} catch (err) {
expect(err.name).assertEqual("BusinessError");
expect(err.code).assertEqual(10200001);
expect(err.message).assertEqual(`The value of "index" is out of range. It must be >= 0 && <= 5. Received value is: 8`);
}
});
/**
* @tc.number:TEST_INSERT_005
* @tc.name: testInsert005
* @tc.desc: Insert an element into the middle of the LinkedList instance. For example: linkedList.insert("a", "d").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testInsert005", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
try {
//@ts-ignore
linkedList.insert("a", "d");
expect(true).assertEqual(false);
} catch (err) {
expect(err.name).assertEqual("BusinessError");
expect(err.code).assertEqual(401);
expect(err.message).assertEqual(`The type of "index" must be number. Received value is: a`);
}
});
/**
* @tc.number:TEST_GET_001
* @tc.name: testGet001
* @tc.desc: Gets the element corresponding to the specified index. For example: linkedList.get(1).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGet001", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.get(1);
expect(res).assertEqual("b");
});
/**
* @tc.number:TEST_GET_002
* @tc.name: testGet002
* @tc.desc: Gets the element corresponding to the specified index. For example: linkedList.get(10).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGet002", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.get(10);
expect(res).assertEqual(undefined);
});
/**
* @tc.number:TEST_GET_003
* @tc.name: testGet003
* @tc.desc: Gets the element corresponding to the specified index. For example: linkedList.get(1).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGet003", 0, function () {
let linkedList = new LinkedList();
let res = linkedList.get(1);
expect(res).assertEqual(undefined);
});
/**
* @tc.number:TEST_GET_004
* @tc.name: testGet004
* @tc.desc: Gets the element corresponding to the specified index. For example: linkedList.get("a").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGet004", 0, function () {
let linkedList = new LinkedList();
try {
//@ts-ignore
linkedList.get("a");
expect(true).assertEqual(false);
} catch (err) {
expect(err.name).assertEqual("BusinessError");
expect(err.code).assertEqual(401);
expect(err.message).assertEqual(`The type of "index" must be number. Received value is: a`);
}
});
/**
* @tc.number:TEST_ADDFIRST_001
* @tc.name: testAddFirst001
* @tc.desc: Add element to LinkedList instance header. For example: linkedList.addFirst("e").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testAddFirst001", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.addFirst("e");
let res = linkedList.get(0);
expect(res).assertEqual("e");
});
/**
* @tc.number:TEST_ADDFIRST_002
* @tc.name: testAddFirst002
* @tc.desc: Add element to LinkedList instance header. For example: linkedList.addFirst("h").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testAddFirst002", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.addFirst("h");
let res = linkedList.get(0);
expect(res).assertEqual("h");
});
/**
* @tc.number:TEST_ADDFIRST_003
* @tc.name: testAddFirst003
* @tc.desc: Add element to LinkedList instance header. For example: linkedList.addFirst("m").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testAddFirst003", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.addFirst("m");
let res = linkedList.get(0);
expect(res).assertEqual("m");
});
/**
* @tc.number:TEST_ADDFIRST_004
* @tc.name: testAddFirst004
* @tc.desc: Add element to LinkedList instance header. For example: linkedList.addFirst("k").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testAddFirst004", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.addFirst("k");
let res = linkedList.get(0);
expect(res).assertEqual("k");
});
/**
* @tc.number:TEST_ADDFIRST_005
* @tc.name: testAddFirst005
* @tc.desc: Add element to LinkedList instance header. For example: linkedList.addFirst("w").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testAddFirst005", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.addFirst("w");
let res = linkedList.get(0);
expect(res).assertEqual("w");
});
/**
* @tc.number:TEST_REMOVEFIRST_001
* @tc.name: testRemoveFirst001
* @tc.desc: Delete the header element of a LinkedList instance. For example: linkedList.removeFirst().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemoveFirst001", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
let res = linkedList.removeFirst();
expect(res).assertEqual("a");
let arr = [];
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["b", "c"];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_REMOVEFIRST_002
* @tc.name: testRemoveFirst002
* @tc.desc: Delete the header element of a LinkedList instance. For example: linkedList.removeFirst().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemoveFirst002", 0, function () {
let linkedList = new LinkedList();
linkedList.add("m");
linkedList.add("b");
linkedList.add("c");
let res = linkedList.removeFirst();
expect(res).assertEqual("m");
let arr = [];
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["b", "c"];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_REMOVEFIRST_003
* @tc.name: testRemoveFirst003
* @tc.desc: Delete the header element of a LinkedList instance. For example: linkedList.removeFirst().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemoveFirst003", 0, function () {
let linkedList = new LinkedList();
linkedList.add("h");
linkedList.add("b");
linkedList.add("c");
let res = linkedList.removeFirst();
expect(res).assertEqual("h");
let arr = [];
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["b", "c"];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_REMOVEFIRST_004
* @tc.name: testRemoveFirst004
* @tc.desc: Delete the header element of a LinkedList instance. For example: linkedList.removeFirst().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemoveFirst004", 0, function () {
let linkedList = new LinkedList();
linkedList.add("k");
linkedList.add("b");
linkedList.add("c");
let res = linkedList.removeFirst();
expect(res).assertEqual("k");
let arr = [];
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["b", "c"];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_REMOVEFIRST_005
* @tc.name: testRemoveFirst005
* @tc.desc: Delete the header element of a LinkedList instance. For example: linkedList.removeFirst().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemoveFirst005", 0, function () {
let linkedList = new LinkedList();
try {
linkedList.removeFirst();
expect(true).assertEqual(false);
} catch (err) {
expect(err.name).assertEqual("BusinessError");
expect(err.code).assertEqual(10200010);
expect(err.message).assertEqual(`Container is empty`);
}
});
/**
* @tc.number:TEST_REMOVELAST_001
* @tc.name: testRemoveLast001
* @tc.desc: Delete the end element of a LinkedList instance. linkedList.removeLast().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemoveLast001", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.addFirst("e");
let res = linkedList.removeLast();
expect(res).assertEqual("c");
let arr = [];
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["e", "a", "b"];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_REMOVELAST_002
* @tc.name: testRemoveLast002
* @tc.desc: Delete the end element of a LinkedList instance. linkedList.removeLast().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemoveLast002", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("d");
linkedList.addFirst("e");
let res = linkedList.removeLast();
expect(res).assertEqual("d");
let arr = [];
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["e", "a", "b","c"];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_REMOVELAST_003
* @tc.name: testRemoveLast003
* @tc.desc: Delete the end element of a LinkedList instance. linkedList.removeLast().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemoveLast003", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("h");
linkedList.addFirst("e");
let res = linkedList.removeLast();
expect(res).assertEqual("h");
let arr = [];
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["e", "a", "b"];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_REMOVELAST_004
* @tc.name: testRemoveLast004
* @tc.desc: Delete the end element of a LinkedList instance. linkedList.removeLast().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemoveLast004", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("m");
linkedList.addFirst("e");
let res = linkedList.removeLast();
expect(res).assertEqual("m");
let arr = [];
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["e", "a", "b"];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_REMOVELAST_005
* @tc.name: testRemoveLast005
* @tc.desc: Delete the end element of a LinkedList instance. linkedList.removeLast().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemoveLast061", 0, function () {
let linkedList = new LinkedList();
try {
linkedList.removeLast();
expect(true).assertEqual(false);
} catch (err) {
expect(err.name).assertEqual("BusinessError");
expect(err.code).assertEqual(10200010);
expect(err.message).assertEqual(`Container is empty`);
}
});
/**
* @tc.number:TEST_HAS_001
* @tc.name: testHas001
* @tc.desc: Check whether the LinkedList contains a specified element. For example: linkedList.has("a").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testHas001", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
let res = linkedList.has("a");
expect(res).assertEqual(true);
let res1 = linkedList.has("d");
expect(res1).assertEqual(false);
});
/**
* @tc.number:TEST_HAS_002
* @tc.name: testHas002
* @tc.desc: Check whether the LinkedList contains a specified element. For example: linkedList.has("a").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testHas002", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("m");
let res = linkedList.has("m");
expect(res).assertEqual(true);
let res1 = linkedList.has("k");
expect(res1).assertEqual(false);
});
/**
* @tc.number:TEST_HAS_003
* @tc.name: testHas003
* @tc.desc: Check whether the LinkedList contains a specified element. For example: linkedList.has(1).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testHas003", 0, function () {
let linkedList = new LinkedList();
let res = linkedList.has(1);
expect(res).assertEqual(false);
});
/**
* @tc.number:TEST_GETINDEXOF_001
* @tc.name: testGetIndexOf001
* @tc.desc: In the LinkedList instance, find the index of a specified element from front to back,
* and return the index found for the first time. If not found, return -1.
* For example: linkedList.getIndexOf("b").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGetIndexOf001", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
linkedList.add("b");
let res = linkedList.getIndexOf("b");
expect(res).assertEqual(1);
});
/**
* @tc.number:TEST_GETINDEXOF_002
* @tc.name: testGetIndexOf002
* @tc.desc: In the LinkedList instance, find the index of a specified element from front to back,
* and return the index found for the first time. If not found, return -1.
* For example: linkedList.getIndexOf("b").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGetIndexOf002", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
linkedList.add("b");
let res = linkedList.getIndexOf("a");
expect(res).assertEqual(0);
});
/**
* @tc.number:TEST_GETINDEXOF_003
* @tc.name: testGetIndexOf003
* @tc.desc: In the LinkedList instance, find the index of a specified element from front to back,
* and return the index found for the first time. If not found, return -1.
* For example: linkedList.getIndexOf("b").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGetIndexOf003", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
linkedList.add("b");
let res = linkedList.getIndexOf("c");
expect(res).assertEqual(2);
});
/**
* @tc.number:TEST_GETINDEXOF_004
* @tc.name: testGetIndexOf004
* @tc.desc: In the LinkedList instance, find the index of a specified element from front to back,
* and return the index found for the first time. If not found, return -1.
* For example: linkedList.getIndexOf("f").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGetIndexOf004", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
linkedList.add("b");
let res = linkedList.getIndexOf("f");
expect(res).assertEqual(-1);
});
/**
* @tc.number:TEST_GETINDEXOF_005
* @tc.name: testGetIndexOf005
* @tc.desc: In the LinkedList instance, find the index of a specified element from front to back,
* and return the index found for the first time. If not found, return -1. For example: linkedList.getIndexOf(1).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGetIndexOf005", 0, function () {
let linkedList = new LinkedList();
let res = linkedList.getIndexOf(1);
expect(res).assertEqual(-1);
});
/**
* @tc.number:TEST_REMOVEBYINDEX_001
* @tc.name: testRemoveByIndex001
* @tc.desc: In the linkedList instance, delete the element based on its index.
* For example: linkedList.removeByIndex(2).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemoveByIndex001", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.removeByIndex(2);
let arr = [];
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["a", "b", "a", "b"];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_REMOVEBYINDEX_002
* @tc.name: testRemoveByIndex002
* @tc.desc: In the linkedList instance, delete the element based on its index.
* For example: linkedList.removeByIndex(3).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemoveByIndex002", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.removeByIndex(3);
let arr = [];
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["a", "b", "c", "b"];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_REMOVEBYINDEX_003
* @tc.name: testRemoveByIndex003
* @tc.desc: In the linkedList instance, delete the element based on its subscript index.
* For example: linkedList.removeByIndex(10).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemoveByIndex003", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
try {
let res = linkedList.removeByIndex(10);
expect(true).assertEqual(false);
} catch (err) {
expect(err.name).assertEqual("BusinessError");
expect(err.code).assertEqual(10200001);
expect(err.message).assertEqual(`The value of "index" is out of range. It must be >= 0 && <= 4. Received value is: 10`);
}
});
/**
* @tc.number:TEST_REMOVEBYINDEX_004
* @tc.name: testRemoveByIndex004
* @tc.desc: In the linkedList instance, delete the element based on its subscript index.
* For example: linkedList.removeByIndex(1).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemoveByIndex004", 0, function () {
let linkedList = new LinkedList();
try {
let res = linkedList.removeByIndex(1);
expect(true).assertEqual(false);
} catch (err) {
expect(err.name).assertEqual("BusinessError");
expect(err.code).assertEqual(10200001);
expect(err.message).assertEqual(`The value of "index" is out of range. It must be >= 0 && <= 0. Received value is: 1`);
}
});
/**
* @tc.number:TEST_REMOVEBYINDEX_005
* @tc.name: testRemoveByIndex005
* @tc.desc: In the linkedList instance, delete the element based on its subscript index.
* For example: linkedList.removeByIndex("a").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemoveByIndex005", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
try {
//@ts-ignore
linkedList.removeByIndex("a");
expect(true).assertEqual(false);
} catch (err) {
expect(err.name).assertEqual("BusinessError");
expect(err.code).assertEqual(401);
expect(err.message).assertEqual(`The type of "index" must be number. Received value is: a`);
}
});
/**
* @tc.number:TEST_REMOVE_001
* @tc.name: testRemove001
* @tc.desc: Delete the specified element. For example: linkedList.remove("a").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemove001", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.remove("a");
let arr = [];
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["b", "c", "a", "b"];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_REMOVE_002
* @tc.name: testRemove002
* @tc.desc: Delete the specified element. For example: linkedList.remove("a").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemove002", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.remove("c");
let arr = [];
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["a", "b", "a", "b"];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_REMOVE_003
* @tc.name: testRemove003
* @tc.desc: Delete the specified element. For example: linkedList.remove("a").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemove003", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.remove("b");
let arr = [];
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["a", "c", "a", "b"];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_REMOVE_004
* @tc.name: testRemove004
* @tc.desc: Delete the specified element. For example: linkedList.remove("d").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemove004", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.remove("d");
expect(res).assertEqual(false);
});
/**
* @tc.number:TEST_REMOVE_005
* @tc.name: testRemove005
* @tc.desc: Delete the specified element. For example: linkedList.remove("d").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemove005", 0, function () {
let linkedList = new LinkedList();
let res = linkedList.remove("d");
expect(res).assertEqual(false);
});
/**
* @tc.number:TEST_REMOVEFIRSTFOUND_001
* @tc.name: testRemoveFirstFound001
* @tc.desc: Delete the specified element found for the first time. For example: linkedList.removeFirstFound("b").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemoveFirstFound001", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.removeFirstFound("b");
let arr = [];
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["a", "c", "a", "b"];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_REMOVEFIRSTFOUND_002
* @tc.name: testRemoveFirstFound002
* @tc.desc: Delete the specified element found for the first time. For example: linkedList.removeFirstFound("b").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemoveFirstFound002", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.removeFirstFound("a");
let arr = [];
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["b", "c", "a", "b"];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_REMOVEFIRSTFOUND_003
* @tc.name: testRemoveFirstFound003
* @tc.desc: Delete the specified element found for the first time. For example: linkedList.removeFirstFound("b").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemoveFirstFound003", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.removeFirstFound("c");
let arr = [];
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["a", "b", "a", "b"];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_REMOVEFIRSTFOUND_004
* @tc.name: testRemoveFirstFound004
* @tc.desc: Delete the specified element found for the first time. For example: linkedList.removeFirstFound("b").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemoveFirstFound004", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("m");
let res = linkedList.removeFirstFound("m");
let arr = [];
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["a", "b", "c", "a"];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_REMOVEFIRSTFOUND_005
* @tc.name: testRemoveFirstFound005
* @tc.desc: Delete the specified element found for the first time. For example: linkedList.removeFirstFound("b").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemoveFirstFound005", 0, function () {
let linkedList = new LinkedList();
try {
linkedList.removeFirstFound("b");
expect(true).assertEqual(false);
} catch (err) {
expect(err.name).assertEqual("BusinessError");
expect(err.code).assertEqual(10200010);
expect(err.message).assertEqual(`Container is empty`);
}
});
/**
* @tc.number:TEST_REMOVELASTFOUND_001
* @tc.name: testRemoveLastFound001
* @tc.desc: Delete the specified element found for the last time. For example: linkedList.removeLastFound("b").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemoveLastFound001", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.removeLastFound("b");
let arr = [];
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["a", "b", "c", "a"];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_REMOVELASTFOUND_002
* @tc.name: testRemoveLastFound002
* @tc.desc: Delete the specified element found for the last time. For example: linkedList.removeLastFound("b").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemoveLastFound002", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.removeLastFound("a");
let arr = [];
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["a", "b", "c", "b"];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_REMOVELASTFOUND_003
* @tc.name: testRemoveLastFound003
* @tc.desc: Delete the specified element found for the last time. For example: linkedList.removeLastFound("b").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemoveLastFound003", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.removeLastFound("c");
let arr = [];
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["a", "b", "a", "b"];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_REMOVELASTFOUND_004
* @tc.name: testRemoveLastFound004
* @tc.desc: Delete the specified element found for the last time. For example: linkedList.removeLastFound("b").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemoveLastFound004", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
linkedList.add("m");
let res = linkedList.removeLastFound("m");
let arr = [];
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["a", "b","c","a", "b"];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_REMOVELASTFOUND_005
* @tc.name: testRemoveLastFound005
* @tc.desc: Delete the specified element found for the last time. For example: linkedList.removeLastFound("b").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testRemoveLastFound005", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
linkedList.add("m");
let res = linkedList.removeLastFound("a");
let arr = [];
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["a", "b","c","b", "m"];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_GETLASTINDEXOF_001
* @tc.name: testGetLastIndexOf001
* @tc.desc: In the LinkedList instance, find the index of a specified element from brack to front,
* and return the index found for the first time. If not found, return -1.
* For example: linkedList.getLastIndexOf("a").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGetLastIndexOf001", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
linkedList.add("b");
let res = linkedList.getLastIndexOf("a");
expect(res).assertEqual(3);
});
/**
* @tc.number:TEST_GETLASTINDEXOF_002
* @tc.name: testGetLastIndexOf002
* @tc.desc: In the LinkedList instance, find the index of a specified element from brack to front,
* and return the index found for the first time. If not found, return -1.
* For example: linkedList.getLastIndexOf("a").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGetLastIndexOf002", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
linkedList.add("b");
let res = linkedList.getLastIndexOf("b");
expect(res).assertEqual(5);
});
/**
* @tc.number:TEST_GETLASTINDEXOF_003
* @tc.name: testGetLastIndexOf003
* @tc.desc: In the LinkedList instance, find the index of a specified element from brack to front,
* and return the index found for the first time. If not found, return -1.
* For example: linkedList.getLastIndexOf("a").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGetLastIndexOf003", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
linkedList.add("b");
let res = linkedList.getLastIndexOf("c");
expect(res).assertEqual(2);
});
/**
* @tc.number:TEST_GETLASTINDEXOF_004
* @tc.name: testGetLastIndexOf004
* @tc.desc: In the LinkedList instance, find the index of a specified element from brack to front,
* and return the index found for the first time. If not found, return -1.
* For example: linkedList.getLastIndexOf("a").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGetLastIndexOf004", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("k");
linkedList.add("b");
linkedList.add("k");
linkedList.add("b");
let res = linkedList.getLastIndexOf("k");
expect(res).assertEqual(6);
});
/**
* @tc.number:TEST_GETLASTINDEXOF_005
* @tc.name: testGetLastIndexOf005
* @tc.desc: In the LinkedList instance, find the index of a specified element from brack to front,
* and return the index found for the first time. If not found, return -1.
* For example: linkedList.getLastIndexOf("f").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGetLastIndexOf005", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
linkedList.add("b");
let res = linkedList.getLastIndexOf("f");
expect(res).assertEqual(-1);
});
/**
* @tc.number:TEST_GETFIRST_001
* @tc.name: testGetFirst001
* @tc.desc: Get the header element of the linkedList instance. For example: linkedList.getFirst().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGetFirst001", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.getFirst();
expect(res).assertEqual("a");
});
/**
* @tc.number:TEST_GETFIRST_002
* @tc.name: testGetFirst002
* @tc.desc: Get the header element of the linkedList instance. For example: linkedList.getFirst().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGetFirst002", 0, function () {
let linkedList = new LinkedList();
linkedList.add("m");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.getFirst();
expect(res).assertEqual("m");
});
/**
* @tc.number:TEST_GETFIRST_003
* @tc.name: testGetFirst003
* @tc.desc: Get the header element of the linkedList instance. For example: linkedList.getFirst().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGetFirst003", 0, function () {
let linkedList = new LinkedList();
linkedList.add("k");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.getFirst();
expect(res).assertEqual("k");
});
/**
* @tc.number:TEST_GETFIRST_004
* @tc.name: testGetFirst004
* @tc.desc: Get the header element of the linkedList instance. For example: linkedList.getFirst().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGetFirst004", 0, function () {
let linkedList = new LinkedList();
linkedList.add("h");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.getFirst();
expect(res).assertEqual("h");
});
/**
* @tc.number:TEST_GETFIRST_005
* @tc.name: testGetFirst005
* @tc.desc: Get the header element of the linkedList instance. For example: linkedList.getFirst().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGetFirst005", 0, function () {
let linkedList = new LinkedList();
let res = linkedList.getFirst();
expect(res).assertEqual(undefined);
});
/**
* @tc.number:TEST_GETLAST_001
* @tc.name: testGetLast001
* @tc.desc: Get the end element of the linkedList instance. For example: linkedList.getLast().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGetLast001", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.getLast();
expect(res).assertEqual("b");
});
/**
* @tc.number:TEST_GETLAST_002
* @tc.name: testGetLast002
* @tc.desc: Get the end element of the linkedList instance. For example: linkedList.getLast().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGetLast002", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("m");
let res = linkedList.getLast();
expect(res).assertEqual("m");
});
/**
* @tc.number:TEST_GETLAST_003
* @tc.name: testGetLast003
* @tc.desc: Get the end element of the linkedList instance. For example: linkedList.getLast().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGetLast003", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("h");
let res = linkedList.getLast();
expect(res).assertEqual("h");
});
/**
* @tc.number:TEST_GETLAST_004
* @tc.name: testGetLast004
* @tc.desc: Get the end element of the linkedList instance. For example: linkedList.getLast().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGetLast004", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("k");
let res = linkedList.getLast();
expect(res).assertEqual("k");
});
/**
* @tc.number:TEST_GETLAST_005
* @tc.name: testGetLast005
* @tc.desc: Get the end element of the linkedList instance. For example: linkedList.getLast().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testGetLast005", 0, function () {
let linkedList = new LinkedList();
let res = linkedList.getLast();
expect(res).assertEqual(undefined);
});
/**
* @tc.number:TEST_SET_001
* @tc.name: testSet001
* @tc.desc: Modify the element corresponding to the specified index. For example: linkedList.set(2, "d").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testSet001", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
let res = linkedList.set(2, "d");
let res1 = linkedList.get(2);
expect(res1).assertEqual("d");
});
/**
* @tc.number:TEST_SET_002
* @tc.name: testSet002
* @tc.desc: Modify the element corresponding to the specified index. For example: linkedList.set(2, "d").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testSet002", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
let res = linkedList.set(1, "m");
let res1 = linkedList.get(1);
expect(res1).assertEqual("m");
});
/**
* @tc.number:TEST_SET_003
* @tc.name: testSet003
* @tc.desc: Modify the element corresponding to the specified index. For example: linkedList.set(2, "d").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testSet003", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
let res = linkedList.set(3, "k");
let res1 = linkedList.get(3);
expect(res1).assertEqual("k");
});
/**
* @tc.number:TEST_SET_004
* @tc.name: testSet004
* @tc.desc: Modify the element corresponding to the specified index. For example: linkedList.set(6, "d").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testSet004", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
try {
linkedList.set(6, "d");
expect(true).assertEqual(false);
} catch (err) {
expect(err.name).assertEqual("BusinessError");
expect(err.code).assertEqual(10200001);
expect(err.message).assertEqual(`The value of "index" is out of range. It must be >= 0 && <= 3. Received value is: 6`);
}
});
/**
* @tc.number:TEST_SET_005
* @tc.name: testSet005
* @tc.desc: Modify the element corresponding to the specified index. For example: linkedList.set("a", "d").
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testSet005", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
try {
//@ts-ignore
linkedList.set("a", "d");
expect(true).assertEqual(false);
} catch (err) {
expect(err.name).assertEqual("BusinessError");
expect(err.code).assertEqual(401);
expect(err.message).assertEqual(`The type of "index" must be number. Received value is: a`);
}
});
/**
* @tc.number:TEST_FOREACH_001
* @tc.name: testForEach001
* @tc.desc: Traversing elements in an LinkedList instance.
* For example: linkedList.forEach((item, index) => {arr.push(item);}).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testForEach001", 0, function () {
let linkedList = new LinkedList();
linkedList.add(8);
linkedList.add("一");
linkedList.add("二");
linkedList.add(5);
let c = [1, 2, 3, 4];
linkedList.add(c);
linkedList.add(6);
linkedList.add("三");
linkedList.add("四");
let arr = [];
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = [8, "一", "二", 5, c, 6, "三", "四"];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_FOREACH_002
* @tc.name: testForEach002
* @tc.desc: Traversing elements in an LinkedList instance.
* For example: linkedList.forEach((item, index) => {arr.push(item);}).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testForEach002", 0, function () {
let linkedList = new LinkedList();
linkedList.add(8);
linkedList.add(1);
linkedList.add(2);
linkedList.add(5);
let c = [1, 2, 3, 4];
linkedList.add(c);
linkedList.add(6);
linkedList.add(3);
linkedList.add(4);
let arr = [];
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = [8, 1, 2, 5, c, 6, 3, 4];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_FOREACH_003
* @tc.name: testForEach003
* @tc.desc: Traversing elements in an LinkedList instance.
* For example: linkedList.forEach((item, index) => {arr.push(item);}).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testForEach003", 0, function () {
let linkedList = new LinkedList();
linkedList.add(8);
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
let c = [1, 2, 3, 4];
linkedList.add("c");
linkedList.add(6);
linkedList.add(3);
linkedList.add(4);
let arr = [];
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = [8, "a", "b", "c", "c", 6, 3, 4];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_FOREACH_004
* @tc.name: testForEach004
* @tc.desc: Traversing elements in an LinkedList instance.
* For example: linkedList.forEach((item, index) => {arr.push(item);}).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testForEach004", 0, function () {
let linkedList = new LinkedList();
linkedList.add("m");
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
let c = [1, 2, 3, 4];
linkedList.add("m");
linkedList.add(6);
linkedList.add(3);
linkedList.add(4);
let arr = [];
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["m", "a", "b", "c", "m", 6, 3, 4];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_FOREACH_005
* @tc.name: testForEach005
* @tc.desc: Traversing elements in an LinkedList instance.
* For example: linkedList.forEach((item, index) => { num++; }).
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testForEach005", 0, function () {
let linkedList = new LinkedList();
let num = 0;
linkedList.forEach((item, index) => {
num++;
});
expect(num).assertEqual(0);
});
/**
* @tc.number:TEST_CLEAR_001
* @tc.name: testClear001
* @tc.desc: Clear all elements in the linkedList instance. For example: linkedList.clear().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testClear001", 0, function () {
let linkedList = new LinkedList();
linkedList.add(4);
linkedList.add(3);
linkedList.add(1);
linkedList.add(2);
linkedList.add(14);
linkedList.clear();
let res = linkedList.length;
expect(res).assertEqual(0);
});
/**
* @tc.number:TEST_CLEAR_002
* @tc.name: testClear002
* @tc.desc: Clear all elements in the linkedList instance. For example: linkedList.clear().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testClear002", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("d");
linkedList.add(20);
linkedList.clear();
let res = linkedList.length;
expect(res).assertEqual(0);
});
/**
* @tc.number:TEST_CLEAR_003
* @tc.name: testClear003
* @tc.desc: Clear all elements in the LinkedList instance. For example: linkedList.clear().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testClear003", 0, function () {
let linkedList = new LinkedList();
linkedList.clear();
const len = linkedList.length;
expect(len).assertEqual(0);
});
/**
* @tc.number:TEST_CLONE_001
* @tc.name: testClone001
* @tc.desc: Clone an LinkedList instance. For example: linkedList.clone().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testClone001", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
let linkedList1 = linkedList.clone();
linkedList1.addFirst("e");
let res = linkedList1.removeLast();
expect(res).assertEqual("c");
let arr = [];
linkedList1.forEach((item, index) => {
arr.push(item);
});
let a = ["e", "a", "b"];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_CLONE_002
* @tc.name: testClone002
* @tc.desc: Clone an LinkedList instance. For example: linkedList.clone().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testClone002", 0, function () {
let linkedList = new LinkedList();
linkedList.add(1);
linkedList.add(2);
linkedList.add(3);
let linkedList1 = linkedList.clone();
linkedList1.addFirst("e");
let res = linkedList1.removeLast();
expect(res).assertEqual(3);
let arr = [];
linkedList1.forEach((item, index) => {
arr.push(item);
});
let a = ["e", 1, 2];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_CLONE_003
* @tc.name: testClone003
* @tc.desc: Clone an LinkedList instance. For example: linkedList.clone().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testClone003", 0, function () {
let linkedList = new LinkedList();
let newlinkedList = linkedList.clone();
let res = true
for (let i = 0; i < linkedList.length; i++) {
if (linkedList[i] !== newlinkedList[i]) {
res = false
}
}
expect(res).assertEqual(true);
});
/**
* @tc.number:TEST_CONVERTTOARRAY_001
* @tc.name: testConvertToArray001
* @tc.desc: Convert an LinkedList instance to an array. For example: linkedList.convertToArray().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testConvertToArray001", 0, function () {
let linkedList = new LinkedList();
linkedList.add(4);
linkedList.add(3);
linkedList.add(1);
linkedList.add(2);
linkedList.add(14);
let res = linkedList.convertToArray();
let a = [4, 3, 1, 2, 14];
for (let i = 0; i < a.length; i++) {
expect(res[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_CONVERTTOARRAY_002
* @tc.name: testConvertToArray002
* @tc.desc: Convert an LinkedList instance to an array. For example: linkedList.convertToArray().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testConvertToArray002", 0, function () {
let linkedList = new LinkedList();
linkedList.add(1);
linkedList.add(2);
linkedList.add(3);
linkedList.add(4);
linkedList.add(5);
linkedList.add(6);
let res = linkedList.convertToArray();
let a = [1,2,3,4,5,6];
for (let i = 0; i < a.length; i++) {
expect(res[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_CONVERTTOARRAY_003
* @tc.name: testConvertToArray003
* @tc.desc: Convert an LinkedList instance to an array. For example: linkedList.convertToArray().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testConvertToArray003", 0, function () {
let linkedList = new LinkedList();
linkedList.add(2);
linkedList.add(4);
linkedList.add(3);
linkedList.add(10);
linkedList.add(12);
linkedList.add(16);
let res = linkedList.convertToArray();
let a = [2,4,3,10,12,16];
for (let i = 0; i < a.length; i++) {
expect(res[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_CONVERTTOARRAY_004
* @tc.name: testConvertToArray004
* @tc.desc: Convert an LinkedList instance to an array. For example: linkedList.convertToArray().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testConvertToArray004", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("d");
linkedList.add("e");
linkedList.add("f");
let res = linkedList.convertToArray();
let a = ["a","b","c","d","e","f"];
for (let i = 0; i < a.length; i++) {
expect(res[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_CONVERTTOARRAY_005
* @tc.name: testConvertToArray005
* @tc.desc: Convert an LinkedList instance to an array. For example: linkedList.convertToArray().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testConvertToArray005", 0, function () {
let linkedList = new LinkedList();
linkedList.add("m");
linkedList.add("k");
linkedList.add("c");
linkedList.add("d");
linkedList.add("e");
linkedList.add("f");
let res = linkedList.convertToArray();
let a = ["m","k","c","d","e","f"];
for (let i = 0; i < a.length; i++) {
expect(res[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_ITERATOR_001
* @tc.name: testIterator001
* @tc.desc: Iterates over all elements in an LinkedList instance. For example: linkedList[Symbol.iterator]().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testIterator001", 0, function () {
let linkedList = new LinkedList();
linkedList.add(1);
linkedList.add(2);
linkedList.add(3);
linkedList.addFirst("e");
let res = linkedList.removeLast();
expect(res).assertEqual(3);
let arr = [];
let itr = linkedList[Symbol.iterator]();
let tmp = undefined;
do {
tmp = itr.next().value;
arr.push(tmp);
} while (tmp != undefined);
let a = ["e", 1, 2];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_ITERATOR_002
* @tc.name: testIterator002
* @tc.desc: Iterates over all elements in an LinkedList instance. For example: linkedList[Symbol.iterator]().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testIterator002", 0, function () {
let linkedList = new LinkedList();
linkedList.add(5);
linkedList.add(10);
linkedList.add(15);
linkedList.addFirst("e");
let res = linkedList.removeLast();
expect(res).assertEqual(15);
let arr = [];
let itr = linkedList[Symbol.iterator]();
let tmp = undefined;
do {
tmp = itr.next().value;
arr.push(tmp);
} while (tmp != undefined);
let a = ["e", 5, 10];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_ITERATOR_003
* @tc.name: testIterator003
* @tc.desc: Iterates over all elements in an LinkedList instance. For example: linkedList[Symbol.iterator]().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testIterator003", 0, function () {
let linkedList = new LinkedList();
linkedList.add("k");
linkedList.add("h");
linkedList.add("m");
linkedList.addFirst("e");
let res = linkedList.removeLast();
expect(res).assertEqual("m");
let arr = [];
let itr = linkedList[Symbol.iterator]();
let tmp = undefined;
do {
tmp = itr.next().value;
arr.push(tmp);
} while (tmp != undefined);
let a = ["e", "k", "h"];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_ITERATOR_004
* @tc.name: testIterator004
* @tc.desc: Iterates over all elements in an LinkedList instance. For example: linkedList[Symbol.iterator]().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testIterator004", 0, function () {
let linkedList = new LinkedList();
linkedList.add(1);
linkedList.add(2);
linkedList.add(3);
linkedList.addFirst(10);
let res = linkedList.removeLast();
expect(res).assertEqual(3);
let arr = [];
let itr = linkedList[Symbol.iterator]();
let tmp = undefined;
do {
tmp = itr.next().value;
arr.push(tmp);
} while (tmp != undefined);
let a = [10, 1, 2];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
/**
* @tc.number:TEST_ITERATOR_005
* @tc.name: testIterator005
* @tc.desc: Iterates over all elements in an LinkedList instance. For example: linkedList[Symbol.iterator]().
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it("testIterator005", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.addFirst("e");
let res = linkedList.removeLast();
expect(res).assertEqual("c");
let arr = [];
let itr = linkedList[Symbol.iterator]();
let tmp = undefined;
do {
tmp = itr.next().value;
arr.push(tmp);
} while (tmp != undefined);
let a = ["e", "a", "b"];
for (let i = 0; i < a.length; i++) {
expect(arr[i]).assertEqual(a[i]);
}
});
});
}
\ No newline at end of file
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License')
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import LinkedListTest from './LinkedList.test'
export default function testsuite() {
LinkedListTest()
}
\ No newline at end of file
{
"module": {
"name": "entry_test",
"type": "feature",
"description": "$string:module_test_desc",
"mainElement": "TestAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:test_pages",
"abilities": [
{
"name": "TestAbility",
"srcEntry": "./ets/TestAbility/TestAbility.ets",
"description": "$string:TestAbility_desc",
"icon": "$media:icon",
"label": "$string:TestAbility_label",
"exported": true,
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
}
]
}
}
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_test_desc",
"value": "test ability description"
},
{
"name": "TestAbility_desc",
"value": "the test ability"
},
{
"name": "TestAbility_label",
"value": "test label"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "ohos.acts.commonlibrary.crossplatform.process.normal",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"minAPIVersion": 10,
"targetAPIVersion": 10,
"car": {
"apiCompatibleVersion": 10,
"singleUser": false
}
}
}
# Copyright (C) 2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsCrossplatformProcessTest") {
hap_profile = "src/main/module.json"
deps = [
":windowStage_js_assets",
":windowStage_resources",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
# hap_name: HAP的名字,可选,默认为目标名
hap_name = "ActsCrossplatformProcessTest"
subsystem_name = "commonlibrary"
part_name = "ets_utils"
}
ohos_app_scope("windowStage_app_profile") {
# app_profile: HAP的AppScope中的app.json,只在Stage模型下使用
app_profile = "AppScope/app.json"
# sources: 资源文件路径
sources = [ "AppScope/resources" ]
}
ohos_js_assets("windowStage_js_assets") {
# source_dir: js或ets代码路径,兼容FA模型的单ability配置到ability目录
source_dir = "src/main/ets"
}
ohos_resources("windowStage_resources") {
# sources: 资源文件路径
sources = [ "src/main/resources" ]
# deps: 当前目标的依赖
deps = [ ":windowStage_app_profile" ]
# hap_profile: HAP的config.json,Stage模型对应module.json
hap_profile = "src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "60000",
"shell-timeout": "60000",
"bundle-name": "ohos.acts.commonlibrary.crossplatform.process.normal",
"module-name": "entry_test"
},
"kits": [
{
"test-file-name": [
"ActsCrossplatformProcessTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import UIAbility from '@ohos.app.ability.UIAbility';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
import hilog from '@ohos.hilog';
import { Hypium } from '@ohos/hypium';
import testsuite from '../test/List.test';
import window from '@ohos.window';
export default class TestAbility extends UIAbility {
onCreate(want, launchParam) {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate');
hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? '');
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!');
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy');
}
onWindowStageCreate(windowStage: window.WindowStage) {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate');
windowStage.loadContent('TestAbility/pages/Index', (err, data) => {
if (err.code) {
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s',
JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy');
}
onForeground() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground');
}
onBackground() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground');
}
}
\ No newline at end of file
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License')
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import hilog from '@ohos.hilog';
@Entry
@Component
struct Index {
aboutToAppear() {
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear');
}
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(()=>{
})
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
import hilog from '@ohos.hilog';
import TestRunner from '@ohos.application.testRunner';
import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
async function onAbilityCreateCallback() {
hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err: any) {
hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');
}
async onRun() {
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run');
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName
var debug = abilityDelegatorArguments.parameters['-D']
if (debug == 'true')
{
cmd += ' -D'
}
hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd);
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? '');
})
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end');
}
}
\ No newline at end of file
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License')
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import ProcessTest from './Process.test.ets'
export default function testsuite() {
ProcessTest()
}
\ No newline at end of file
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
import process from '@ohos.process'
export default function ProcessTest() {
describe('ProcessManager', function () {
/**
* @tc.number:TEST_IS_APPUID_001
* @tc.name: testProcessManagerIsAppUid001
* @tc.desc: Returns a boolean whether the specified uid belongs to a particular application.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testProcessManagerIsAppUid001', 0, function () {
let pro = new process.ProcessManager();
let isorno = pro.isAppUid(167);
expect(isorno).assertEqual(false);
})
/**
* @tc.number:TEST_PROCESSMAMAGER_IS_APPUID_002
* @tc.name: testProcessManagerIsAppUid002
* @tc.desc: Returns a boolean whether the specified uid belongs to a particular application.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testProcessManagerIsAppUid002', 0, function () {
let pro = new process.ProcessManager();
let isorno = pro.isAppUid(80000);
expect(isorno).assertEqual(false);
})
/**
* @tc.number:TEST_PROCESSMAMAGER_IS_APPUID_003
* @tc.name: testProcessManagerIsAppUid003
* @tc.desc: Returns a boolean whether the specified uid belongs to a particular application.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testProcessManagerIsappuid003', 0, function () {
let pro = new process.ProcessManager();
let isorno = pro.isAppUid(123);
expect(isorno).assertEqual(false);
})
/**
* @tc.number:TEST_PROCESSMAMAGER_IS_APPUID_004
* @tc.name: testProcessManagerIsAppUid004
* @tc.desc: Returns a boolean whether the specified uid belongs to a particular application.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testProcessManagerIsappuid004', 0, function () {
let pro = new process.ProcessManager();
let isorno = pro.isAppUid(789);
expect(isorno).assertEqual(false);
})
/**
* @tc.number:TEST_PROCESSMAMAGER_IS_APPUID_005
* @tc.name: testProcessManagerIsAppUid004
* @tc.desc: Returns a boolean whether the specified uid belongs to a particular application.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testProcessManagerIsappuid005', 0, function () {
let pro = new process.ProcessManager();
let isorno = pro.isAppUid(8569);
expect(isorno).assertEqual(false);
})
/**
* @tc.number:TEST_PROCESSMAMAGER_IS_APPUID_006
* @tc.name: testProcessManagerIsAppUid006
* @tc.desc: Returns a boolean whether the specified uid belongs to a particular application.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testProcessManagerIsappuid006', 0, function () {
try {
let pro = new process.ProcessManager();
//@ts-ignore
let mag = pro.isAppUid("asdad");
} catch (e) {
expect(e.toString()).assertEqual("BuisnessError: The type of v must be number.");
}
})
/**
* @tc.number:TEST_PROCESSMANAGER_GETUIDFORNAME_001
* @tc.name: testProcessManagerGetUidForName001
* @tc.desc: Returns the uid based on the specified user name.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testProcessManagerGetUidForName001',0, function () {
let pro = new process.ProcessManager();
let pres = pro.getUidForName("root");
if (pres != -1) {
let flag = new Boolean(true);
expect(Boolean(flag)).assertEqual(true);
}
})
/**
* @tc.number:TEST_PROCESSMANAGER_GETUIDFORNAME_002
* @tc.name: testProcessManagerGetUidForName002
* @tc.desc: Returns the uid based on the specified user name.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testProcessManagerGetUidForName002', 0, function () {
let pro = new process.ProcessManager();
for (let i=0; i<3; i++) {
let pres = pro.getUidForName("12356");
expect(pres).assertEqual(-1);
}
})
/**
* @tc.number:TEST_PROCESSMANAGER_GETUIDFORNAME_003
* @tc.name: testProcessManagerGetUidForName003
* @tc.desc: Returns the uid based on the specified user name.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testProcessManagerGetUidForName003', 0, function () {
let pro = new process.ProcessManager();
for (let i=0; i<5; i++) {
let pres = pro.getUidForName("as123");
expect(pres).assertEqual(-1);
}
})
/**
* @tc.number:TEST_PROCESSMANAGER_GETUIDFORNAME_004
* @tc.name: testGetUidForName004
* @tc.desc: Returns the uid based on the specified user name.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testProcessManagerGetUidForName004',0, function () {
try {
let pro = new process.ProcessManager();
//@ts-ignore
let pres = pro.getUidForName(12);
} catch (e) {
expect(e.toString()).assertEqual("BuisnessError: The type of v must be string.");
}
})
/**
* @tc.number:TEST_PROCESSMANAGER_GETTHREADPRIORITY_001
* @tc.name: testProcessManagerGetThreadPriority001
* @tc.desc: Returns the thread priority based on the specified tid.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testProcessManagerGetThreadPriority001', 0, function () {
let pro = new process.ProcessManager();
let pres = process.tid;
let pri = pro.getThreadPriority(pres);
if (pri) {
let flag = new Boolean(true);
expect(Boolean(flag)).assertEqual(true);
}
})
/**
* @tc.number:TEST_PROCESSMANAGER_GETTHREADPRIORITY_002
* @tc.name: testProcessManagerGetThreadPriority002
* @tc.desc: Returns the thread priority based on the specified tid.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testProcessManagerGetThreadPriority002', 0, function () {
let pro = new process.ProcessManager();
let pres = process.tid;
for (let i=0; i<3; i++) {
let pri = pro.getThreadPriority(pres);
if (pri > 0) {
let flag = new Boolean(true);
expect(Boolean(flag)).assertEqual(true);
}
}
})
/**
* @tc.number:TEST_PROCESSMANAGER_GETTHREADPRIORITY_003
* @tc.name: testProcessManagerGetThreadPriority003
* @tc.desc: Returns the thread priority based on the specified tid.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testProcessManagerGetThreadPriority003', 0, function () {
let pro = new process.ProcessManager();
let pres = process.tid;
for (let i=0; i<5; i++) {
let pri = pro.getThreadPriority(pres);
if (pri > 0) {
let flag = new Boolean(true);
expect(Boolean(flag)).assertEqual(true);
}
}
})
/**
* @tc.number:TEST_PROCESSMANAGER_GETTHREADPRIORITY_004
* @tc.name: testProcessManagerGetThreadPriority004
* @tc.desc: Returns the thread priority based on the specified tid.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testProcessManagerGetThreadPriority004', 0, function () {
try {
let pro = new process.ProcessManager();
//@ts-ignore
let pri = pro.getThreadPriority("asdad");
} catch (e) {
expect(e.toString()).assertEqual("BuisnessError: The type of v must be number.");
}
})
/**
* @tc.number:TEST_PROCESSMANAGER_GETSYSTEMCONFIG_001
* @tc.name: testProcessManagerGetSystemConfig001
* @tc.desc: Returns the system configuration at runtime.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testProcessManagerGetSystemConfig001', 0, function () {
let pro = new process.ProcessManager();
let _SC_ARG_MAX = 0;
let pri = pro.getSystemConfig(_SC_ARG_MAX);
if (pri > 0) {
var flag = new Boolean(true);
}
expect(Boolean(flag)).assertEqual(true);
})
/**
* @tc.number:TEST_PROCESSMANAGER_GETSYSTEMCONFIG_002
* @tc.name: testProcessManagerGetSystemConfig002
* @tc.desc: Returns the system configuration at runtime.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testProcessManagerGetSystemConfig002', 0, function () {
let pro = new process.ProcessManager();
let _SC_ARG_MAX = 0;
for (let i=0; i<3; i++) {
let pri = pro.getSystemConfig(_SC_ARG_MAX);
if (pri > 0) {
var flag = new Boolean(true);
}
expect(Boolean(flag)).assertEqual(true);
}
})
/**
* @tc.number:TEST_PROCESSMANAGER_GETSYSTEMCONFIG_003
* @tc.name: testProcessManagerGetSystemConfig003
* @tc.desc: Returns the system configuration at runtime.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testProcessManagerGetSystemConfig003', 0, function () {
let pro = new process.ProcessManager();
let _SC_ARG_MAX = 0;
for (let i=0; i<5; i++) {
let pri = pro.getSystemConfig(_SC_ARG_MAX);
if (pri > 0) {
var flag = new Boolean(true);
}
expect(Boolean(flag)).assertEqual(true);
}
})
/**
* @tc.number:TEST_PROCESSMANAGER_GETSYSTEMCONFIG_004
* @tc.name: testProcessManagerGetSystemConfig004
* @tc.desc: Returns the system configuration at runtime.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testProcessManagerGetSystemConfig004', 0, function () {
let pro = new process.ProcessManager();
let _SC_OPEN_MAX = 4
let pri = pro.getSystemConfig(_SC_OPEN_MAX);
if (pri > 0) {
var flag = new Boolean(true);
}
expect(Boolean(flag)).assertEqual(true);
})
/**
* @tc.number:TEST_PROCESSMANAGER_GETSYSTEMCONFIG_005
* @tc.name: testProcessManagerGetSystemConfig005
* @tc.desc: Returns the system configuration at runtime.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testProcessManagerGetSystemConfig005', 0, function () {
let pro = new process.ProcessManager();
let _SC_PAGESIZE = 8;
let pri = pro.getSystemConfig(_SC_PAGESIZE);
if (pri > 0) {
var flag = new Boolean(true);
}
expect(Boolean(flag)).assertEqual(true);
})
/**
* @tc.number:TEST_PROCESSMANAGER_GETSYSTEMCONFIG_006
* @tc.name: testGetSystemConfig006
* @tc.desc: Returns the system configuration at runtime.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testProcessManagerGetSystemConfig006', 0, function () {
try {
let pro = new process.ProcessManager();
//@ts-ignore
let pri = pro.getSystemConfig("asdad");
} catch (e) {
expect(e.toString()).assertEqual("BuisnessError: The type of v must be number.");
}
})
/**
* @tc.number:TEST_PROCESSMANAGER_GETENVIRONMENTVAR_001
* @tc.name: testProcessManagerGetEnvironmentVar001
* @tc.desc: Returns the system value for environment variables.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testProcessManagerGetEnvironmentVar001', 0, function () {
let pro = new process.ProcessManager();
let pri = pro.getEnvironmentVar("USER");
if (pri != null) {
var flag = new Boolean(true);
expect(Boolean(flag)).assertEqual(true);
}
})
/**
* @tc.number:TEST_PROCESSMANAGER_GETENVIRONMENTVAR_002
* @tc.name: testProcessManagerGetEnvironmentVar002
* @tc.desc: Returns the system value for environment variables.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testProcessManagerGetEnvironmentVar002', 0, function () {
let pro = new process.ProcessManager();
for (let i=0; i<3; i++) {
let pri = pro.getEnvironmentVar("PATH");
if (pri != null) {
var flag = new Boolean(true);
expect(Boolean(flag)).assertEqual(true);
}
}
})
/**
* @tc.number:TEST_PROCESSMANAGER_GETENVIRONMENTVAR_003
* @tc.name: testProcessManagerGetEnvironmentVar003
* @tc.desc: Returns the system value for environment variables.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testProcessManagerGetEnvironmentVar003', 0, function () {
let pro = new process.ProcessManager();
for (let i=0; i<100; i++) {
let pri = pro.getEnvironmentVar("i123");
if (pri == null) {
var flag = new Boolean(true);
expect(Boolean(flag)).assertEqual(true);
}
}
})
/**
* @tc.number:TEST_PROCESSMANAGER_GETENVIRONMENTVAR_004
* @tc.name: testGetEnvironmentVar004
* @tc.desc: Returns the system value for environment variables.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testProcessManagerGetEnvironmentVar004', 0, function () {
try {
let pro = new process.ProcessManager();
//@ts-ignore
let pri = pro.getEnvironmentVar(123);
} catch (e) {
expect(e.toString()).assertEqual("BuisnessError: The type of v must be string.");
}
})
/**
* @tc.number:TEST_PROCESSMANAGER_KILL_001
* @tc.name: testProcessManagerKill001
* @tc.desc: Return whether the signal was sent successfully.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testProcessManagerKill001', 0, function () {
let pro = new process.ProcessManager();
let result = pro.kill(3, 123);
expect(result).assertEqual(false);
})
/**
* @tc.number:TEST_PROCESSMANAGER_KILL_002
* @tc.name: testProcessManagerKill002
* @tc.desc: Return whether the signal was sent successfully.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testProcessManagerKill002', 0, function () {
let pro = new process.ProcessManager();
let pres = process.pid;
let result = pro.kill(23, pres);
expect(result).assertEqual(true);
})
/**
* @tc.number:TEST_PROCESSMANAGER_KILL_003
* @tc.name: testProcessManagerKill003
* @tc.desc: Return whether the signal was sent successfully.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testProcessManagerKill003', 0, function () {
let pro = new process.ProcessManager();
let pres = process.pid;
let result = pro.kill(28, pres);
expect(result).assertEqual(true);
})
/**
* @tc.number:TEST_PROCESSMANAGER_KILL_004
* @tc.name: testProcessManagerKill004
* @tc.desc: Return whether the signal was sent successfully.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testProcessManagerKill004', 0, function () {
let pro = new process.ProcessManager();
let result = pro.kill(3, 113);
expect(result).assertEqual(false);
})
/**
* @tc.number:TEST_PROCESSMANAGER_KILL_005
* @tc.name: testProcessManagerKill005
* @tc.desc: Return whether the signal was sent successfully.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testProcessManagerKill005', 0, function () {
try {
let pro = new process.ProcessManager();
//@ts-ignore
let result = pro.kill("asd", 123);
} catch (e) {
expect(e.toString()).assertEqual("BuisnessError: The type of v must be number.");
}
})
})
describe('ProcessTest', function () {
/**
* @tc.number:TEST_EGID_001
* @tc.name: testEgid001
* @tc.desc: Returns the numeric valid group ID of the process
* @tc.size: MediumTest
* @tc.type: Constant
* @tc.level: level 2
*/
it('testEgid001', 0, function () {
let result = process.egid;
if (result > 0) {
var flag = true;
}
expect(flag).assertEqual(true);
})
/**
* @tc.number:TEST_EGID_002
* @tc.name: testEgid002
* @tc.desc: Returns the numeric valid group ID of the process
* @tc.size: MediumTest
* @tc.type: Constant
* @tc.level: level 2
*/
it('testEgid002', 0, function () {
for (let i = 0; i < 3; i++) {
let result = process.egid;
if (result != null) {
if (result > 0) {
var flag = true;
}
expect(flag).assertEqual(true);
}
}
})
/**
* @tc.number:TEST_EUID_001
* @tc.name: testEuid001
* @tc.desc: Return the numeric valid user identity of the process
* @tc.size: MediumTest
* @tc.type: Constant
* @tc.level: level 2
*/
it('testEuid001', 0, function () {
let result = process.euid;
if (result > 0) {
var flag = true;
}
expect(flag).assertEqual(true);
})
/**
* @tc.number:TEST_EUID_002
* @tc.name: testEuid002
* @tc.desc: Return the numeric valid user identity of the process
* @tc.size: MediumTest
* @tc.type: Constant
* @tc.level: level 2
*/
it('testUid002', 0, function () {
for (let i = 0; i < 3; i++) {
let result = process.euid;
if (result != null) {
if (result > 0) {
var flag = true;
}
expect(flag).assertEqual(true);
}
}
})
/**
* @tc.number:TEST_GID_001
* @tc.name: testGid001
* @tc.desc: Return the numeric group if of the process
* @tc.size: MediumTest
* @tc.type: Constant
* @tc.level: level 2
*/
it('testGid001', 0, function () {
let result = process.gid;
if (result > 0) {
var flag = true;
}
expect(flag).assertEqual(true);
})
/**
* @tc.number:TEST_GID_002
* @tc.name: testGid002
* @tc.desc: Return the numeric group if of the process
* @tc.size: MediumTest
* @tc.type: Constant
* @tc.level: level 2
*/
it('testGid002', 0, function () {
for (let i = 0; i < 3; i++) {
let result = process.gid;
if (result != null) {
if (result > 0) {
var flag = true;
}
expect(flag).assertEqual(true);
}
}
})
/**
* @tc.number:TEST_Uid_001
* @tc.name: testUid001
* @tc.desc: returns the digital user id of the process.
* @tc.size: MediumTest
* @tc.type: Constant
* @tc.level: level 2
*/
it('testUid001', 0, function () {
let result = process.uid;
if (result > 0) {
var flag = true;
}
expect(flag).assertEqual(true);
})
/**
* @tc.number:TEST_Uid_002
* @tc.name: testUid002
* @tc.desc: returns the digital user id of the process.
* @tc.size: MediumTest
* @tc.type: Constant
* @tc.level: level 2
*/
it('testUid002', 0, function () {
for (let i = 0; i < 3; i++) {
let result = process.uid;
if (result != null) {
if (result > 0) {
var flag = true;
}
expect(flag).assertEqual(true);
}
}
})
/**
* @tc.number:TEST_Uid_003
* @tc.name: testUid003
* @tc.desc: returns the digital user id of the process.
* @tc.size: MediumTest
* @tc.type: Constant
* @tc.level: level 2
*/
it('testUid003', 0, function () {
for (let i = 0; i < 6; i++) {
let result = process.uid;
if (result != null) {
if (result > 0) {
var flag = true;
}
expect(flag).assertEqual(true);
}
}
})
/**
* @tc.number:TEST_Uid_004
* @tc.name: testUid004
* @tc.desc: returns the digital user id of the process.
* @tc.size: MediumTest
* @tc.type: Constant
* @tc.level: level 2
*/
it('testUid004', 0, function () {
for (let i = 0; i < 8; i++) {
let result = process.uid;
if (result != null) {
if (result > 0) {
var flag = true;
}
expect(flag).assertEqual(true);
}
}
})
/**
* @tc.number:TEST_Uid_005
* @tc.name: testUid005
* @tc.desc: returns the digital user id of the process.
* @tc.size: MediumTest
* @tc.type: Constant
* @tc.level: level 2
*/
it('testUid005', 0, function () {
for (let i = 0; i < 5; i++){
let result = process.uid;
if (result != null) {
if (result > 0) {
var flag = true;
}
expect(flag).assertEqual(true);
}
}
})
/**
* @tc.number:TEST_GROUPS_001
* @tc.name: testGroups001
* @tc.desc: Return an array with supplementary group id
* @tc.size: MediumTest
* @tc.type: Constant
* @tc.level: level 2
*/
it('testGroups001', 0, function () {
let result = process.groups;
if (result != null) {
var flag = true;
}
expect(flag).assertEqual(true);
})
/**
* @tc.number:TEST_PID_001
* @tc.name: testPid001
* @tc.desc: Return pid is the pid of the current process.
* @tc.size: MediumTest
* @tc.type: Constant
* @tc.level: level 2
*/
it('testPid001', 0, function () {
let result = process.pid;
if (result > 0) {
var flag = true;
}
expect(flag).assertEqual(true);
})
/**
* @tc.number:TEST_PID_002
* @tc.name: testPid002
* @tc.desc: Return pid is the pid of the current process.
* @tc.size: MediumTest
* @tc.type: Constant
* @tc.level: level 2
*/
it('testPid002', 0, function () {
for (let i = 0; i < 3; i++) {
let result = process.pid;
if (result > 0) {
var flag = true;
}
expect(flag).assertEqual(true);
}
})
/**
* @tc.number:TEST_PID_003
* @tc.name: testPid003
* @tc.desc: Return pid is the pid of the current process.
* @tc.size: MediumTest
* @tc.type: Constant
* @tc.level: level 2
*/
it('testPid003', 0, function () {
for (let i = 0; i < 5; i++) {
let result = process.pid;
if (result > 0) {
var flag = true;
}
expect(flag).assertEqual(true);
}
})
/**
* @tc.number:TEST_PID_004
* @tc.name: testPid004
* @tc.desc: Return pid is the pid of the current process.
* @tc.size: MediumTest
* @tc.type: Constant
* @tc.level: level 2
*/
it('testPid004', 0, function () {
for (let i = 0; i < 6; i++) {
let result = process.pid;
if (result > 0) {
var flag = true;
}
expect(flag).assertEqual(true);
}
})
/**
* @tc.number:TEST_PID_005
* @tc.name: testPid005
* @tc.desc: Return pid is the pid of the current process.
* @tc.size: MediumTest
* @tc.type: Constant
* @tc.level: level 2
*/
it('testPid005', 0, function () {
for (let i = 0; i < 8; i++) {
let result = process.pid;
if (result > 0) {
var flag = true;
}
expect(flag).assertEqual(true);
}
})
/**
* @tc.number:TEST_PPID_001
* @tc.name: testPpid001
* @tc.desc: Return ppid is The pid of the current child process
* @tc.size: MediumTest
* @tc.type: Constant
* @tc.level: level 2
*/
it('testTid001', 0, function () {
let pres = process.ppid;
if (pres > 0) {
var flag = new Boolean(true);
}
expect(Boolean(flag)).assertEqual(true);
})
/**
* @tc.number:TEST_PPID_002
* @tc.name: testPpid002
* @tc.desc: Return ppid is The pid of the current child process
* @tc.size: MediumTest
* @tc.type: Constant
* @tc.level: level 2
*/
it('testPpid002', 0, function () {
for (let i = 0; i < 8; i++) {
let result = process.ppid;
if (result > 0) {
var flag = true;
}
expect(flag).assertEqual(true);
}
})
/**
* @tc.number:TEST_TID_001
* @tc.name: testTid001
* @tc.desc: Returns the tid of the current thread.
* @tc.size: MediumTest
* @tc.type: Constant
* @tc.level: level 2
*/
it('testTid001', 0, function () {
let pres = process.tid;
if (pres > 0) {
var flag = new Boolean(true);
}
expect(Boolean(flag)).assertEqual(true);
})
/**
* @tc.number:TEST_TID_002
* @tc.name: testTid002
* @tc.desc: Returns the tid of the current thread.
* @tc.size: MediumTest
* @tc.type: Constant
* @tc.level: level 2
*/
it('testTid002', 0, function () {
for (let i=0; i < 5; i++) {
let pres = process.tid;
if (pres > 0) {
var flag = new Boolean(true);
}
expect(Boolean(flag)).assertEqual(true);
}
})
/**
* @tc.number:TEST_TID_003
* @tc.name: testTid003
* @tc.desc: Returns the tid of the current thread.
* @tc.size: MediumTest
* @tc.type: Constant
* @tc.level: level 2
*/
it('testTid003', 0, function () {
for (let i=0; i < 3; i++) {
let pres = process.tid;
if (pres > 0) {
var flag = new Boolean(true);
}
expect(Boolean(flag)).assertEqual(true);
}
})
/**
* @tc.number:TEST_IS64BIT_001
* @tc.name: testIs64Bit001
* @tc.desc: Returns a boolean whether the process is running in a 64-bit environment.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testIs64Bit001', 0, function () {
let isorno = process.is64Bit();
if (isorno) {
expect(isorno).assertEqual(true);
} else {
expect(isorno).assertEqual(false);
}
})
/**
* @tc.number:TEST_IS64BIT_002
* @tc.name: testIs64Bit002
* @tc.desc: Returns a boolean whether the process is running in a 64-bit environment.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testIs64Bit002', 0, function () {
for (let i=0; i<3; i++) {
let isorno = process.is64Bit();
if (isorno) {
expect(isorno).assertEqual(true);
} else {
expect(isorno).assertEqual(false);
}
}
})
/**
* @tc.number:TEST_IS64BIT_003
* @tc.name: testIs64Bit003
* @tc.desc: Returns a boolean whether the process is running in a 64-bit environment.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testIs64Bit003', 0, function () {
for (let i=0; i<5; i++) {
let isorno = process.is64Bit();
if (isorno) {
expect(isorno).assertEqual(true);
} else {
expect(isorno).assertEqual(false);
}
}
})
/**
* @tc.number:TEST_GET_START_REALTIME_001
* @tc.name: testGetStartRealtime001
* @tc.desc: Returns the elapsed real time (in milliseconds) taken from the start of
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testGetStartRealtime001', 0, function () {
for (let i=0; i<3; i++) {
let pri = process.getStartRealtime();
if (pri !== null) {
var flag = new Boolean(true);
}
expect(Boolean(flag)).assertEqual(true);
}
})
/**
* @tc.number:TEST_GET_START_REALTIME_002
* @tc.name: testGetStartRealtime002
* @tc.desc: Returns the elapsed real time (in milliseconds) taken from the start of
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testGetStartRealtime002', 0, function () {
let pri = process.getStartRealtime();
if (pri !== null) {
var flag = new Boolean(true);
}
expect(Boolean(flag)).assertEqual(true);
})
/**
* @tc.number:TEST_GET_START_REALTIME_003
* @tc.name: testGetStartRealtime003
* @tc.desc: Returns the elapsed real time (in milliseconds) taken from the start of
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testGetStartRealtime003', 0, function () {
for (let i=0; i<5; i++) {
let pri = process.getStartRealtime();
if (pri !== null) {
var flag = new Boolean(true);
}
expect(Boolean(flag)).assertEqual(true);
}
})
/**
* @tc.number:TEST_GET_START_REALTIME_004
* @tc.name: testGetStartRealtime004
* @tc.desc: Returns the elapsed real time (in milliseconds)
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testGetStartRealtime004', 0, function () {
for (let i=0; i<8; i++) {
let pri = process.getStartRealtime();
if (pri !== null) {
var flag = new Boolean(true);
}
expect(Boolean(flag)).assertEqual(true);
}
})
/**
* @tc.number:TEST_GET_START_REALTIME_005
* @tc.name: testGetStartRealtime005
* @tc.desc: Returns the elapsed real time (in milliseconds) taken from the start of
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testGetStartRealtime005', 0, function () {
for (let i=0; i<6; i++) {
let pri = process.getStartRealtime();
if (pri !== null) {
var flag = new Boolean(true);
}
expect(Boolean(flag)).assertEqual(true);
}
})
/**
* @tc.number:TEST_GET_PAST_CPU_TIME_001
* @tc.name: testGetpastCpuTime001
* @tc.desc: Returns the cpu time (in milliseconds) from the time when the process starts to the current time.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testGetpastCpuTime001', 0, function () {
for (let i=0; i<3; i++) {
let pri = process.getPastCpuTime();
if (pri > 0) {
var flag = new Boolean(true);
}
expect(Boolean(flag)).assertEqual(true);
}
})
/**
* @tc.number:TEST_GET_PAST_CPU_TIME_002
* @tc.name: testGetpastCpuTime002
* @tc.desc: Returns the cpu time (in milliseconds) from the time when the process starts to the current time.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testGetpastCpuTime002', 0, function () {
let pri = process.getPastCpuTime();
if (pri > 0) {
var flag = new Boolean(true);
}
expect(Boolean(flag)).assertEqual(true);
})
/**
* @tc.number:TEST_GET_PAST_CPU_TIME_003
* @tc.name: testGetpastCpuTime003
* @tc.desc: Returns the cpu time (in milliseconds) from the time when the process starts to the current time.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testGetpastCpuTime003', 0, function () {
for (let i=0; i<5; i++) {
let pri = process.getPastCpuTime();
if (pri > 0) {
var flag = new Boolean(true);
}
expect(Boolean(flag)).assertEqual(true);
}
})
/**
* @tc.number:TEST_GET_PAST_CPU_TIME_004
* @tc.name: testGetpastCpuTime004
* @tc.desc: Returns the cpu time (in milliseconds) from the time when the process starts to the current time.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testGetpastCpuTime004', 0, function () {
for (let i=0; i<8; i++) {
let pri = process.getPastCpuTime();
if (pri > 0) {
var flag = new Boolean(true);
}
expect(Boolean(flag)).assertEqual(true);
}
})
/**
* @tc.number:TEST_CWD_001
* @tc.name: testCwd001
* @tc.desc: Return the current work directory
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testCwd001', 0, function () {
let result=process.cwd();
expect(result!=null).assertTrue();
})
/**
* @tc.number:TEST_CHDIR_001
* @tc.name: testChdir001
* @tc.desc: Change current directory
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testChdir001', 0, function () {
let result=process.cwd();
let result1=process.chdir(result);
expect(result!=null).assertTrue();
})
/**
* @tc.number:TEST_UPTIME_001
* @tc.name: testUptime001
* @tc.desc: Returns the running time of the system.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testUptime001', 0, function () {
let result1 = process.uptime();
function sleep(d){
while(process.uptime() - result1 <= d);
}
sleep(6);
let result2 = process.uptime();
var flag = false
if ((result2 - result1) >= 6) {
flag = true;
}
expect(flag).assertEqual(true);
})
/**
* @tc.number:TEST_UPTIME_002
* @tc.name: testUptime002
* @tc.desc: Returns the running time of the system.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testUptime002', 0, function () {
let result1 = process.uptime();
function sleep(d){
while (process.uptime() - result1 <= d);
}
sleep(8);
let result2 = process.uptime();
var flag = false;
if ((result2 - result1) >= 8) {
flag = true;
}
expect(flag).assertEqual(true);
})
/**
* @tc.number:TEST_UPTIME_003
* @tc.name: testUptime003
* @tc.desc: Returns the running time of the system.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testUptime003', 0, function () {
let result1 = process.uptime();
function sleep(d){
while (process.uptime() - result1 <= d);
}
sleep(10);
let result2 = process.uptime();
var flag = false;
if ((result2 - result1) >= 10) {
flag = true;
}
expect(flag).assertEqual(true);
})
/**
* @tc.number:TEST_UPTIME_004
* @tc.name: testUptime004
* @tc.desc: Returns the running time of the system.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testUptime004', 0, function () {
let result1 = process.uptime();
function sleep(d){
while (process.uptime() - result1 <= d);
}
sleep(7);
let result2 = process.uptime();
var flag = false;
if ((result2 - result1) >= 7) {
flag = true;
}
expect(flag).assertEqual(true);
})
/**
* @tc.number:TEST_UPTIME_005
* @tc.name: testUptime005
* @tc.desc: Returns the running time of the system.
* @tc.size: MediumTest
* @tc.type: Method
* @tc.level: level 2
*/
it('testUptime005', 0, function () {
let result1 = process.uptime();
function sleep(d){
while (process.uptime() - result1 <= d);
}
sleep(11);
let result2 = process.uptime();
var flag = false;
if ((result2 - result1) >= 11) {
flag = true;
}
expect(flag).assertEqual(true);
})
})
}
\ No newline at end of file
{
"module": {
"name": "entry_test",
"type": "feature",
"description": "$string:module_test_desc",
"mainElement": "TestAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:test_pages",
"abilities": [
{
"name": "TestAbility",
"srcEntry": "./ets/TestAbility/TestAbility.ets",
"description": "$string:TestAbility_desc",
"icon": "$media:icon",
"label": "$string:TestAbility_label",
"exported": true,
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
}
]
}
}
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_test_desc",
"value": "test ability description"
},
{
"name": "TestAbility_desc",
"value": "the test ability"
},
{
"name": "TestAbility_label",
"value": "test label"
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册