diff --git a/compileruntime/BUILD.gn b/compileruntime/BUILD.gn
index 21770fe0e8dd912046b46d27d33450f2e37e0727..265545f58fbac1d92849278911851fa178f3c993 100644
--- a/compileruntime/BUILD.gn
+++ b/compileruntime/BUILD.gn
@@ -17,6 +17,8 @@ group("compileruntime") {
if (is_standard_system) {
deps = [
"ark_intl_standard/intljs:intljs_test",
+ "containerLine_lib_standard:containerLine_js_test",
+ "containerRelation_lib_standard:containerRelation_js_test",
"convertxml_lib_standard:convertxml_js_test",
"uri_lib_standard:uri_js_test",
"url_lib_standard:url_js_test",
diff --git a/compileruntime/containerLine_lib_standard/BUILD.gn b/compileruntime/containerLine_lib_standard/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..fc82a328b24d350e1f02f6346e072fb034e713e7
--- /dev/null
+++ b/compileruntime/containerLine_lib_standard/BUILD.gn
@@ -0,0 +1,39 @@
+# Copyright (C) 2021 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("containerLine_js_test") {
+ hap_profile = "./src/main/config.json"
+ js2abc = true
+ deps = [
+ ":containerLine_js_assets",
+ ":containerLine_resources",
+ ]
+
+ # shared_libraries = [
+ # "//third_party/giflib:libgif",
+ # "//third_party/libpng:libpng",
+ # ]
+ certificate_profile = "./signature/openharmony_sx.p7b"
+ hap_name = "ActsContainerLineJsTest"
+
+ # part_name = "prebuilt_hap"
+ # subsystem_name = "xts"
+}
+ohos_js_assets("containerLine_js_assets") {
+ source_dir = "./src/main/js/default"
+}
+ohos_resources("containerLine_resources") {
+ sources = [ "./src/main/resources" ]
+ hap_profile = "./src/main/config.json"
+}
diff --git a/compileruntime/containerLine_lib_standard/Test.json b/compileruntime/containerLine_lib_standard/Test.json
new file mode 100644
index 0000000000000000000000000000000000000000..f0b2227089c25a180777059da8f45eaf05f752d6
--- /dev/null
+++ b/compileruntime/containerLine_lib_standard/Test.json
@@ -0,0 +1,18 @@
+{
+ "description": "Configuration for startup util js api Tests",
+ "driver": {
+ "type": "JSUnitTest",
+ "test-timeout": "300000",
+ "package": "com.example.containerLine",
+ "shell-timeout": "60000"
+ },
+ "kits": [
+ {
+ "test-file-name": [
+ "ActsContainerLineJsTest.hap"
+ ],
+ "type": "AppInstallKit",
+ "cleanup-apps": true
+ }
+ ]
+}
\ No newline at end of file
diff --git a/compileruntime/containerLine_lib_standard/signature/openharmony_sx.p7b b/compileruntime/containerLine_lib_standard/signature/openharmony_sx.p7b
new file mode 100644
index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5
Binary files /dev/null and b/compileruntime/containerLine_lib_standard/signature/openharmony_sx.p7b differ
diff --git a/compileruntime/containerLine_lib_standard/src/main/config.json b/compileruntime/containerLine_lib_standard/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..f387e1f0b398b54dbfff9e0ecdb5f127a2795dae
--- /dev/null
+++ b/compileruntime/containerLine_lib_standard/src/main/config.json
@@ -0,0 +1,62 @@
+{
+ "app": {
+ "bundleName": "com.example.containerLine",
+ "vendor": "example",
+ "version": {
+ "code": 1000000,
+ "name": "1.0.0"
+ },
+ "apiVersion": {
+ "compatible": 4,
+ "target": 5
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.example.containerLine",
+ "name": ".MyApplication",
+ "mainAbility": "com.example.containerLine.MainAbility",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry",
+ "moduleType": "entry",
+ "installationFree": false
+ },
+ "abilities": [
+ {
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ],
+ "visible": true,
+ "name": "com.example.containerLine.MainAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:entry_MainAbility",
+ "type": "page",
+ "launchType": "standard"
+ }
+ ],
+ "js": [
+ {
+ "pages": [
+ "pages/index/index"
+ ],
+ "name": "default",
+ "window": {
+ "designWidth": 720,
+ "autoDesignWidth": true
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/compileruntime/containerLine_lib_standard/src/main/js/default/app.js b/compileruntime/containerLine_lib_standard/src/main/js/default/app.js
new file mode 100644
index 0000000000000000000000000000000000000000..ef92b6e96e9db7d997b0be7c2068d560b1cab26d
--- /dev/null
+++ b/compileruntime/containerLine_lib_standard/src/main/js/default/app.js
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+export default {
+ onCreate() {
+ console.info('AceApplication onCreate');
+ },
+ onDestroy() {
+ console.info('AceApplication onDestroy');
+ }
+};
diff --git a/compileruntime/containerLine_lib_standard/src/main/js/default/i18n/en-US.json b/compileruntime/containerLine_lib_standard/src/main/js/default/i18n/en-US.json
new file mode 100644
index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c
--- /dev/null
+++ b/compileruntime/containerLine_lib_standard/src/main/js/default/i18n/en-US.json
@@ -0,0 +1,6 @@
+{
+ "strings": {
+ "hello": "Hello",
+ "world": "World"
+ }
+}
\ No newline at end of file
diff --git a/compileruntime/containerLine_lib_standard/src/main/js/default/i18n/zh-CN.json b/compileruntime/containerLine_lib_standard/src/main/js/default/i18n/zh-CN.json
new file mode 100644
index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f
--- /dev/null
+++ b/compileruntime/containerLine_lib_standard/src/main/js/default/i18n/zh-CN.json
@@ -0,0 +1,6 @@
+{
+ "strings": {
+ "hello": "您好",
+ "world": "世界"
+ }
+}
\ No newline at end of file
diff --git a/compileruntime/containerLine_lib_standard/src/main/js/default/pages/index/index.css b/compileruntime/containerLine_lib_standard/src/main/js/default/pages/index/index.css
new file mode 100644
index 0000000000000000000000000000000000000000..2b1965821483f4f8c8b97c86ef07fe87ea767d01
--- /dev/null
+++ b/compileruntime/containerLine_lib_standard/src/main/js/default/pages/index/index.css
@@ -0,0 +1,44 @@
+.container {
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+}
+
+.title {
+ font-size: 40px;
+ color: #000000;
+ opacity: 0.9;
+}
+
+@media screen and (device-type: tablet) and (orientation: landscape) {
+ .title {
+ font-size: 100px;
+ }
+}
+
+@media screen and (device-type: wearable) {
+ .title {
+ font-size: 28px;
+ color: #FFFFFF;
+ }
+}
+
+@media screen and (device-type: tv) {
+ .container {
+ background-image: url("../../common/images/Wallpaper.png");
+ background-size: cover;
+ background-repeat: no-repeat;
+ background-position: center;
+ }
+
+ .title {
+ font-size: 100px;
+ color: #FFFFFF;
+ }
+}
+
+@media screen and (device-type: phone) and (orientation: landscape) {
+ .title {
+ font-size: 60px;
+ }
+}
diff --git a/compileruntime/containerLine_lib_standard/src/main/js/default/pages/index/index.hml b/compileruntime/containerLine_lib_standard/src/main/js/default/pages/index/index.hml
new file mode 100644
index 0000000000000000000000000000000000000000..20a4e40d9a4ee698bf8e485840457dd43233a376
--- /dev/null
+++ b/compileruntime/containerLine_lib_standard/src/main/js/default/pages/index/index.hml
@@ -0,0 +1,5 @@
+
+
+ {{ $t('strings.hello') }} {{title}}
+
+
\ No newline at end of file
diff --git a/compileruntime/containerLine_lib_standard/src/main/js/default/pages/index/index.js b/compileruntime/containerLine_lib_standard/src/main/js/default/pages/index/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..300a1758a515674d193b32a393c1b1da897614d8
--- /dev/null
+++ b/compileruntime/containerLine_lib_standard/src/main/js/default/pages/index/index.js
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2021 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 file from '@system.file'
+import app from '@system.app'
+import device from '@system.device'
+import router from '@system.router'
+import {Core} from 'deccjsunit/index'
+
+export default {
+ data: {
+ title: ""
+ },
+ onInit() {
+ this.title = this.$t('strings.world');
+ },
+ onShow() {
+ console.info('onShow finish')
+ const core = Core.getInstance()
+ core.init()
+ require('../../../test/Main.test')
+ core.execute()
+ },
+ onReady() {
+ },
+}
\ No newline at end of file
diff --git a/compileruntime/util_lib_standard/src/main/js/test/ArrayList.test.js b/compileruntime/containerLine_lib_standard/src/main/js/test/ArrayList.test.js
similarity index 92%
rename from compileruntime/util_lib_standard/src/main/js/test/ArrayList.test.js
rename to compileruntime/containerLine_lib_standard/src/main/js/test/ArrayList.test.js
index 223b01c79e8071d58b722f8b8f9affe4e8b734f2..c0911dbc18e0c0d9edd3c2327a9ed826630c9ec4 100644
--- a/compileruntime/util_lib_standard/src/main/js/test/ArrayList.test.js
+++ b/compileruntime/containerLine_lib_standard/src/main/js/test/ArrayList.test.js
@@ -1,663 +1,659 @@
-/*
- * Copyright (C) 2021 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 'deccjsunit/index';
-import ArrayList from "@ohos.util.ArrayList";
-
-describe("ArraylistTest", function () {
- it("SR000GGR44_testConstructor001", 0, function () {
- try {
- let arrayList = new ArrayList();
- expect(arrayList != undefined).assertEqual(true);
- } catch (err) {
- expect(err).assertEqual("Error: Cannot create new arrayList");
- }
- });
- it("SR000GGR44_testAdd002", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add("四");
- let res = arrayList.has("四");
- expect(res).assertEqual(true);
- });
- it("SR000GGR44_testAdd003", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add(8);
- let res = arrayList.has(8);
- expect(res).assertEqual(true);
- });
- it("SR000GGR44_testAdd004 ", 0, function () {
- let arrayList = new ArrayList();
- let a = {name: "lala", age: "13岁"};
- arrayList.add(a);
- let res = arrayList.has(a);
- expect(res).assertEqual(true);
- });
- it("SR000GGR44_testAdd005 ", 0, function () {
- let arrayList = new ArrayList();
- let a = [1, 2, 3, 4];
- arrayList.add(a);
- let res = arrayList.has(a);
- expect(res).assertEqual(true);
- });
- it("SR000GGR44_testAdd006 ", 0, function () {
- let arrayList = new ArrayList();
- let a = true;
- arrayList.add(a);
- let res = arrayList.has(a);
- expect(res).assertEqual(true);
- });
- it("SR000GGR44_testInsert007", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add("四");
- arrayList.add("三");
- arrayList.add(1);
- arrayList.add("a");
- arrayList.insert(8, 2);
- let arr = [];
- arrayList.forEach((item, index) => {
- arr.push(item);
- });
- let a = ["四", "三", 8, 1, "a"];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR44_testLength008", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add("四");
- arrayList.add("三");
- arrayList.add(1);
- arrayList.add("a");
- arrayList.insert(8, 2);
- let res = arrayList.length;
- expect(res).assertEqual(5);
- });
- it("SR000GGR44_testHas009", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add("四");
- arrayList.add("三");
- arrayList.add(1);
- arrayList.add("a");
- arrayList.insert(8, 2);
- let res = arrayList.has(8);
- expect(res).assertEqual(true);
- });
- it("SR000GGR44_testGetIndexOf010", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add(1);
- arrayList.add("三");
- arrayList.add(1);
- arrayList.add("a");
- arrayList.insert(1, 2);
- let res1 = arrayList.getIndexOf(1);
- expect(res1).assertEqual(0);
- });
- it("SR000GGR44_testRemoveByIndex011", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add("四");
- arrayList.add("三");
- arrayList.add(1);
- arrayList.add("a");
- arrayList.removeByIndex(2);
- let arr = [];
- arrayList.forEach((item, index) => {
- arr.push(item);
- });
- let a = ["四", "三", "a"];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR44_testRemove012", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add("四");
- arrayList.add("三");
- arrayList.add(1);
- arrayList.add("a");
- arrayList.remove("三");
- let res = arrayList.has("三");
- expect(res).assertEqual(false);
- });
- it("SR000GGR44_testGetLastIndexOf013", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add("四");
- arrayList.add("三");
- arrayList.add(1);
- arrayList.add("a");
- arrayList.add(1);
- arrayList.add("b");
- let res = arrayList.getLastIndexOf(1);
- expect(res).assertEqual(4);
- });
- it("SR000GGR44_testRemoveByRange014", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add("四");
- arrayList.add("三");
- arrayList.add(1);
- arrayList.add("a");
- arrayList.add(1);
- arrayList.add("b");
- arrayList.add("c");
- arrayList.add(1);
- arrayList.removeByRange(1, 3);
- let arr = [];
- arrayList.forEach((item, index) => {
- arr.push(item);
- });
- let a = ["四", "a", 1, "b", "c", 1];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR44_testReplaceAllElements015", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add(4);
- arrayList.add(3);
- arrayList.add(1);
- arrayList.add(2);
- arrayList.add(14);
- arrayList.replaceAllElements((item, index) => {
- return (item = 2 * item);
- });
- let arr = [];
- arrayList.forEach((item, index) => {
- arr.push(item);
- });
- let a = [8, 6, 2, 4, 28];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR44_testForEach016", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add(4);
- arrayList.add(3);
- arrayList.add(1);
- arrayList.add(2);
- arrayList.add(14);
- let arr = [];
- arrayList.forEach((item, index) => {
- arr.push(item);
- });
- let a = [4, 3, 1, 2, 14];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR44_testSubArrayList017", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add(4);
- arrayList.add(3);
- arrayList.add(1);
- arrayList.add(2);
- arrayList.add(14);
- let subArr = arrayList.subArrayList(2, 4);
- let arr = [];
- subArr.forEach((item, index) => {
- arr.push(item);
- });
- let a = [1, 2];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR44_testClear018", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add(4);
- arrayList.add(3);
- arrayList.add(1);
- arrayList.add(2);
- arrayList.add(14);
- arrayList.clear();
- let res = arrayList.length;
- expect(res).assertEqual(0);
- });
- it("SR000GGR44_testConvertToArray19", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add(4);
- arrayList.add(3);
- arrayList.add(1);
- arrayList.add(2);
- arrayList.add(14);
- let arr = arrayList.convertToArray();
- let a = [4, 3, 1, 2, 14];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR44_testClone020", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add(4);
- arrayList.add(3);
- arrayList.add(1);
- arrayList.add(2);
- arrayList.add(14);
- let res = arrayList.clone();
- let arr = [];
- res.forEach((item, index) => {
- arr.push(item);
- });
- let a = [4, 3, 1, 2, 14];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR44_testGetCapacity021", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add(4);
- arrayList.add(3);
- arrayList.add(1);
- arrayList.add(2);
- arrayList.add(14);
- let res = arrayList.getCapacity();
- expect(res).assertEqual(10);
- });
- it("SR000GGR44_testGetCapacity022", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add(4);
- arrayList.add(3);
- arrayList.add(1);
- arrayList.add(2);
- arrayList.add(14);
- arrayList.add("a");
- arrayList.add("b");
- arrayList.add("c");
- arrayList.add("d");
- arrayList.add("v");
- let a = [1, 2, 3, 4];
- arrayList.add(a);
- let res = arrayList.getCapacity();
- expect(res).assertEqual(15);
- });
- it("SR000GGR44_testIncreaseCapacityTo023", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add(4);
- arrayList.add(3);
- arrayList.add(1);
- arrayList.add(2);
- arrayList.add(14);
- arrayList.increaseCapacityTo(8);
- let res = arrayList.getCapacity();
- expect(res).assertEqual(8);
- });
- it("SR000GGR44_testTrimToCurrentLength024", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add(4);
- arrayList.add(3);
- arrayList.add(1);
- arrayList.add(2);
- arrayList.add(14);
- arrayList.trimToCurrentLength();
- let res = arrayList.getCapacity();
- expect(res).assertEqual(5);
- });
- it("SR000GGR44_testIterator025", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add(8);
- arrayList.add("一");
- arrayList.add("二");
- arrayList.add(5);
- let c = [1, 2, 3, 4];
- arrayList.add(c);
- arrayList.add(6);
- arrayList.add("三");
- arrayList.add("四");
- let arr = [];
- for (let item of arrayList) {
- arr.push(item);
- }
- let a = [8, "一", "二", 5, c, 6, "三", "四"];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR44_testSort026", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add(4);
- arrayList.add(3);
- arrayList.add(1);
- arrayList.add(2);
- arrayList.add(14);
- arrayList.sort((a, b) => a - b);
- let arr = [];
- arrayList.forEach((item, index) => {
- arr.push(item);
- });
- let a = [1, 2, 3, 4, 14];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR44_testInsert0027", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add("四");
- arrayList.add("三");
- arrayList.add(1);
- arrayList.add("a");
- try {
- let res = arrayList.insert(8, -1);
- } catch (err) {
- expect(err).assertEqual("Error: ArrayList: get out-of-bounds");
- }
- });
- it("SR000GGR44_testInsert0028", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add("四");
- arrayList.add("三");
- arrayList.add(1);
- arrayList.add("a");
- try {
- let res = arrayList.insert(8, 10);
- } catch (err) {
- expect(err).assertEqual("Error: ArrayList: set out-of-bounds");
- }
- });
- it("SR000GGR44_testInsert029", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add("四");
- arrayList.add("三");
- arrayList.add(1);
- arrayList.add("a");
- try {
- let res = arrayList.insert(8, 11);
- } catch (err) {
- expect(err).assertEqual("Error: ArrayList: set out-of-bounds");
- }
- });
- it("SR000GGR44_testisEmpty030", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add(4);
- arrayList.add(3);
- arrayList.add(1);
- arrayList.add(2);
- arrayList.add(14);
- arrayList.clear();
- let res = arrayList.isEmpty();
- expect(res).assertEqual(true);
- });
- it("SR000GGR44_testisEmpty031", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add(4);
- arrayList.add(3);
- arrayList.add(1);
- arrayList.add(2);
- arrayList.add(14);
- let res = arrayList.isEmpty();
- expect(res).assertEqual(false);
- });
- it("SR000GGR44_testHas032", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add("四");
- arrayList.add("三");
- arrayList.add(1);
- arrayList.add("a");
- arrayList.insert(8, 2);
- let res = arrayList.has("二");
- expect(res).assertEqual(false);
- });
- it("SR000GGR44_testGetIndexOf033", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add(1);
- arrayList.add("三");
- arrayList.add(1);
- arrayList.add("a");
- arrayList.insert(1, 2);
- let res = arrayList.getIndexOf("A");
- expect(res).assertEqual(-1);
- });
- it("SR000GGR44_testRemove034", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add("四");
- arrayList.add("三");
- arrayList.add(1);
- arrayList.add("a");
- let res = arrayList.remove("A");
- expect(res).assertEqual(false);
- });
- it("SR000GGR44_testRemoveByIndex035", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add(0);
- arrayList.add(1);
- arrayList.add(2);
- arrayList.add(1);
- arrayList.add(3);
- arrayList.add(1);
- arrayList.forEach((item, index) => {
- if (item == 1) {
- arrayList.remove(item);
- }
- });
- let arr = [];
- arrayList.forEach((item, index) => {
- arr.push(item);
- });
- let a = [0, 2, 3];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR44_testRemoveByIndex036", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add("a");
- arrayList.add("b");
- arrayList.add("c");
- arrayList.add("a");
- arrayList.add("b");
- try {
- let res = arrayList.removeByIndex(5);
- } catch (err) {
- expect(err).assertEqual("Error: removeByIndex is out-of-bounds");
- }
- });
- it("SR000GGR44_testRemoveByRange037", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add("四");
- arrayList.add("三");
- arrayList.add(1);
- arrayList.add("a");
- arrayList.add(1);
- arrayList.add("b");
- arrayList.add("c");
- arrayList.add(1);
- try {
- let res = arrayList.removeByRange(3, 1);
- } catch (err) {
- expect(err).assertEqual(
- "Error: fromIndex cannot be less than or equal to toIndex"
- );
- }
- });
- it("SR000GGR44_testRemoveByRange038", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add("四");
- arrayList.add("三");
- arrayList.add(1);
- arrayList.add("a");
- arrayList.add(1);
- try {
- let res = arrayList.removeByRange(6, 8);
- } catch (err) {
- expect(err).assertEqual("Error: ArrayList: set out-of-bounds");
- }
- });
- it("SR000GGR44_testRemoveByRange039", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add("四");
- arrayList.add("三");
- arrayList.add(1);
- arrayList.add("a");
- arrayList.add(1);
- arrayList.add("b");
- arrayList.add("c");
- arrayList.add(1);
- arrayList.removeByRange(0, 9);
- let res = arrayList.length;
- let res1 = arrayList.getLastIndexOf(1);
- expect(res).assertEqual(1);
- expect(res1).assertEqual(0);
- });
- it("SR000GGR44_testSubArrayList040", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add(4);
- arrayList.add(3);
- arrayList.add(1);
- arrayList.add(2);
- arrayList.add(14);
- try {
- let subArr = arrayList.subArrayList(4, 2);
- } catch (err) {
- expect(err).assertEqual(
- "Error: fromIndex cannot be less than or equal to toIndex"
- );
- }
- });
- it("SR000GGR44_testSubArrayList041", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add(4);
- arrayList.add(3);
- arrayList.add(1);
- arrayList.add(2);
- arrayList.add(14);
- let subArr = arrayList.subArrayList(0, 6);
- let arr = [];
- arrayList.forEach((item, index) => {
- arr.push(item);
- });
- let a = [4, 3, 1, 2, 14];
- for (let i = 0; i < a.length; i++) {
- expect(a[i]).assertEqual(arr[i]);
- }
- });
- it("SR000GGR44_testSubArrayList042", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add(4);
- arrayList.add(3);
- arrayList.add(1);
- arrayList.add(2);
- arrayList.add(14);
- try {
- let subArr = arrayList.subArrayList(6, 9);
- } catch (err) {
- expect(err).assertEqual("Error: fromIndex or toIndex is out-of-bounds");
- }
- });
- it("SR000GGR44_testIncreaseCapacityTo043", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add(4);
- arrayList.add(3);
- arrayList.add(1);
- arrayList.add(2);
- arrayList.add(14);
- arrayList.increaseCapacityTo(-1);
- let res = arrayList.getCapacity();
- expect(res).assertEqual(10);
- });
- it("SR000GGR44_testIncreaseCapacityTo044", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add(4);
- arrayList.add(3);
- arrayList.add(1);
- arrayList.add(2);
- arrayList.add(14);
- try {
- let res = arrayList.increaseCapacityTo();
- } catch (err) {
- expect(err).assertEqual("ArrayList: set out-of-bounds");
- }
- });
- it("SR000GGR44_testAdd045", 0, function () {
- let arrayList = new ArrayList();
- for (let i = 0; i < 100; i++) {
- arrayList.add(i);
- }
- let res = arrayList.getIndexOf(99);
- let res1 = arrayList.length;
- expect(res).assertEqual(99);
- expect(res1).assertEqual(100);
- });
- it("SR000GGR44_testAdd046", 0, function () {
- let arrayList = new ArrayList();
- let a = "*";
- arrayList.add(a);
- let res = arrayList.has(a);
- expect(res).assertEqual(true);
- });
- it("SR000GGR44_testAdd047", 0, function () {
- let arrayList = new ArrayList();
- let a = "3.14";
- arrayList.add(a);
- let res = arrayList.has(a);
- expect(res).assertEqual(true);
- });
- it("SR000GGR44_testAdd048", 0, function () {
- let arrayList = new ArrayList();
- let a = "";
- arrayList.add(a);
- let res = arrayList.has(a);
- expect(res).assertEqual(true);
- });
- it("SR000GGR44_testSort049", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add("刘");
- arrayList.add("张三");
- arrayList.add(1);
- arrayList.add(2);
- arrayList.add("李四");
- arrayList.sort((a, b) => a - b);
- let arr = [];
- arrayList.forEach((item, index) => {
- arr.push(item);
- });
- let a = ["刘", "张三", 1, 2, "李四"];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR44_testSort050", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add("c");
- arrayList.add("a");
- arrayList.add("b");
- arrayList.add("e");
- arrayList.add("d");
- arrayList.sort((a, b) => a - b);
- let arr = [];
- arrayList.forEach((item, index) => {
- arr.push(item);
- });
- let a = ["c", "a", "b", "e", "d"];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR44_testIterator051", 0, function () {
- let arrayList = new ArrayList();
- arrayList.add("刘");
- arrayList.add("张三");
- arrayList.add(1);
- arrayList.add(2);
- arrayList.add("李四");
- let arr = [];
- let itr = arrayList[Symbol.iterator]();
- let tmp = undefined;
- do {
- tmp = itr.next().value;
- arr.push(tmp);
- } while (tmp != undefined);
- let a = ["刘", "张三", 1, 2, "李四"];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
-});
+/*
+ * Copyright (C) 2021 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 'deccjsunit/index';
+import ArrayList from "@ohos.util.ArrayList";
+
+describe("ArraylistTest", function () {
+ it("SR000GGR44_testConstructor001", 0, function () {
+ try {
+ let arrayList = new ArrayList();
+ expect(arrayList != undefined).assertEqual(true);
+ } catch (err) {
+ expect(err).assertEqual("Error: Cannot create new arrayList");
+ }
+ });
+ it("SR000GGR44_testAdd002", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add("四");
+ let res = arrayList.has("四");
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR44_testAdd003", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add(8);
+ let res = arrayList.has(8);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR44_testAdd004 ", 0, function () {
+ let arrayList = new ArrayList();
+ let a = {name: "lala", age: "13岁"};
+ arrayList.add(a);
+ let res = arrayList.has(a);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR44_testAdd005 ", 0, function () {
+ let arrayList = new ArrayList();
+ let a = [1, 2, 3, 4];
+ arrayList.add(a);
+ let res = arrayList.has(a);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR44_testAdd006 ", 0, function () {
+ let arrayList = new ArrayList();
+ let a = true;
+ arrayList.add(a);
+ let res = arrayList.has(a);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR44_testInsert007", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add("四");
+ arrayList.add("三");
+ arrayList.add(1);
+ arrayList.add("a");
+ arrayList.insert(8, 2);
+ let arr = [];
+ arrayList.forEach((item, index) => {
+ arr.push(item);
+ });
+ let a = ["四", "三", 8, 1, "a"];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR44_testLength008", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add("四");
+ arrayList.add("三");
+ arrayList.add(1);
+ arrayList.add("a");
+ arrayList.insert(8, 2);
+ let res = arrayList.length;
+ expect(res).assertEqual(5);
+ });
+ it("SR000GGR44_testHas009", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add("四");
+ arrayList.add("三");
+ arrayList.add(1);
+ arrayList.add("a");
+ arrayList.insert(8, 2);
+ let res = arrayList.has(8);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR44_testGetIndexOf010", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add(1);
+ arrayList.add("三");
+ arrayList.add(1);
+ arrayList.add("a");
+ arrayList.insert(1, 2);
+ let res1 = arrayList.getIndexOf(1);
+ expect(res1).assertEqual(0);
+ });
+ it("SR000GGR44_testRemoveByIndex011", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add("四");
+ arrayList.add("三");
+ arrayList.add(1);
+ arrayList.add("a");
+ arrayList.removeByIndex(2);
+ let arr = [];
+ arrayList.forEach((item, index) => {
+ arr.push(item);
+ });
+ let a = ["四", "三", "a"];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR44_testRemove012", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add("四");
+ arrayList.add("三");
+ arrayList.add(1);
+ arrayList.add("a");
+ arrayList.remove("三");
+ let res = arrayList.has("三");
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR44_testGetLastIndexOf013", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add("四");
+ arrayList.add("三");
+ arrayList.add(1);
+ arrayList.add("a");
+ arrayList.add(1);
+ arrayList.add("b");
+ let res = arrayList.getLastIndexOf(1);
+ expect(res).assertEqual(4);
+ });
+ it("SR000GGR44_testRemoveByRange014", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add("四");
+ arrayList.add("三");
+ arrayList.add(1);
+ arrayList.add("a");
+ arrayList.add(1);
+ arrayList.add("b");
+ arrayList.add("c");
+ arrayList.add(1);
+ arrayList.removeByRange(1, 3);
+ let arr = [];
+ arrayList.forEach((item, index) => {
+ arr.push(item);
+ });
+ let a = ["四", "a", 1, "b", "c", 1];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR44_testReplaceAllElements015", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add(4);
+ arrayList.add(3);
+ arrayList.add(1);
+ arrayList.add(2);
+ arrayList.add(14);
+ arrayList.replaceAllElements((item, index) => {
+ return (item = 2 * item);
+ });
+ let arr = [];
+ arrayList.forEach((item, index) => {
+ arr.push(item);
+ });
+ let a = [8, 6, 2, 4, 28];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR44_testForEach016", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add(4);
+ arrayList.add(3);
+ arrayList.add(1);
+ arrayList.add(2);
+ arrayList.add(14);
+ let arr = [];
+ arrayList.forEach((item, index) => {
+ arr.push(item);
+ });
+ let a = [4, 3, 1, 2, 14];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR44_testSubArrayList017", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add(4);
+ arrayList.add(3);
+ arrayList.add(1);
+ arrayList.add(2);
+ arrayList.add(14);
+ let subArr = arrayList.subArrayList(2, 4);
+ let arr = [];
+ subArr.forEach((item, index) => {
+ arr.push(item);
+ });
+ let a = [1, 2];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR44_testClear018", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add(4);
+ arrayList.add(3);
+ arrayList.add(1);
+ arrayList.add(2);
+ arrayList.add(14);
+ arrayList.clear();
+ let res = arrayList.length;
+ expect(res).assertEqual(0);
+ });
+ it("SR000GGR44_testConvertToArray19", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add(4);
+ arrayList.add(3);
+ arrayList.add(1);
+ arrayList.add(2);
+ arrayList.add(14);
+ let arr = arrayList.convertToArray();
+ let a = [4, 3, 1, 2, 14];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR44_testClone020", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add(4);
+ arrayList.add(3);
+ arrayList.add(1);
+ arrayList.add(2);
+ arrayList.add(14);
+ let res = arrayList.clone();
+ let arr = [];
+ res.forEach((item, index) => {
+ arr.push(item);
+ });
+ let a = [4, 3, 1, 2, 14];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR44_testGetCapacity021", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add(4);
+ arrayList.add(3);
+ arrayList.add(1);
+ arrayList.add(2);
+ arrayList.add(14);
+ let res = arrayList.getCapacity();
+ expect(res).assertEqual(10);
+ });
+ it("SR000GGR44_testGetCapacity022", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add(4);
+ arrayList.add(3);
+ arrayList.add(1);
+ arrayList.add(2);
+ arrayList.add(14);
+ arrayList.add("a");
+ arrayList.add("b");
+ arrayList.add("c");
+ arrayList.add("d");
+ arrayList.add("v");
+ let a = [1, 2, 3, 4];
+ arrayList.add(a);
+ let res = arrayList.getCapacity();
+ expect(res).assertEqual(15);
+ });
+ it("SR000GGR44_testIncreaseCapacityTo023", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add(4);
+ arrayList.add(3);
+ arrayList.add(1);
+ arrayList.add(2);
+ arrayList.add(14);
+ arrayList.increaseCapacityTo(8);
+ let res = arrayList.getCapacity();
+ expect(res).assertEqual(8);
+ });
+ it("SR000GGR44_testTrimToCurrentLength024", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add(4);
+ arrayList.add(3);
+ arrayList.add(1);
+ arrayList.add(2);
+ arrayList.add(14);
+ arrayList.trimToCurrentLength();
+ let res = arrayList.getCapacity();
+ expect(res).assertEqual(5);
+ });
+ it("SR000GGR44_testIterator025", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add(8);
+ arrayList.add("一");
+ arrayList.add("二");
+ arrayList.add(5);
+ let c = [1, 2, 3, 4];
+ arrayList.add(c);
+ arrayList.add(6);
+ arrayList.add("三");
+ arrayList.add("四");
+ let arr = [];
+ for (let item of arrayList) {
+ arr.push(item);
+ }
+ let a = [8, "一", "二", 5, c, 6, "三", "四"];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR44_testSort026", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add(4);
+ arrayList.add(3);
+ arrayList.add(1);
+ arrayList.add(2);
+ arrayList.add(14);
+ arrayList.sort((a, b) => a - b);
+ let arr = [];
+ arrayList.forEach((item, index) => {
+ arr.push(item);
+ });
+ let a = [1, 2, 3, 4, 14];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR44_testInsert0027", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add("四");
+ arrayList.add("三");
+ arrayList.add(1);
+ arrayList.add("a");
+ try {
+ let res = arrayList.insert(8, -1);
+ } catch (err) {
+ expect(err).assertEqual("RangeError: ArrayList: set out-of-bounds");
+ }
+ });
+ it("SR000GGR44_testInsert0028", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add("四");
+ arrayList.add("三");
+ arrayList.add(1);
+ arrayList.add("a");
+ try {
+ let res = arrayList.insert(8, 10);
+ } catch (err) {
+ expect(err).assertEqual("RangeError: ArrayList: set out-of-bounds");
+ }
+ });
+ it("SR000GGR44_testInsert029", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add("四");
+ arrayList.add("三");
+ arrayList.add(1);
+ arrayList.add("a");
+ try {
+ let res = arrayList.insert(8, 11);
+ } catch (err) {
+ expect(err).assertEqual("RangeError: ArrayList: set out-of-bounds");
+ }
+ });
+ it("SR000GGR44_testisEmpty030", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add(4);
+ arrayList.add(3);
+ arrayList.add(1);
+ arrayList.add(2);
+ arrayList.add(14);
+ arrayList.clear();
+ let res = arrayList.isEmpty();
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR44_testisEmpty031", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add(4);
+ arrayList.add(3);
+ arrayList.add(1);
+ arrayList.add(2);
+ arrayList.add(14);
+ let res = arrayList.isEmpty();
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR44_testHas032", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add("四");
+ arrayList.add("三");
+ arrayList.add(1);
+ arrayList.add("a");
+ arrayList.insert(8, 2);
+ let res = arrayList.has("二");
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR44_testGetIndexOf033", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add(1);
+ arrayList.add("三");
+ arrayList.add(1);
+ arrayList.add("a");
+ arrayList.insert(1, 2);
+ let res = arrayList.getIndexOf("A");
+ expect(res).assertEqual(-1);
+ });
+ it("SR000GGR44_testRemove034", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add("四");
+ arrayList.add("三");
+ arrayList.add(1);
+ arrayList.add("a");
+ let res = arrayList.remove("A");
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR44_testRemoveByIndex035", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add(0);
+ arrayList.add(1);
+ arrayList.add(2);
+ arrayList.add(1);
+ arrayList.add(3);
+ arrayList.add(1);
+ arrayList.forEach((item, index) => {
+ if (item == 1) {
+ arrayList.remove(item);
+ }
+ });
+ let arr = [];
+ arrayList.forEach((item, index) => {
+ arr.push(item);
+ });
+ let a = [0, 2, 3];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR44_testRemoveByIndex036", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add("a");
+ arrayList.add("b");
+ arrayList.add("c");
+ arrayList.add("a");
+ arrayList.add("b");
+ try {
+ let res = arrayList.removeByIndex(5);
+ } catch (err) {
+ expect(err).assertEqual("RangeError: removeByIndex is out-of-bounds");
+ }
+ });
+ it("SR000GGR44_testRemoveByRange037", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add("四");
+ arrayList.add("三");
+ arrayList.add(1);
+ arrayList.add("a");
+ arrayList.add(1);
+ arrayList.add("b");
+ arrayList.add("c");
+ arrayList.add(1);
+ try {
+ let res = arrayList.removeByRange(3, 1);
+ } catch (err) {
+ expect(err).assertEqual("RangeError: fromIndex cannot be less than or equal to toIndex");
+ }
+ });
+ it("SR000GGR44_testRemoveByRange038", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add("四");
+ arrayList.add("三");
+ arrayList.add(1);
+ arrayList.add("a");
+ arrayList.add(1);
+ try {
+ let res = arrayList.removeByRange(6, 8);
+ } catch (err) {
+ expect(err).assertEqual("RangeError: ArrayList: set out-of-bounds");
+ }
+ });
+ it("SR000GGR44_testRemoveByRange039", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add("四");
+ arrayList.add("三");
+ arrayList.add(1);
+ arrayList.add("a");
+ arrayList.add(1);
+ arrayList.add("b");
+ arrayList.add("c");
+ arrayList.add(1);
+ arrayList.removeByRange(0, 9);
+ let res = arrayList.length;
+ let res1 = arrayList.getLastIndexOf(1);
+ expect(res).assertEqual(1);
+ expect(res1).assertEqual(0);
+ });
+ it("SR000GGR44_testSubArrayList040", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add(4);
+ arrayList.add(3);
+ arrayList.add(1);
+ arrayList.add(2);
+ arrayList.add(14);
+ try {
+ let subArr = arrayList.subArrayList(4, 2);
+ } catch (err) {
+ expect(err).assertEqual("RangeError: fromIndex cannot be less than or equal to toIndex");
+ }
+ });
+ it("SR000GGR44_testSubArrayList041", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add(4);
+ arrayList.add(3);
+ arrayList.add(1);
+ arrayList.add(2);
+ arrayList.add(14);
+ let subArr = arrayList.subArrayList(0, 6);
+ let arr = [];
+ arrayList.forEach((item, index) => {
+ arr.push(item);
+ });
+ let a = [4, 3, 1, 2, 14];
+ for (let i = 0; i < a.length; i++) {
+ expect(a[i]).assertEqual(arr[i]);
+ }
+ });
+ it("SR000GGR44_testSubArrayList042", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add(4);
+ arrayList.add(3);
+ arrayList.add(1);
+ arrayList.add(2);
+ arrayList.add(14);
+ try {
+ let subArr = arrayList.subArrayList(6, 9);
+ } catch (err) {
+ expect(err).assertEqual("RangeError: fromIndex or toIndex is out-of-bounds");
+ }
+ });
+ it("SR000GGR44_testIncreaseCapacityTo043", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add(4);
+ arrayList.add(3);
+ arrayList.add(1);
+ arrayList.add(2);
+ arrayList.add(14);
+ arrayList.increaseCapacityTo(-1);
+ let res = arrayList.getCapacity();
+ expect(res).assertEqual(10);
+ });
+ it("SR000GGR44_testIncreaseCapacityTo044", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add(4);
+ arrayList.add(3);
+ arrayList.add(1);
+ arrayList.add(2);
+ arrayList.add(14);
+ try {
+ let res = arrayList.increaseCapacityTo();
+ } catch (err) {
+ expect(err).assertEqual("TypeError: newCapacity is not Integer");
+ }
+ });
+ it("SR000GGR44_testAdd045", 0, function () {
+ let arrayList = new ArrayList();
+ for (let i = 0; i < 100; i++) {
+ arrayList.add(i);
+ }
+ let res = arrayList.getIndexOf(99);
+ let res1 = arrayList.length;
+ expect(res).assertEqual(99);
+ expect(res1).assertEqual(100);
+ });
+ it("SR000GGR44_testAdd046", 0, function () {
+ let arrayList = new ArrayList();
+ let a = "*";
+ arrayList.add(a);
+ let res = arrayList.has(a);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR44_testAdd047", 0, function () {
+ let arrayList = new ArrayList();
+ let a = "3.14";
+ arrayList.add(a);
+ let res = arrayList.has(a);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR44_testAdd048", 0, function () {
+ let arrayList = new ArrayList();
+ let a = "";
+ arrayList.add(a);
+ let res = arrayList.has(a);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR44_testSort049", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add("刘");
+ arrayList.add("张三");
+ arrayList.add(1);
+ arrayList.add(2);
+ arrayList.add("李四");
+ arrayList.sort((a, b) => a - b);
+ let arr = [];
+ arrayList.forEach((item, index) => {
+ arr.push(item);
+ });
+ let a = ["刘", "张三", 1, 2, "李四"];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR44_testSort050", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add("c");
+ arrayList.add("a");
+ arrayList.add("b");
+ arrayList.add("e");
+ arrayList.add("d");
+ arrayList.sort((a, b) => a - b);
+ let arr = [];
+ arrayList.forEach((item, index) => {
+ arr.push(item);
+ });
+ let a = ["c", "a", "b", "e", "d"];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR44_testIterator051", 0, function () {
+ let arrayList = new ArrayList();
+ arrayList.add("刘");
+ arrayList.add("张三");
+ arrayList.add(1);
+ arrayList.add(2);
+ arrayList.add("李四");
+ let arr = [];
+ let itr = arrayList[Symbol.iterator]();
+ let tmp = undefined;
+ do {
+ tmp = itr.next().value;
+ arr.push(tmp);
+ } while (tmp != undefined);
+ let a = ["刘", "张三", 1, 2, "李四"];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+});
diff --git a/compileruntime/util_lib_standard/src/main/js/test/Deque.test.js b/compileruntime/containerLine_lib_standard/src/main/js/test/Deque.test.js
similarity index 96%
rename from compileruntime/util_lib_standard/src/main/js/test/Deque.test.js
rename to compileruntime/containerLine_lib_standard/src/main/js/test/Deque.test.js
index 5b60dac53def97b9c82f5c4641699f7af6619d64..8900f0b78db3c8df3af5ae69a755ae7a9d2c9adf 100644
--- a/compileruntime/util_lib_standard/src/main/js/test/Deque.test.js
+++ b/compileruntime/containerLine_lib_standard/src/main/js/test/Deque.test.js
@@ -1,321 +1,321 @@
-/*
- * Copyright (C) 2021 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 'deccjsunit/index';
-import Deque from "@ohos.util.Deque";
-
-describe("DequeTest", function () {
- it("SR000GGR3K_testConstructor001", 0, function () {
- try {
- let deque = new Deque();
- } catch (err) {
- expect(err).assertEqual("Error:Cannot create new deque");
- }
- });
- it("SR000GGR3K_testInsertFront001", 0, function () {
- let deque = new Deque();
- deque.insertFront("一");
- let res = deque.getFirst();
- expect(res).assertEqual("一");
- });
- it("SR000GGR3K_testInsertFront002", 0, function () {
- let deque = new Deque();
- deque.insertFront(8);
- let res = deque.getFirst();
- expect(res).assertEqual(8);
- });
- it("SR000GGR3K_testInsertFront003", 0, function () {
- let deque = new Deque();
- let a = {name: "lala", age: "15"};
- deque.insertFront(a);
- let res = deque.getFirst();
- expect(res).assertEqual(a);
- });
- it("SR000GGR3K_testInsertFront004", 0, function () {
- let deque = new Deque();
- let a = [1, 2, 3, 4];
- deque.insertFront(a);
- let res = deque.getFirst();
- expect(res).assertEqual(a);
- });
- it("SR000GGR3K_testInsertEnd005", 0, function () {
- let deque = new Deque();
- deque.insertEnd(8);
- let res = deque.getLast();
- expect(res).assertEqual(8);
- });
- it("SR000GGR3K_testInsertEnd006", 0, function () {
- let deque = new Deque();
- let a = ["a", "b", "c"];
- deque.insertEnd(a);
- let res = deque.getLast();
- expect(res).assertEqual(a);
- });
- it("SR000GGR3K_testInsertEnd007", 0, function () {
- let deque = new Deque();
- let a = {class: "6班", say: "we"};
- deque.insertEnd(a);
- let res = deque.getLast();
- expect(res).assertEqual(a);
- });
- it("SR000GGR3K_testGetFirst007", 0, function () {
- let deque = new Deque();
- deque.insertEnd("四");
- deque.insertEnd("三");
- let res = deque.getFirst();
- expect(res).assertEqual("四");
- });
- it("SR000GGR3K_testGetLast008", 0, function () {
- let deque = new Deque();
- deque.insertEnd(8);
- deque.insertEnd("三");
- let res = deque.getLast();
- expect(res).assertEqual("三");
- });
- it("SR000GGR3K_testHas009", 0, function () {
- let deque = new Deque();
- deque.insertEnd(6);
- let res = deque.has(6);
- expect(res).assertEqual(true);
- });
- it("SR000GGR3K_testHas010", 0, function () {
- let deque = new Deque();
- deque.insertEnd(8);
- let res = deque.has(6);
- expect(res).assertEqual(false);
- });
- it("SR000GGR3K_testPopFirst011", 0, function () {
- let deque = new Deque();
- deque.insertEnd(8);
- deque.insertFront("一");
- let res = deque.popFirst();
- expect(res).assertEqual("一");
- });
- it("SR000GGR3K_testPopLast012", 0, function () {
- let deque = new Deque();
- deque.insertEnd(8);
- deque.insertFront("一");
- deque.insertFront("二");
- let res = deque.popLast();
- expect(res).assertEqual(8);
- });
- it("SR000GGR3K_testForEach013", 0, function () {
- let deque = new Deque();
- deque.insertEnd(8);
- deque.insertFront("一");
- deque.insertFront("二");
- deque.insertEnd(1);
- deque.insertEnd(2);
- deque.insertEnd(3);
- deque.insertEnd(4);
- deque.insertEnd(5);
- deque.insertEnd(6);
- deque.insertFront("三");
- deque.insertFront("四");
- let arr = [];
- deque.forEach((item, index) => {
- arr.push(item);
- });
- let a = ["四", "三", "二", "一", 8, 1, 2, 3, 4, 5, 6];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR3K_testIterator014", 0, function () {
- let deque = new Deque();
- deque.insertEnd(8);
- deque.insertFront("一");
- deque.insertFront("二");
- deque.insertEnd(5);
- deque.insertEnd(6);
- deque.insertFront("三");
- deque.insertFront("四");
- let arr = [];
- for (let item of deque) {
- arr.push(item);
- }
- let a = ["四", "三", "二", "一", 8, 5, 6];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR3K_testInsertFront015", 0, function () {
- let deque = new Deque();
- deque.insertFront("$");
- let res = deque.getFirst();
- expect(res).assertEqual("$");
- });
- it("SR000GGR3K_testInsertFront016", 0, function () {
- let deque = new Deque();
- deque.insertFront(" ");
- let res = deque.getFirst();
- expect(res).assertEqual(" ");
- });
- it("SR000GGR3K_testInsertFront017", 0, function () {
- let deque = new Deque();
- deque.insertFront(null);
- let res = deque.getFirst();
- expect(res).assertEqual(null);
- });
- it("SR000GGR3K_testInsertFront018", 0, function () {
- let deque = new Deque();
- deque.insertFront(undefined);
- let res = deque.getFirst();
- expect(res).assertEqual(undefined);
- });
- it("SR000GGR3K_testInsertFront019", 0, function () {
- let deque = new Deque();
- for (let i = 0; i < 100; i++) {
- deque.insertFront(i);
- let res = deque.getFirst();
- expect(res).assertEqual(i);
- }
- let res1 = deque.length;
- expect(res1).assertEqual(100);
- });
- it("SR000GGR3K_testInsertEnd020", 0, function () {
- let deque = new Deque();
- deque.insertEnd("$");
- let res = deque.getLast();
- expect(res).assertEqual("$");
- });
- it("SR000GGR3K_testInsertEnd021", 0, function () {
- let deque = new Deque();
- deque.insertEnd(" ");
- let res = deque.getLast();
- expect(res).assertEqual(" ");
- });
- it("SR000GGR3K_testInsertEnd022", 0, function () {
- let deque = new Deque();
- deque.insertEnd(null);
- let res = deque.getLast();
- expect(res).assertEqual(null);
- });
- it("SR000GGR3K_testInsertEnd023", 0, function () {
- let deque = new Deque();
- deque.insertEnd(undefined);
- let res = deque.getLast();
- expect(res).assertEqual(undefined);
- });
- it("SR000GGR3K_testInsertFront024", 0, function () {
- let deque = new Deque();
- for (let i = 0; i < 100; i++) {
- deque.insertEnd(i);
- let res = deque.getLast();
- expect(res).assertEqual(i);
- }
- let res1 = deque.length;
- expect(res1).assertEqual(100);
- });
- it("SR000GGR3K_testHas025", 0, function () {
- let deque = new Deque();
- let res = deque.has(6);
- expect(res).assertEqual(false);
- });
- it("SR000GGR3K_testPopFirst026", 0, function () {
- let deque = new Deque();
- let res = deque.popFirst();
- expect(res).assertEqual(undefined);
- });
- it("SR000GGR3K_testGetFirst027", 0, function () {
- let deque = new Deque();
- let res = deque.getFirst();
- expect(res).assertEqual(undefined);
- });
- it("SR000GGR3K_testPopLast028", 0, function () {
- let deque = new Deque();
- try {
- let res = deque.popLast();
- } catch (err) {
- expect(err).assertEqual("Error: Deque: get out-of-bounds");
- }
- });
- it("SR000GGR3K_testGetLast029", 0, function () {
- let deque = new Deque();
- try {
- let res = deque.getLast();
- } catch (err) {
- expect(err).assertEqual("Error: Deque: get out-of-bounds");
- }
- });
- it("SR000GGR3K_testForEach030", 0, function () {
- let deque = new Deque();
- deque.insertEnd(8);
- deque.insertEnd(1);
- deque.insertEnd(2);
- deque.insertEnd(3);
- deque.insertEnd(3);
- deque.insertEnd(4);
- deque.insertEnd(5);
- deque.insertEnd(6);
- deque.popFirst();
- deque.popLast();
- deque.insertFront(8);
- deque.insertEnd(6);
- let arr = [];
- deque.forEach((item, index) => {
- arr.push(item);
- });
- let a = [8, 1, 2, 3, 3, 4, 5, 6];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR3K_testIterator031", 0, function () {
- let deque = new Deque();
- deque.insertEnd(8);
- deque.insertFront("一");
- deque.insertFront("二");
- deque.insertEnd(5);
- deque.insertEnd(6);
- deque.insertFront("三");
- deque.insertFront("四");
- deque.popFirst();
- deque.popLast();
- deque.insertFront("四");
- deque.insertEnd(6);
- let arr = [];
- for (let item of deque) {
- arr.push(item);
- }
- let a = ["四", "三", "二", "一", 8, 5, 6];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR3K_testIterator032", 0, function () {
- let deque = new Deque();
- deque.insertEnd(8);
- deque.insertFront("a");
- deque.insertFront("b");
- deque.insertEnd(5);
- deque.insertEnd(6);
- deque.insertFront("s");
- deque.insertFront("z");
- deque.popFirst();
- deque.popLast();
- deque.insertFront("g");
- deque.insertEnd(6);
- let size = deque.length;
- let arr = [];
- let itr = deque[Symbol.iterator]();
- for (let i = 0; i < size; i++) {
- arr.push(itr.next().value);
- }
- let a = ["g", "s", "b", "a", 8, 5, 6];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
-});
+/*
+ * Copyright (C) 2021 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 'deccjsunit/index';
+import Deque from "@ohos.util.Deque";
+
+describe("DequeTest", function () {
+ it("SR000GGR3K_testConstructor001", 0, function () {
+ try {
+ let deque = new Deque();
+ } catch (err) {
+ expect(err).assertEqual("Error:Cannot create new deque");
+ }
+ });
+ it("SR000GGR3K_testInsertFront001", 0, function () {
+ let deque = new Deque();
+ deque.insertFront("一");
+ let res = deque.getFirst();
+ expect(res).assertEqual("一");
+ });
+ it("SR000GGR3K_testInsertFront002", 0, function () {
+ let deque = new Deque();
+ deque.insertFront(8);
+ let res = deque.getFirst();
+ expect(res).assertEqual(8);
+ });
+ it("SR000GGR3K_testInsertFront003", 0, function () {
+ let deque = new Deque();
+ let a = {name: "lala", age: "15"};
+ deque.insertFront(a);
+ let res = deque.getFirst();
+ expect(res).assertEqual(a);
+ });
+ it("SR000GGR3K_testInsertFront004", 0, function () {
+ let deque = new Deque();
+ let a = [1, 2, 3, 4];
+ deque.insertFront(a);
+ let res = deque.getFirst();
+ expect(res).assertEqual(a);
+ });
+ it("SR000GGR3K_testInsertEnd005", 0, function () {
+ let deque = new Deque();
+ deque.insertEnd(8);
+ let res = deque.getLast();
+ expect(res).assertEqual(8);
+ });
+ it("SR000GGR3K_testInsertEnd006", 0, function () {
+ let deque = new Deque();
+ let a = ["a", "b", "c"];
+ deque.insertEnd(a);
+ let res = deque.getLast();
+ expect(res).assertEqual(a);
+ });
+ it("SR000GGR3K_testInsertEnd007", 0, function () {
+ let deque = new Deque();
+ let a = {class: "6班", say: "we"};
+ deque.insertEnd(a);
+ let res = deque.getLast();
+ expect(res).assertEqual(a);
+ });
+ it("SR000GGR3K_testGetFirst007", 0, function () {
+ let deque = new Deque();
+ deque.insertEnd("四");
+ deque.insertEnd("三");
+ let res = deque.getFirst();
+ expect(res).assertEqual("四");
+ });
+ it("SR000GGR3K_testGetLast008", 0, function () {
+ let deque = new Deque();
+ deque.insertEnd(8);
+ deque.insertEnd("三");
+ let res = deque.getLast();
+ expect(res).assertEqual("三");
+ });
+ it("SR000GGR3K_testHas009", 0, function () {
+ let deque = new Deque();
+ deque.insertEnd(6);
+ let res = deque.has(6);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR3K_testHas010", 0, function () {
+ let deque = new Deque();
+ deque.insertEnd(8);
+ let res = deque.has(6);
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR3K_testPopFirst011", 0, function () {
+ let deque = new Deque();
+ deque.insertEnd(8);
+ deque.insertFront("一");
+ let res = deque.popFirst();
+ expect(res).assertEqual("一");
+ });
+ it("SR000GGR3K_testPopLast012", 0, function () {
+ let deque = new Deque();
+ deque.insertEnd(8);
+ deque.insertFront("一");
+ deque.insertFront("二");
+ let res = deque.popLast();
+ expect(res).assertEqual(8);
+ });
+ it("SR000GGR3K_testForEach013", 0, function () {
+ let deque = new Deque();
+ deque.insertEnd(8);
+ deque.insertFront("一");
+ deque.insertFront("二");
+ deque.insertEnd(1);
+ deque.insertEnd(2);
+ deque.insertEnd(3);
+ deque.insertEnd(4);
+ deque.insertEnd(5);
+ deque.insertEnd(6);
+ deque.insertFront("三");
+ deque.insertFront("四");
+ let arr = [];
+ deque.forEach((item, index) => {
+ arr.push(item);
+ });
+ let a = ["四", "三", "二", "一", 8, 1, 2, 3, 4, 5, 6];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR3K_testIterator014", 0, function () {
+ let deque = new Deque();
+ deque.insertEnd(8);
+ deque.insertFront("一");
+ deque.insertFront("二");
+ deque.insertEnd(5);
+ deque.insertEnd(6);
+ deque.insertFront("三");
+ deque.insertFront("四");
+ let arr = [];
+ for (let item of deque) {
+ arr.push(item);
+ }
+ let a = ["四", "三", "二", "一", 8, 5, 6];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR3K_testInsertFront015", 0, function () {
+ let deque = new Deque();
+ deque.insertFront("$");
+ let res = deque.getFirst();
+ expect(res).assertEqual("$");
+ });
+ it("SR000GGR3K_testInsertFront016", 0, function () {
+ let deque = new Deque();
+ deque.insertFront(" ");
+ let res = deque.getFirst();
+ expect(res).assertEqual(" ");
+ });
+ it("SR000GGR3K_testInsertFront017", 0, function () {
+ let deque = new Deque();
+ deque.insertFront(null);
+ let res = deque.getFirst();
+ expect(res).assertEqual(null);
+ });
+ it("SR000GGR3K_testInsertFront018", 0, function () {
+ let deque = new Deque();
+ deque.insertFront(undefined);
+ let res = deque.getFirst();
+ expect(res).assertEqual(undefined);
+ });
+ it("SR000GGR3K_testInsertFront019", 0, function () {
+ let deque = new Deque();
+ for (let i = 0; i < 100; i++) {
+ deque.insertFront(i);
+ let res = deque.getFirst();
+ expect(res).assertEqual(i);
+ }
+ let res1 = deque.length;
+ expect(res1).assertEqual(100);
+ });
+ it("SR000GGR3K_testInsertEnd020", 0, function () {
+ let deque = new Deque();
+ deque.insertEnd("$");
+ let res = deque.getLast();
+ expect(res).assertEqual("$");
+ });
+ it("SR000GGR3K_testInsertEnd021", 0, function () {
+ let deque = new Deque();
+ deque.insertEnd(" ");
+ let res = deque.getLast();
+ expect(res).assertEqual(" ");
+ });
+ it("SR000GGR3K_testInsertEnd022", 0, function () {
+ let deque = new Deque();
+ deque.insertEnd(null);
+ let res = deque.getLast();
+ expect(res).assertEqual(null);
+ });
+ it("SR000GGR3K_testInsertEnd023", 0, function () {
+ let deque = new Deque();
+ deque.insertEnd(undefined);
+ let res = deque.getLast();
+ expect(res).assertEqual(undefined);
+ });
+ it("SR000GGR3K_testInsertFront024", 0, function () {
+ let deque = new Deque();
+ for (let i = 0; i < 100; i++) {
+ deque.insertEnd(i);
+ let res = deque.getLast();
+ expect(res).assertEqual(i);
+ }
+ let res1 = deque.length;
+ expect(res1).assertEqual(100);
+ });
+ it("SR000GGR3K_testHas025", 0, function () {
+ let deque = new Deque();
+ let res = deque.has(6);
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR3K_testPopFirst026", 0, function () {
+ let deque = new Deque();
+ let res = deque.popFirst();
+ expect(res).assertEqual(undefined);
+ });
+ it("SR000GGR3K_testGetFirst027", 0, function () {
+ let deque = new Deque();
+ let res = deque.getFirst();
+ expect(res).assertEqual(undefined);
+ });
+ it("SR000GGR3K_testPopLast028", 0, function () {
+ let deque = new Deque();
+ try {
+ let res = deque.popLast();
+ } catch (err) {
+ expect(err).assertEqual("Error: Deque: get out-of-bounds");
+ }
+ });
+ it("SR000GGR3K_testGetLast029", 0, function () {
+ let deque = new Deque();
+ try {
+ let res = deque.getLast();
+ } catch (err) {
+ expect(err).assertEqual("Error: Deque: get out-of-bounds");
+ }
+ });
+ it("SR000GGR3K_testForEach030", 0, function () {
+ let deque = new Deque();
+ deque.insertEnd(8);
+ deque.insertEnd(1);
+ deque.insertEnd(2);
+ deque.insertEnd(3);
+ deque.insertEnd(3);
+ deque.insertEnd(4);
+ deque.insertEnd(5);
+ deque.insertEnd(6);
+ deque.popFirst();
+ deque.popLast();
+ deque.insertFront(8);
+ deque.insertEnd(6);
+ let arr = [];
+ deque.forEach((item, index) => {
+ arr.push(item);
+ });
+ let a = [8, 1, 2, 3, 3, 4, 5, 6];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR3K_testIterator031", 0, function () {
+ let deque = new Deque();
+ deque.insertEnd(8);
+ deque.insertFront("一");
+ deque.insertFront("二");
+ deque.insertEnd(5);
+ deque.insertEnd(6);
+ deque.insertFront("三");
+ deque.insertFront("四");
+ deque.popFirst();
+ deque.popLast();
+ deque.insertFront("四");
+ deque.insertEnd(6);
+ let arr = [];
+ for (let item of deque) {
+ arr.push(item);
+ }
+ let a = ["四", "三", "二", "一", 8, 5, 6];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR3K_testIterator032", 0, function () {
+ let deque = new Deque();
+ deque.insertEnd(8);
+ deque.insertFront("a");
+ deque.insertFront("b");
+ deque.insertEnd(5);
+ deque.insertEnd(6);
+ deque.insertFront("s");
+ deque.insertFront("z");
+ deque.popFirst();
+ deque.popLast();
+ deque.insertFront("g");
+ deque.insertEnd(6);
+ let size = deque.length;
+ let arr = [];
+ let itr = deque[Symbol.iterator]();
+ for (let i = 0; i < size; i++) {
+ arr.push(itr.next().value);
+ }
+ let a = ["g", "s", "b", "a", 8, 5, 6];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+});
diff --git a/compileruntime/containerLine_lib_standard/src/main/js/test/ExampleJsunit.test.js b/compileruntime/containerLine_lib_standard/src/main/js/test/ExampleJsunit.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..a46419640e38427a40d27eec75ddc8eb183a89d4
--- /dev/null
+++ b/compileruntime/containerLine_lib_standard/src/main/js/test/ExampleJsunit.test.js
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2021 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 app from '@system.app'
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
+
+describe('appInfoTest', function () {
+ it('app_info_test_001', 0, function () {
+ var info = app.getInfo()
+ expect(info.versionCode).assertEqual('1000000')
+ })
+})
\ No newline at end of file
diff --git a/compileruntime/util_lib_standard/src/main/js/test/LinkedList.test.js b/compileruntime/containerLine_lib_standard/src/main/js/test/LinkedList.test.js
similarity index 96%
rename from compileruntime/util_lib_standard/src/main/js/test/LinkedList.test.js
rename to compileruntime/containerLine_lib_standard/src/main/js/test/LinkedList.test.js
index c73ee864a80f5dfa15678132f08708e6d0ade41c..b86350a3ddfce127455ae3288393633da9375a58 100644
--- a/compileruntime/util_lib_standard/src/main/js/test/LinkedList.test.js
+++ b/compileruntime/containerLine_lib_standard/src/main/js/test/LinkedList.test.js
@@ -1,656 +1,656 @@
-/*
- * Copyright (C) 2021 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 'deccjsunit/index';
-import LinkedList from "@ohos.util.LinkedList";
-
-describe("LinkedListTest", function () {
- it("SR000GGR46_testConstructor001", 0, function () {
- try {
- let linkedList = new LinkedList();
- } catch (err) {
- expect(err).assertEqual("Error:Cannot create new linkedList");
- }
- });
- it("SR000GGR46_testAdd002", 0, function () {
- let linkedList = new LinkedList();
- linkedList.add("四");
- let res = linkedList.get(0);
- expect(res).assertEqual("四");
- });
- it("SR000GGR46_testAdd003", 0, function () {
- let linkedList = new LinkedList();
- linkedList.add(8);
- let res = linkedList.get(0);
- expect(res).assertEqual(8);
- });
- it("SR000GGR46_testAdd004", 0, function () {
- let linkedList = new LinkedList();
- let a = [1, 2, 3, 4];
- linkedList.add(a);
- let res = linkedList.get(0);
- expect(res).assertEqual(a);
- });
- it("SR000GGR46_testAdd005", 0, function () {
- let linkedList = new LinkedList();
- let a = {name: "lala", age: "13"};
- linkedList.add(a);
- let res = linkedList.get(0);
- expect(res).assertEqual(a);
- });
- it("SR000GGR46_testAdd006", 0, function () {
- let linkedList = new LinkedList();
- let a = ".";
- linkedList.add(a);
- let res = linkedList.get(0);
- expect(res).assertEqual(a);
- });
- it("SR000GGR46_testAdd007", 0, function () {
- let linkedList = new LinkedList();
- let a = "*";
- linkedList.add(a);
- let res = linkedList.get(0);
- expect(res).assertEqual(a);
- });
- it("SR000GGR46_testAdd008", 0, function () {
- let linkedList = new LinkedList();
- let a = '/"';
- linkedList.add(a);
- let res = linkedList.get(0);
- expect(res).assertEqual(a);
- });
- it("SR000GGR46_testAdd009", 0, function () {
- let linkedList = new LinkedList();
- let a = "";
- linkedList.add(a);
- let res = linkedList.get(0);
- expect(res).assertEqual(a);
- });
- it("SR000GGR46_testAdd010", 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);
- });
- it("SR000GGR46_testHas011", 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);
- });
- it("SR000GGR46_testClone012", 0, function () {
- let list = new LinkedList();
- list.add("a");
- list.add("b");
- list.add("c");
- let list1 = list.clone();
- list1.addFirst("e");
- let res = list1.removeLast();
- expect(res).assertEqual("c");
- let arr = [];
- list1.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]);
- }
- });
- it("SR000GGR46_testAddFirst013", 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");
- });
- it("SR000GGR46_testRemoveFirst014", 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]);
- }
- });
- it("SR000GGR46_testGetLastIndexOf015", 0, function () {
- let list = new LinkedList();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- list.add("b");
- let res = list.getLastIndexOf("a");
- expect(res).assertEqual(3);
- });
- it("SR000GGR46_testGetLastIndexOf016", 0, function () {
- let list = new LinkedList();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- list.add("b");
- let res = list.getLastIndexOf("f");
- expect(res).assertEqual(-1);
- });
- it("SR000GGR46_testGetIndexOf017", 0, function () {
- let list = new LinkedList();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- list.add("b");
- let res = list.getIndexOf("b");
- expect(res).assertEqual(1);
- });
- it("SR000GGR46_testGetIndexOf018", 0, function () {
- let list = new LinkedList();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- list.add("b");
- try {
- let res = list.getIndexOf("f");
- } catch (err) {
- expect(err).assertEqual("");
- }
- });
- it("SR000GGR46_testRemoveByIndex019", 0, function () {
- let list = new LinkedList();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- let res = list.removeByIndex(2);
- let arr = [];
- list.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]);
- }
- });
- it("SR000GGR46_testRemoveByIndex020", 0, function () {
- let list = new LinkedList();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- try {
- let res = list.removeByIndex(10);
- } catch (err) {
- expect(err).assertEqual("Error: removeByIndex is out-of-bounds");
- }
- });
- it("SR000GGR46_testRemove0021", 0, function () {
- let list = new LinkedList();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- let res = list.remove("a");
- let arr = [];
- list.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]);
- }
- });
- it("SR000GGR46_testRemove022", 0, function () {
- let list = new LinkedList();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- let res = list.remove("d");
- expect(res).assertEqual(false);
- });
- it("SR000GGR46_testRemove023", 0, function () {
- let list = new LinkedList();
- let res = list.remove("d");
- expect(res).assertEqual(false);
- });
- it("SR000GGR46_testRemoveFirstFound024", 0, function () {
- let list = new LinkedList();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- let res = list.removeFirstFound("b");
- let arr = [];
- list.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]);
- }
- });
- it("SR000GGR46_testRemoveLastFound025", 0, function () {
- let list = new LinkedList();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- let res = list.removeLastFound("b");
- let arr = [];
- list.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]);
- }
- });
- it("SR000GGR46_testGetFirst026", 0, function () {
- let list = new LinkedList();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- let res = list.getFirst();
- expect(res).assertEqual("a");
- });
- it("SR000GGR46_testGetLast027", 0, function () {
- let list = new LinkedList();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- let res = list.getLast();
- expect(res).assertEqual("b");
- });
- it("SR000GGR46_testInsert028", 0, function () {
- let list = new LinkedList();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- let res = list.insert(3, "d");
- let arr = [];
- list.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]);
- }
- });
- it("SR000GGR46_testInsert029", 0, function () {
- let list = new LinkedList();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- let res = list.insert(0, "d");
- let arr = [];
- list.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]);
- }
- });
- it("SR000GGR46_testInsert030", 0, function () {
- let list = new LinkedList();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- let res = list.insert(5, "d");
- let arr = [];
- list.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]);
- }
- });
- it("SR000GGR46_testInsert031", 0, function () {
- let list = new LinkedList();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- try {
- let res = list.insert(8, "d");
- } catch (err) {
- expect(err).assertEqual(
- "Error: index cannot Less than 0 and more than this length"
- );
- }
- });
- it("SR000GGR46_testSet032", 0, function () {
- let list = new LinkedList();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- let res = list.set(2, "d");
- let res1 = list.get(2);
- expect(res1).assertEqual("d");
- });
- it("SR000GGR46_testConvertToArray033", 0, function () {
- let list = new LinkedList();
- list.add(4);
- list.add(3);
- list.add(1);
- list.add(2);
- list.add(14);
- let res = list.convertToArray();
-
- let a = [4, 3, 1, 2, 14];
- for (let i = 0; i < a.length; i++) {
- expect(res[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR46_testLength034", 0, function () {
- let list = new LinkedList();
- list.add(4);
- list.add(3);
- list.add(1);
- list.add(2);
- list.add(14);
- let res = list.length;
- expect(res).assertEqual(5);
- });
- it("SR000GGR46_testClear035", 0, function () {
- let list = new LinkedList();
- list.add(4);
- list.add(3);
- list.add(1);
- list.add(2);
- list.add(14);
- list.clear();
- let res = list.length;
- expect(res).assertEqual(0);
- });
- it("SR000GGR46_testIterator036", 0, function () {
- let list = new LinkedList();
- list.add(8);
- list.add("一");
- list.add("二");
- list.add(5);
- let c = [1, 2, 3, 4];
- list.add(c);
- list.add(6);
- list.add("三");
- list.add("四");
- let arr = [];
- let a = [8, "一", "二", 5, c, 6, "三", "四"];
- for (let item of list) {
- arr.push(item);
- }
- for (let index = 0; index < list.length; index++) {
- expect(arr[index]).assertEqual(a[index]);
- }
- });
- it("SR000GGR46_testForEach037", 0, function () {
- let list = new LinkedList();
- list.add(8);
- list.add("一");
- list.add("二");
- list.add(5);
- let c = [1, 2, 3, 4];
- list.add(c);
- list.add(6);
- list.add("三");
- list.add("四");
- let arr = [];
- list.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]);
- }
- });
- it("SR000GGR46_testRemoveLast038", 0, function () {
- let list = new LinkedList();
- list.add("a");
- list.add("b");
- list.add("c");
- list.addFirst("e");
- let res = list.removeLast();
- expect(res).assertEqual("c");
- let arr = [];
- list.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]);
- }
- });
- it("SR000GGR46_testGet039", 0, function () {
- let list = new LinkedList();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- let res = list.get(1);
- expect(res).assertEqual("b");
- });
- it("SR000GGR46_testGet040", 0, function () {
- let list = new LinkedList();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- try {
- let res = list.get(10);
- } catch (err) {
- expect(err).assertEqual("TypeError: Obj is not a valid object");
- }
- });
- it("SR000GGR46_testListGet041", 0, function () {
- let list = new LinkedList();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- let res = list[1];
- list.forEach((item, index) => {
- console.log(item);
- });
- expect(res).assertEqual("b");
- });
- it("SR000GGR46_testListSet042", 0, function () {
- let list = new LinkedList();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- list[1] = "f";
- let res = list[1];
- list.forEach((item, index) => {
- console.log(item);
- });
- expect(res).assertEqual("f");
- });
- it("SR000GGR46_testAdd043", 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);
- });
- it("SR000GGR46_testRemoveByIndex044", 0, function () {
- let linkedList = new LinkedList();
- try {
- let res = linkedList.removeByIndex(1);
- } catch (err) {
- expect(err).assertEqual("Error: removeByIndex is out-of-bounds");
- }
- });
- it("SR000GGR46_testClone045", 0, function () {
- let linkedList = new LinkedList();
- try {
- let newlist = linkedList.clone();
- } catch (err) {
- expect(err).assertEqual("TypeError: Obj is not a valid object");
- }
- });
- it("SR000GGR46_testGetIndexOf046", 0, function () {
- let linkedList = new LinkedList();
- let res = linkedList.getIndexOf(1);
- expect(res).assertEqual(-1);
- });
- it("SR000GGR46_testForEach047", 0, function () {
- let linkedList = new LinkedList();
- let num = 0;
- try {
- linkedList.forEach((item, index) => {
- num++;
- });
- } catch (err) {
- expect(err).assertEqual("TypeError: Obj is not a valid object");
- }
- expect(num).assertEqual(0);
- });
- it("SR000GGR46_testIsEmpty048", 0, function () {
- let linkedList = new LinkedList();
- try {
- let res = linkedList.isEmpty();
- } catch (err) {
- expect(err).assertEqual("TypeError: is not callable");
- }
- });
- it("SR000GGR46_testHas049", 0, function () {
- let linkedList = new LinkedList();
- try {
- let res = linkedList.has(1);
- } catch (err) {
- expect(err).assertEqual("TypeError: Obj is not a valid object");
- }
- });
- it("SR000GGR46_testGet050", 0, function () {
- let linkedList = new LinkedList();
- try {
- let res = linkedList.get(1);
- } catch (err) {
- expect(err).assertEqual("TypeError: Obj is not a valid object");
- }
- });
- it("SR000GGR46_testClear051", 0, function () {
- let linkedList = new LinkedList();
- linkedList.clear();
- const len = linkedList.length;
- expect(len).assertEqual(0);
- });
- it("SR000GGR46_testGetLast052", 0, function () {
- let linkedList = new LinkedList();
- try {
- let res = linkedList.getLast();
- } catch (err) {
- expect(err).assertEqual("TypeError: Obj is not a valid object");
- }
- });
- it("SR000GGR46_testGetFirst053", 0, function () {
- let linkedList = new LinkedList();
- try {
- let res = linkedList.getFirst();
- } catch (err) {
- expect(err).assertEqual("TypeError: Obj is not a valid object");
- }
- });
- it("SR000GGR46_testAdd054", 0, function () {
- let linkedList = new LinkedList();
- linkedList.add(null);
- let res = linkedList.get(0);
- expect(res).assertEqual(null);
- });
- it("SR000GGR46_testAdd055", 0, function () {
- let linkedList = new LinkedList();
- linkedList.add(0.1);
- let res = linkedList.get(0);
- expect(res).assertEqual(0.1);
- });
- it("SR000GGR46_testAdd056", 0, function () {
- let linkedList = new LinkedList();
- linkedList.add(-1);
- let res = linkedList.get(0);
- expect(res).assertEqual(-1);
- });
- it("SR000GGR46_testAdd057", 0, function () {
- let linkedList = new LinkedList();
- const obj = {};
- linkedList.add(obj);
- let res = linkedList.get(0);
- expect(res).assertEqual(obj);
- });
- it("SR000GGR46_testIterator058", 0, function () {
- let list = new LinkedList();
- list.add("a");
- list.add("b");
- list.add("c");
- list.addFirst("e");
- let res = list.removeLast();
- expect(res).assertEqual("c");
- let arr = [];
- let itr = list[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]);
- }
- });
-});
+/*
+ * Copyright (C) 2021 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 'deccjsunit/index';
+import LinkedList from "@ohos.util.LinkedList";
+
+describe("LinkedListTest", function () {
+ it("SR000GGR46_testConstructor001", 0, function () {
+ try {
+ let linkedList = new LinkedList();
+ } catch (err) {
+ expect(err).assertEqual("Error:Cannot create new linkedList");
+ }
+ });
+ it("SR000GGR46_testAdd002", 0, function () {
+ let linkedList = new LinkedList();
+ linkedList.add("四");
+ let res = linkedList.get(0);
+ expect(res).assertEqual("四");
+ });
+ it("SR000GGR46_testAdd003", 0, function () {
+ let linkedList = new LinkedList();
+ linkedList.add(8);
+ let res = linkedList.get(0);
+ expect(res).assertEqual(8);
+ });
+ it("SR000GGR46_testAdd004", 0, function () {
+ let linkedList = new LinkedList();
+ let a = [1, 2, 3, 4];
+ linkedList.add(a);
+ let res = linkedList.get(0);
+ expect(res).assertEqual(a);
+ });
+ it("SR000GGR46_testAdd005", 0, function () {
+ let linkedList = new LinkedList();
+ let a = {name: "lala", age: "13"};
+ linkedList.add(a);
+ let res = linkedList.get(0);
+ expect(res).assertEqual(a);
+ });
+ it("SR000GGR46_testAdd006", 0, function () {
+ let linkedList = new LinkedList();
+ let a = ".";
+ linkedList.add(a);
+ let res = linkedList.get(0);
+ expect(res).assertEqual(a);
+ });
+ it("SR000GGR46_testAdd007", 0, function () {
+ let linkedList = new LinkedList();
+ let a = "*";
+ linkedList.add(a);
+ let res = linkedList.get(0);
+ expect(res).assertEqual(a);
+ });
+ it("SR000GGR46_testAdd008", 0, function () {
+ let linkedList = new LinkedList();
+ let a = '/"';
+ linkedList.add(a);
+ let res = linkedList.get(0);
+ expect(res).assertEqual(a);
+ });
+ it("SR000GGR46_testAdd009", 0, function () {
+ let linkedList = new LinkedList();
+ let a = "";
+ linkedList.add(a);
+ let res = linkedList.get(0);
+ expect(res).assertEqual(a);
+ });
+ it("SR000GGR46_testAdd010", 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);
+ });
+ it("SR000GGR46_testHas011", 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);
+ });
+ it("SR000GGR46_testClone012", 0, function () {
+ let list = new LinkedList();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ let list1 = list.clone();
+ list1.addFirst("e");
+ let res = list1.removeLast();
+ expect(res).assertEqual("c");
+ let arr = [];
+ list1.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]);
+ }
+ });
+ it("SR000GGR46_testAddFirst013", 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");
+ });
+ it("SR000GGR46_testRemoveFirst014", 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]);
+ }
+ });
+ it("SR000GGR46_testGetLastIndexOf015", 0, function () {
+ let list = new LinkedList();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ list.add("b");
+ let res = list.getLastIndexOf("a");
+ expect(res).assertEqual(3);
+ });
+ it("SR000GGR46_testGetLastIndexOf016", 0, function () {
+ let list = new LinkedList();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ list.add("b");
+ let res = list.getLastIndexOf("f");
+ expect(res).assertEqual(-1);
+ });
+ it("SR000GGR46_testGetIndexOf017", 0, function () {
+ let list = new LinkedList();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ list.add("b");
+ let res = list.getIndexOf("b");
+ expect(res).assertEqual(1);
+ });
+ it("SR000GGR46_testGetIndexOf018", 0, function () {
+ let list = new LinkedList();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ list.add("b");
+ try {
+ let res = list.getIndexOf("f");
+ } catch (err) {
+ expect(err).assertEqual("");
+ }
+ });
+ it("SR000GGR46_testRemoveByIndex019", 0, function () {
+ let list = new LinkedList();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ let res = list.removeByIndex(2);
+ let arr = [];
+ list.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]);
+ }
+ });
+ it("SR000GGR46_testRemoveByIndex020", 0, function () {
+ let list = new LinkedList();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ try {
+ let res = list.removeByIndex(10);
+ } catch (err) {
+ expect(err).assertEqual("Error: removeByIndex is out-of-bounds");
+ }
+ });
+ it("SR000GGR46_testRemove0021", 0, function () {
+ let list = new LinkedList();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ let res = list.remove("a");
+ let arr = [];
+ list.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]);
+ }
+ });
+ it("SR000GGR46_testRemove022", 0, function () {
+ let list = new LinkedList();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ let res = list.remove("d");
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR46_testRemove023", 0, function () {
+ let list = new LinkedList();
+ let res = list.remove("d");
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR46_testRemoveFirstFound024", 0, function () {
+ let list = new LinkedList();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ let res = list.removeFirstFound("b");
+ let arr = [];
+ list.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]);
+ }
+ });
+ it("SR000GGR46_testRemoveLastFound025", 0, function () {
+ let list = new LinkedList();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ let res = list.removeLastFound("b");
+ let arr = [];
+ list.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]);
+ }
+ });
+ it("SR000GGR46_testGetFirst026", 0, function () {
+ let list = new LinkedList();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ let res = list.getFirst();
+ expect(res).assertEqual("a");
+ });
+ it("SR000GGR46_testGetLast027", 0, function () {
+ let list = new LinkedList();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ let res = list.getLast();
+ expect(res).assertEqual("b");
+ });
+ it("SR000GGR46_testInsert028", 0, function () {
+ let list = new LinkedList();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ let res = list.insert(3, "d");
+ let arr = [];
+ list.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]);
+ }
+ });
+ it("SR000GGR46_testInsert029", 0, function () {
+ let list = new LinkedList();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ let res = list.insert(0, "d");
+ let arr = [];
+ list.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]);
+ }
+ });
+ it("SR000GGR46_testInsert030", 0, function () {
+ let list = new LinkedList();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ let res = list.insert(5, "d");
+ let arr = [];
+ list.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]);
+ }
+ });
+ it("SR000GGR46_testInsert031", 0, function () {
+ let list = new LinkedList();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ try {
+ let res = list.insert(8, "d");
+ } catch (err) {
+ expect(err).assertEqual(
+ "Error: index cannot Less than 0 and more than this length"
+ );
+ }
+ });
+ it("SR000GGR46_testSet032", 0, function () {
+ let list = new LinkedList();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ let res = list.set(2, "d");
+ let res1 = list.get(2);
+ expect(res1).assertEqual("d");
+ });
+ it("SR000GGR46_testConvertToArray033", 0, function () {
+ let list = new LinkedList();
+ list.add(4);
+ list.add(3);
+ list.add(1);
+ list.add(2);
+ list.add(14);
+ let res = list.convertToArray();
+
+ let a = [4, 3, 1, 2, 14];
+ for (let i = 0; i < a.length; i++) {
+ expect(res[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR46_testLength034", 0, function () {
+ let list = new LinkedList();
+ list.add(4);
+ list.add(3);
+ list.add(1);
+ list.add(2);
+ list.add(14);
+ let res = list.length;
+ expect(res).assertEqual(5);
+ });
+ it("SR000GGR46_testClear035", 0, function () {
+ let list = new LinkedList();
+ list.add(4);
+ list.add(3);
+ list.add(1);
+ list.add(2);
+ list.add(14);
+ list.clear();
+ let res = list.length;
+ expect(res).assertEqual(0);
+ });
+ it("SR000GGR46_testIterator036", 0, function () {
+ let list = new LinkedList();
+ list.add(8);
+ list.add("一");
+ list.add("二");
+ list.add(5);
+ let c = [1, 2, 3, 4];
+ list.add(c);
+ list.add(6);
+ list.add("三");
+ list.add("四");
+ let arr = [];
+ let a = [8, "一", "二", 5, c, 6, "三", "四"];
+ for (let item of list) {
+ arr.push(item);
+ }
+ for (let index = 0; index < list.length; index++) {
+ expect(arr[index]).assertEqual(a[index]);
+ }
+ });
+ it("SR000GGR46_testForEach037", 0, function () {
+ let list = new LinkedList();
+ list.add(8);
+ list.add("一");
+ list.add("二");
+ list.add(5);
+ let c = [1, 2, 3, 4];
+ list.add(c);
+ list.add(6);
+ list.add("三");
+ list.add("四");
+ let arr = [];
+ list.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]);
+ }
+ });
+ it("SR000GGR46_testRemoveLast038", 0, function () {
+ let list = new LinkedList();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.addFirst("e");
+ let res = list.removeLast();
+ expect(res).assertEqual("c");
+ let arr = [];
+ list.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]);
+ }
+ });
+ it("SR000GGR46_testGet039", 0, function () {
+ let list = new LinkedList();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ let res = list.get(1);
+ expect(res).assertEqual("b");
+ });
+ it("SR000GGR46_testGet040", 0, function () {
+ let list = new LinkedList();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ try {
+ let res = list.get(10);
+ } catch (err) {
+ expect(err).assertEqual("TypeError: Obj is not a valid object");
+ }
+ });
+ it("SR000GGR46_testListGet041", 0, function () {
+ let list = new LinkedList();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ let res = list[1];
+ list.forEach((item, index) => {
+ console.log(item);
+ });
+ expect(res).assertEqual("b");
+ });
+ it("SR000GGR46_testListSet042", 0, function () {
+ let list = new LinkedList();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ list[1] = "f";
+ let res = list[1];
+ list.forEach((item, index) => {
+ console.log(item);
+ });
+ expect(res).assertEqual("f");
+ });
+ it("SR000GGR46_testAdd043", 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);
+ });
+ it("SR000GGR46_testRemoveByIndex044", 0, function () {
+ let linkedList = new LinkedList();
+ try {
+ let res = linkedList.removeByIndex(1);
+ } catch (err) {
+ expect(err).assertEqual("Error: removeByIndex is out-of-bounds");
+ }
+ });
+ it("SR000GGR46_testClone045", 0, function () {
+ let linkedList = new LinkedList();
+ try {
+ let newlist = linkedList.clone();
+ } catch (err) {
+ expect(err).assertEqual("TypeError: Obj is not a valid object");
+ }
+ });
+ it("SR000GGR46_testGetIndexOf046", 0, function () {
+ let linkedList = new LinkedList();
+ let res = linkedList.getIndexOf(1);
+ expect(res).assertEqual(-1);
+ });
+ it("SR000GGR46_testForEach047", 0, function () {
+ let linkedList = new LinkedList();
+ let num = 0;
+ try {
+ linkedList.forEach((item, index) => {
+ num++;
+ });
+ } catch (err) {
+ expect(err).assertEqual("TypeError: Obj is not a valid object");
+ }
+ expect(num).assertEqual(0);
+ });
+ it("SR000GGR46_testIsEmpty048", 0, function () {
+ let linkedList = new LinkedList();
+ try {
+ let res = linkedList.isEmpty();
+ } catch (err) {
+ expect(err).assertEqual("TypeError: is not callable");
+ }
+ });
+ it("SR000GGR46_testHas049", 0, function () {
+ let linkedList = new LinkedList();
+ try {
+ let res = linkedList.has(1);
+ } catch (err) {
+ expect(err).assertEqual("TypeError: Obj is not a valid object");
+ }
+ });
+ it("SR000GGR46_testGet050", 0, function () {
+ let linkedList = new LinkedList();
+ try {
+ let res = linkedList.get(1);
+ } catch (err) {
+ expect(err).assertEqual("TypeError: Obj is not a valid object");
+ }
+ });
+ it("SR000GGR46_testClear051", 0, function () {
+ let linkedList = new LinkedList();
+ linkedList.clear();
+ const len = linkedList.length;
+ expect(len).assertEqual(0);
+ });
+ it("SR000GGR46_testGetLast052", 0, function () {
+ let linkedList = new LinkedList();
+ try {
+ let res = linkedList.getLast();
+ } catch (err) {
+ expect(err).assertEqual("TypeError: Obj is not a valid object");
+ }
+ });
+ it("SR000GGR46_testGetFirst053", 0, function () {
+ let linkedList = new LinkedList();
+ try {
+ let res = linkedList.getFirst();
+ } catch (err) {
+ expect(err).assertEqual("TypeError: Obj is not a valid object");
+ }
+ });
+ it("SR000GGR46_testAdd054", 0, function () {
+ let linkedList = new LinkedList();
+ linkedList.add(null);
+ let res = linkedList.get(0);
+ expect(res).assertEqual(null);
+ });
+ it("SR000GGR46_testAdd055", 0, function () {
+ let linkedList = new LinkedList();
+ linkedList.add(0.1);
+ let res = linkedList.get(0);
+ expect(res).assertEqual(0.1);
+ });
+ it("SR000GGR46_testAdd056", 0, function () {
+ let linkedList = new LinkedList();
+ linkedList.add(-1);
+ let res = linkedList.get(0);
+ expect(res).assertEqual(-1);
+ });
+ it("SR000GGR46_testAdd057", 0, function () {
+ let linkedList = new LinkedList();
+ const obj = {};
+ linkedList.add(obj);
+ let res = linkedList.get(0);
+ expect(res).assertEqual(obj);
+ });
+ it("SR000GGR46_testIterator058", 0, function () {
+ let list = new LinkedList();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.addFirst("e");
+ let res = list.removeLast();
+ expect(res).assertEqual("c");
+ let arr = [];
+ let itr = list[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]);
+ }
+ });
+});
diff --git a/compileruntime/util_lib_standard/src/main/js/test/ContainerList.test.js b/compileruntime/containerLine_lib_standard/src/main/js/test/List.test.js
similarity index 96%
rename from compileruntime/util_lib_standard/src/main/js/test/ContainerList.test.js
rename to compileruntime/containerLine_lib_standard/src/main/js/test/List.test.js
index 8544c0d835d9b7073b743e1287f84612204e5f78..d45d853db01bb5a934f2e3a14e15b405faf059c9 100644
--- a/compileruntime/util_lib_standard/src/main/js/test/ContainerList.test.js
+++ b/compileruntime/containerLine_lib_standard/src/main/js/test/List.test.js
@@ -1,704 +1,704 @@
-/*
- * Copyright (C) 2021 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 'deccjsunit/index';
-import List from "@ohos.util.List";
-
-describe("ListTest", function () {
- it("SR000GGR4A_testConstructor001", 0, function () {
- try {
- let list = new List();
- expect(list != undefined).assertEqual(true);
- } catch (err) {
- expect(err).assertEqual("Error:Cannot create new list");
- }
- });
- it("SR000GGR4A_testGet002", 0, function () {
- let list = new List();
- list.add("四");
- let res = list.get(0);
- expect(res).assertEqual("四");
- });
- it("SR000GGR4A_testAdd002", 0, function () {
- let list = new List();
- list.add(8);
- let res = list.get(0);
- expect(res).assertEqual(8);
- });
- it("SR000GGR4A_testAdd003", 0, function () {
- let list = new List();
- let a = [1, 2, 3, 4];
- list.add(a);
- let res = list.get(0);
- expect(res).assertEqual(a);
- });
- it("SR000GGR4A_testAdd004", 0, function () {
- let list = new List();
- let a = {name: "lala", age: "13"};
- list.add(a);
- let res = list.get(0);
- expect(res).assertEqual(a);
- });
- it("SR000GGR4A_testHas005", 0, function () {
- let list = new List();
- list.add("a");
- list.add("b");
- list.add("c");
- let res = list.has("a");
- expect(res).assertEqual(true);
- });
- it("SR000GGR4A_testHas006", 0, function () {
- let list = new List();
- list.add("a");
- list.add("b");
- list.add("c");
- let res = list.has("d");
- expect(res).assertEqual(false);
- });
- it("SR000GGR4A_testEqual007", 0, function () {
- let list = new List();
- let list1 = new List();
- list.add("a");
- list.add("b");
- list.add("c");
- list1.add("a");
- list1.add("b");
- list1.add("d");
- let res = list.equal(list1);
- expect(res).assertEqual(false);
- });
- it("SR000GGR4A_testEqual008", 0, function () {
- let list = new List();
- let list1 = new List();
- list.add("a");
- list.add("b");
- list.add("c");
- list1.add("a");
- list1.add("b");
- list1.add("c");
- let res = list.equal(list1);
- expect(res).assertEqual(true);
- });
- it("SR000GGR4A_testEqual009", 0, function () {
- let list = new List();
- let list1 = new List();
- list.add("a");
- list.add("b");
- list.add("c");
- list1.add("a");
- list1.add("b");
- let res = list.equal(list1);
- expect(res).assertEqual(false);
- });
- it("SR000GGR4A_testGet010", 0, function () {
- let list = new List();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- list.add("b");
- let res = list.get(2);
- expect(res).assertEqual("c");
- });
- it("SR000GGR4A_testGetLastIndexOf011", 0, function () {
- let list = new List();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- list.add("b");
- let res = list.getLastIndexOf("a");
- expect(res).assertEqual(3);
- });
- it("SR000GGR4A_testGetIndexOf012", 0, function () {
- let list = new List();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- list.add("b");
- let res = list.getIndexOf("b");
- expect(res).assertEqual(1);
- });
- it("SR000GGR4A_testRemoveByIndex013", 0, function () {
- let list = new List();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- let res = list.removeByIndex(2);
- let arr = [];
- list.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]);
- }
- });
- it("SR000GGR4A_testRemove014", 0, function () {
- let list = new List();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- let res = list.remove("a");
- let arr = [];
- list.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]);
- }
- });
- it("SR000GGR4A_testConstructor015", 0, function () {
- let list = new List();
- list.add(1);
- list.add(2);
- list.add(4);
- list.add(5);
- list.replaceAllElements((item, index) => {
- return (item = 2 * item);
- });
- let arr = [];
- list.forEach((item, index) => {
- arr.push(item);
- });
- let a = [2, 4, 8, 10];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR4A_testGetFirst016", 0, function () {
- let list = new List();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- let res = list.getFirst();
- expect(res).assertEqual("a");
- });
- it("SR000GGR4A_testGetLast017", 0, function () {
- let list = new List();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- let res = list.getLast();
- expect(res).assertEqual("b");
- });
- it("SR000GGR4A_testInsert018", 0, function () {
- let list = new List();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- let res = list.insert("d", 3);
- let arr = [];
- list.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]);
- }
- });
- it("SR000GGR4A_testSet019", 0, function () {
- let list = new List();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- let res = list.set(2, "d");
- let res1 = list.getNode(2).element;
- expect(res1).assertEqual("d");
- });
- it("SR000GGR4A_testSort020", 0, function () {
- let list = new List();
- list.add(4);
- list.add(3);
- list.add(1);
- list.add(2);
- list.add(14);
- list.sort((a, b) => a - b);
- let arr = [];
- list.forEach((item, index) => {
- arr.push(item);
- });
- let a = [1, 2, 3, 4, 14];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR4A_testGetSubList021", 0, function () {
- let list = new List();
- list.add(4);
- list.add(3);
- list.add(1);
- list.add(2);
- list.add(14);
- let res = list.getSubList(2, 4);
- let arr = [];
- res.forEach((item, index) => {
- arr.push(item);
- });
- let a = [1, 2];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR4A_testConvertToArray022", 0, function () {
- let list = new List();
- list.add(4);
- list.add(3);
- list.add(1);
- list.add(2);
- list.add(14);
- let res = list.convertToArray();
-
- let a = [4, 3, 1, 2, 14];
- for (let i = 0; i < a.length; i++) {
- expect(res[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR4A_testLength023", 0, function () {
- let list = new List();
- list.add(4);
- list.add(3);
- list.add(1);
- list.add(2);
- list.add(14);
- let res = list.length;
- expect(res).assertEqual(5);
- });
- it("SR000GGR4A_testConstructor024", 0, function () {
- let list = new List();
- list.add(8);
- list.add("一");
- list.add("二");
- list.add(5);
- let c = [1, 2, 3, 4];
- list.add(c);
- list.add(6);
- list.add("三");
- list.add("四");
- let arr = [];
- for (let item of list) {
- arr.push(item);
- }
- let a = [8, "一", "二", 5, c, 6, "三", "四"];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR4A_testForEach025", 0, function () {
- let list = new List();
- list.add(8);
- list.add("一");
- list.add("二");
- list.add(5);
- let c = [1, 2, 3, 4];
- list.add(c);
- list.add(6);
- list.add("三");
- list.add("四");
- let arr = [];
- list.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]);
- }
- });
- it("SR000GGR4A_testIsEmpty026", 0, function () {
- let list = new List();
- list.add(8);
- list.add("一");
- list.add("二");
- list.add(5);
- let c = [1, 2, 3, 4];
- list.add(c);
- list.add(6);
- list.add("三");
- list.add("四");
- let res = list.isEmpty();
- expect(res).assertEqual(false);
- });
- it("SR000GGR4A_testClear027", 0, function () {
- let list = new List();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.clear();
- let res = list.length;
- expect(res).assertEqual(0);
- });
- it("SR000GGR4A_testGet028", 0, function () {
- let list = new List();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- list.add("b");
- try {
- let res = list.get(6);
- } catch (err) {
- expect(err).assertEqual("TypeError: Obj is not a valid object");
- }
- });
- it("SR000GGR4A_testGetLastIndexOf029", 0, function () {
- let list = new List();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- list.add("b");
- let res = list.getLastIndexOf("F");
- expect(res).assertEqual(-1);
- });
- it("SR000GGR4A_testRemoveByIndex030", 0, function () {
- let list = new List();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- try {
- let res = list.removeByIndex(5);
- } catch (err) {
- expect(err).assertEqual("Error: removeByIndex is out-of-bounds");
- }
- });
- it("SR000GGR4A_testRemove031", 0, function () {
- let list = new List();
- list.add();
- let res = list.remove();
- expect(res).assertEqual(true);
- });
- it("SR000GGR4A_testInsert032", 0, function () {
- let list = new List();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- let res = list.insert("d", 8);
- expect(res).assertEqual(undefined);
- });
- it("SR000GGR4A_testSort033", 0, function () {
- let list = new List();
- list.add(";");
- list.add("一");
- list.add("a");
- list.add("1");
- list.add("2");
- list.add("14");
- list.sort((a, b) => a - b);
- let arr = [];
- list.forEach((item, index) => {
- arr.push(item);
- });
- let a = [";", "一", "a", "1", "2", "14"];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR4A_testGetSubList034", 0, function () {
- let list = new List();
- list.add("4");
- list.add("3");
- list.add("1");
- list.add("2");
- list.add("14");
- let res = list.getSubList(2, 8);
- let arr = [];
- res.forEach((item, index) => {
- arr.push(item);
- });
- let a = ["1", "2"];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR4A_testGetSubList035", 0, function () {
- let list = new List();
- list.add("4");
- list.add("3");
- list.add("1");
- list.add("2");
- list.add("14");
- try {
- let res = list.getSubList(6, 8);
- } catch (err) {
- expect(err).assertEqual("Error: fromIndex or toIndex is out-of-bounds");
- }
- });
- it("SR000GGR4A_testGetSubList036", 0, function () {
- let list = new List();
- list.add("4");
- list.add("3");
- list.add("1");
- list.add("2");
- list.add("14");
- try {
- let res = list.getSubList(6, 2);
- } catch (err) {
- expect(err).assertEqual(
- "Error: toIndex cannot be less than or equal to fromIndex"
- );
- }
- });
- it("SR000GGR4A_testAdd037", 0, function () {
- let list = new List();
- list.add(".");
- list.add("*");
- list.add("|");
- let res = list.get(0);
- expect(res).assertEqual(".");
- });
- it("SR000GGR4A_testAdd038", 0, function () {
- let list = new List();
- list.add(".");
- list.add("*");
- list.add("|");
- let arr = [];
- list.forEach((item, index) => {
- arr.push(item);
- });
- let a = [".", "*", "|"];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR4A_testAdd039", 0, function () {
- let list = new List();
- list.add(" ");
- let res = list.get(0);
- expect(res).assertEqual(" ");
- });
- it("SR000GGR4A_testAdd040", 0, function () {
- let list = new List();
- list.add("a");
- list.add("a");
- let res = list.get(0);
- let res1 = list.get(1);
- expect(res).assertEqual("a");
- expect(res1).assertEqual("a");
- });
- it("SR000GGR4A_testListGet041", 0, function () {
- let list = new List();
- list.add("a");
- list.add("b");
- let res = list[0];
- expect(res).assertEqual("a");
- });
- it("SR000GGR4A_testListSet042", 0, function () {
- let list = new List();
- list.add("a");
- list.add("b");
- list[0] = "c";
- let res = list[0];
- expect(res).assertEqual("c");
- list.forEach((item, index) => {
- console.log(item);
- });
- });
- it("SR000GGR4A_testAdd043", 0, function () {
- let list = new List();
- for (let i = 0; i < 100; i++) {
- list.add(i);
- }
- let res = list.get(99);
- let res1 = list.length;
- expect(res).assertEqual(99);
- expect(res1).assertEqual(100);
- });
- it("SR000GGR4A_testAdd044", 0, function () {
- let list = new List();
- list.add(null);
- let res = list.get(0);
- expect(res).assertEqual(null);
- });
- it("SR000GGR4A_testAdd045", 0, function () {
- let list = new List();
- list.add(0.1111);
- let res = list.get(0);
- expect(res).assertEqual(0.1111);
- });
- it("SR000GGR4A_testAdd046", 0, function () {
- let list = new List();
- list.add(-1);
- let res = list.get(0);
- expect(res).assertEqual(-1);
- });
- it("SR000GGR4A_testAdd047", 0, function () {
- let list = new List();
- const obj = {};
- list.add(obj);
- let res = list.get(0);
- expect(res).assertEqual(obj);
- });
- it("SR000GGR4A_testSort048", 0, function () {
- let list = new List();
- list.sort((a, b) => a - b);
- let res1 = list.length;
- expect(res1).assertEqual(0);
- });
- it("SR000GGR4A_testRemoveByIndex049", 0, function () {
- let list = new List();
- try {
- let res = list.removeByIndex(1);
- } catch (err) {
- expect(err).assertEqual("Error: removeByIndex is out-of-bounds");
- }
- });
- it("SR000GGR4A_testEqual050", 0, function () {
- let list = new List();
- let list1 = new List();
- try {
- let res = list.equal(list1);
- } catch (err) {
- expect(err).assertEqual("TypeError: Obj is not a valid object");
- }
- });
- it("SR000GGR4A_testGetIndexOf051", 0, function () {
- let list = new List();
- let res = list.getIndexOf(1);
- expect(res).assertEqual(-1);
- });
- it("SR000GGR4A_testForEach052", 0, function () {
- let list = new List();
- let num = 0;
- try {
- list.forEach((item, index) => {
- num++;
- });
- } catch (err) {
- expect(err).assertEqual("TypeError: Obj is not a valid object");
- }
- expect(num).assertEqual(0);
- });
- it("SR000GGR4A_testIsEmpty053", 0, function () {
- let list = new List();
- try {
- let res = list.isEmpty();
- } catch (err) {
- expect(err).assertEqual("TypeError: is not callable");
- }
- });
- it("SR000GGR4A_testHas054", 0, function () {
- let list = new List();
- try {
- let res = list.has(1);
- } catch (err) {
- expect(err).assertEqual("TypeError: Obj is not a valid object");
- }
- });
- it("SR000GGR4A_testGet055", 0, function () {
- let list = new List();
- try {
- let res = list.get(1);
- } catch (err) {
- expect(err).assertEqual("TypeError: Obj is not a valid object");
- }
- });
- it("SR000GGR4A_testClear056", 0, function () {
- let list = new List();
- list.clear();
- let res1 = list.length;
- expect(res1).assertEqual(0);
- });
- it("SR000GGR4A_testGetLast057", 0, function () {
- let list = new List();
- try {
- let res = list.getLast();
- } catch (err) {
- expect(err).assertEqual("TypeError: Obj is not a valid object");
- }
- });
- it("SR000GGR4A_testReplaceAllElements058", 0, function () {
- let list = new List();
- let num = 0;
- try {
- list.replaceAllElements((item, index) => {
- num++;
- });
- } catch (err) {
- expect(err).assertEqual("TypeError: Obj is not a valid object");
- }
- expect(num).assertEqual(0);
- });
- it("SR000GGR4A_testConvertToArray059", 0, function () {
- let list = new List();
- const res = list.convertToArray();
- expect(res.length).assertEqual(0);
- });
- it("SR000GGR4A_testConvertToArray060", 0, function () {
- let list = new List();
- const res = list.convertToArray();
- expect(res.length).assertEqual(0);
- });
- it("SR000GGR4A_testlterator061", 0, function () {
- let list = new List();
- for (let index = 0; index < 10; index++) {
- list.add(index);
- }
- let num = 0;
- for (const iterator of list) {
- expect(iterator).assertEqual(num);
- num++;
- }
- });
- it("SR000GGR4A_testGetFirst062", 0, function () {
- let list = new List();
- try {
- let res = list.getFirst();
- } catch (err) {
- expect(err).assertEqual("TypeError: Obj is not a valid object");
- }
- });
- it("SR000GGR4A_testIterator063", 0, function () {
- let list = new List();
- list.add("a");
- list.add("b");
- list.add("c");
- list.add("a");
- list.add("b");
- list.removeByIndex(2);
- let arr = [];
- let itr = list[Symbol.iterator]();
- let tmp = undefined;
- do {
- tmp = itr.next().value;
- arr.push(tmp);
- } while (tmp != undefined);
- let a = ["a", "b", "a", "b"];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
-});
+/*
+ * Copyright (C) 2021 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 'deccjsunit/index';
+import List from "@ohos.util.List";
+
+describe("ListTest", function () {
+ it("SR000GGR4A_testConstructor001", 0, function () {
+ try {
+ let list = new List();
+ expect(list != undefined).assertEqual(true);
+ } catch (err) {
+ expect(err).assertEqual("Error:Cannot create new list");
+ }
+ });
+ it("SR000GGR4A_testGet002", 0, function () {
+ let list = new List();
+ list.add("四");
+ let res = list.get(0);
+ expect(res).assertEqual("四");
+ });
+ it("SR000GGR4A_testAdd002", 0, function () {
+ let list = new List();
+ list.add(8);
+ let res = list.get(0);
+ expect(res).assertEqual(8);
+ });
+ it("SR000GGR4A_testAdd003", 0, function () {
+ let list = new List();
+ let a = [1, 2, 3, 4];
+ list.add(a);
+ let res = list.get(0);
+ expect(res).assertEqual(a);
+ });
+ it("SR000GGR4A_testAdd004", 0, function () {
+ let list = new List();
+ let a = {name: "lala", age: "13"};
+ list.add(a);
+ let res = list.get(0);
+ expect(res).assertEqual(a);
+ });
+ it("SR000GGR4A_testHas005", 0, function () {
+ let list = new List();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ let res = list.has("a");
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR4A_testHas006", 0, function () {
+ let list = new List();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ let res = list.has("d");
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR4A_testEqual007", 0, function () {
+ let list = new List();
+ let list1 = new List();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list1.add("a");
+ list1.add("b");
+ list1.add("d");
+ let res = list.equal(list1);
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR4A_testEqual008", 0, function () {
+ let list = new List();
+ let list1 = new List();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list1.add("a");
+ list1.add("b");
+ list1.add("c");
+ let res = list.equal(list1);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR4A_testEqual009", 0, function () {
+ let list = new List();
+ let list1 = new List();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list1.add("a");
+ list1.add("b");
+ let res = list.equal(list1);
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR4A_testGet010", 0, function () {
+ let list = new List();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ list.add("b");
+ let res = list.get(2);
+ expect(res).assertEqual("c");
+ });
+ it("SR000GGR4A_testGetLastIndexOf011", 0, function () {
+ let list = new List();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ list.add("b");
+ let res = list.getLastIndexOf("a");
+ expect(res).assertEqual(3);
+ });
+ it("SR000GGR4A_testGetIndexOf012", 0, function () {
+ let list = new List();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ list.add("b");
+ let res = list.getIndexOf("b");
+ expect(res).assertEqual(1);
+ });
+ it("SR000GGR4A_testRemoveByIndex013", 0, function () {
+ let list = new List();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ let res = list.removeByIndex(2);
+ let arr = [];
+ list.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]);
+ }
+ });
+ it("SR000GGR4A_testRemove014", 0, function () {
+ let list = new List();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ let res = list.remove("a");
+ let arr = [];
+ list.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]);
+ }
+ });
+ it("SR000GGR4A_testConstructor015", 0, function () {
+ let list = new List();
+ list.add(1);
+ list.add(2);
+ list.add(4);
+ list.add(5);
+ list.replaceAllElements((item, index) => {
+ return (item = 2 * item);
+ });
+ let arr = [];
+ list.forEach((item, index) => {
+ arr.push(item);
+ });
+ let a = [2, 4, 8, 10];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR4A_testGetFirst016", 0, function () {
+ let list = new List();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ let res = list.getFirst();
+ expect(res).assertEqual("a");
+ });
+ it("SR000GGR4A_testGetLast017", 0, function () {
+ let list = new List();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ let res = list.getLast();
+ expect(res).assertEqual("b");
+ });
+ it("SR000GGR4A_testInsert018", 0, function () {
+ let list = new List();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ let res = list.insert("d", 3);
+ let arr = [];
+ list.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]);
+ }
+ });
+ it("SR000GGR4A_testSet019", 0, function () {
+ let list = new List();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ let res = list.set(2, "d");
+ let res1 = list.getNode(2).element;
+ expect(res1).assertEqual("d");
+ });
+ it("SR000GGR4A_testSort020", 0, function () {
+ let list = new List();
+ list.add(4);
+ list.add(3);
+ list.add(1);
+ list.add(2);
+ list.add(14);
+ list.sort((a, b) => a - b);
+ let arr = [];
+ list.forEach((item, index) => {
+ arr.push(item);
+ });
+ let a = [1, 2, 3, 4, 14];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR4A_testGetSubList021", 0, function () {
+ let list = new List();
+ list.add(4);
+ list.add(3);
+ list.add(1);
+ list.add(2);
+ list.add(14);
+ let res = list.getSubList(2, 4);
+ let arr = [];
+ res.forEach((item, index) => {
+ arr.push(item);
+ });
+ let a = [1, 2];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR4A_testConvertToArray022", 0, function () {
+ let list = new List();
+ list.add(4);
+ list.add(3);
+ list.add(1);
+ list.add(2);
+ list.add(14);
+ let res = list.convertToArray();
+
+ let a = [4, 3, 1, 2, 14];
+ for (let i = 0; i < a.length; i++) {
+ expect(res[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR4A_testLength023", 0, function () {
+ let list = new List();
+ list.add(4);
+ list.add(3);
+ list.add(1);
+ list.add(2);
+ list.add(14);
+ let res = list.length;
+ expect(res).assertEqual(5);
+ });
+ it("SR000GGR4A_testConstructor024", 0, function () {
+ let list = new List();
+ list.add(8);
+ list.add("一");
+ list.add("二");
+ list.add(5);
+ let c = [1, 2, 3, 4];
+ list.add(c);
+ list.add(6);
+ list.add("三");
+ list.add("四");
+ let arr = [];
+ for (let item of list) {
+ arr.push(item);
+ }
+ let a = [8, "一", "二", 5, c, 6, "三", "四"];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR4A_testForEach025", 0, function () {
+ let list = new List();
+ list.add(8);
+ list.add("一");
+ list.add("二");
+ list.add(5);
+ let c = [1, 2, 3, 4];
+ list.add(c);
+ list.add(6);
+ list.add("三");
+ list.add("四");
+ let arr = [];
+ list.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]);
+ }
+ });
+ it("SR000GGR4A_testIsEmpty026", 0, function () {
+ let list = new List();
+ list.add(8);
+ list.add("一");
+ list.add("二");
+ list.add(5);
+ let c = [1, 2, 3, 4];
+ list.add(c);
+ list.add(6);
+ list.add("三");
+ list.add("四");
+ let res = list.isEmpty();
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR4A_testClear027", 0, function () {
+ let list = new List();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.clear();
+ let res = list.length;
+ expect(res).assertEqual(0);
+ });
+ it("SR000GGR4A_testGet028", 0, function () {
+ let list = new List();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ list.add("b");
+ try {
+ let res = list.get(6);
+ } catch (err) {
+ expect(err).assertEqual("TypeError: Obj is not a valid object");
+ }
+ });
+ it("SR000GGR4A_testGetLastIndexOf029", 0, function () {
+ let list = new List();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ list.add("b");
+ let res = list.getLastIndexOf("F");
+ expect(res).assertEqual(-1);
+ });
+ it("SR000GGR4A_testRemoveByIndex030", 0, function () {
+ let list = new List();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ try {
+ let res = list.removeByIndex(5);
+ } catch (err) {
+ expect(err).assertEqual("Error: removeByIndex is out-of-bounds");
+ }
+ });
+ it("SR000GGR4A_testRemove031", 0, function () {
+ let list = new List();
+ list.add();
+ let res = list.remove();
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR4A_testInsert032", 0, function () {
+ let list = new List();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ let res = list.insert("d", 8);
+ expect(res).assertEqual(undefined);
+ });
+ it("SR000GGR4A_testSort033", 0, function () {
+ let list = new List();
+ list.add(";");
+ list.add("一");
+ list.add("a");
+ list.add("1");
+ list.add("2");
+ list.add("14");
+ list.sort((a, b) => a - b);
+ let arr = [];
+ list.forEach((item, index) => {
+ arr.push(item);
+ });
+ let a = [";", "一", "a", "1", "2", "14"];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR4A_testGetSubList034", 0, function () {
+ let list = new List();
+ list.add("4");
+ list.add("3");
+ list.add("1");
+ list.add("2");
+ list.add("14");
+ let res = list.getSubList(2, 8);
+ let arr = [];
+ res.forEach((item, index) => {
+ arr.push(item);
+ });
+ let a = ["1", "2"];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR4A_testGetSubList035", 0, function () {
+ let list = new List();
+ list.add("4");
+ list.add("3");
+ list.add("1");
+ list.add("2");
+ list.add("14");
+ try {
+ let res = list.getSubList(6, 8);
+ } catch (err) {
+ expect(err).assertEqual("Error: fromIndex or toIndex is out-of-bounds");
+ }
+ });
+ it("SR000GGR4A_testGetSubList036", 0, function () {
+ let list = new List();
+ list.add("4");
+ list.add("3");
+ list.add("1");
+ list.add("2");
+ list.add("14");
+ try {
+ let res = list.getSubList(6, 2);
+ } catch (err) {
+ expect(err).assertEqual(
+ "Error: toIndex cannot be less than or equal to fromIndex"
+ );
+ }
+ });
+ it("SR000GGR4A_testAdd037", 0, function () {
+ let list = new List();
+ list.add(".");
+ list.add("*");
+ list.add("|");
+ let res = list.get(0);
+ expect(res).assertEqual(".");
+ });
+ it("SR000GGR4A_testAdd038", 0, function () {
+ let list = new List();
+ list.add(".");
+ list.add("*");
+ list.add("|");
+ let arr = [];
+ list.forEach((item, index) => {
+ arr.push(item);
+ });
+ let a = [".", "*", "|"];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR4A_testAdd039", 0, function () {
+ let list = new List();
+ list.add(" ");
+ let res = list.get(0);
+ expect(res).assertEqual(" ");
+ });
+ it("SR000GGR4A_testAdd040", 0, function () {
+ let list = new List();
+ list.add("a");
+ list.add("a");
+ let res = list.get(0);
+ let res1 = list.get(1);
+ expect(res).assertEqual("a");
+ expect(res1).assertEqual("a");
+ });
+ it("SR000GGR4A_testListGet041", 0, function () {
+ let list = new List();
+ list.add("a");
+ list.add("b");
+ let res = list[0];
+ expect(res).assertEqual("a");
+ });
+ it("SR000GGR4A_testListSet042", 0, function () {
+ let list = new List();
+ list.add("a");
+ list.add("b");
+ list[0] = "c";
+ let res = list[0];
+ expect(res).assertEqual("c");
+ list.forEach((item, index) => {
+ console.log(item);
+ });
+ });
+ it("SR000GGR4A_testAdd043", 0, function () {
+ let list = new List();
+ for (let i = 0; i < 100; i++) {
+ list.add(i);
+ }
+ let res = list.get(99);
+ let res1 = list.length;
+ expect(res).assertEqual(99);
+ expect(res1).assertEqual(100);
+ });
+ it("SR000GGR4A_testAdd044", 0, function () {
+ let list = new List();
+ list.add(null);
+ let res = list.get(0);
+ expect(res).assertEqual(null);
+ });
+ it("SR000GGR4A_testAdd045", 0, function () {
+ let list = new List();
+ list.add(0.1111);
+ let res = list.get(0);
+ expect(res).assertEqual(0.1111);
+ });
+ it("SR000GGR4A_testAdd046", 0, function () {
+ let list = new List();
+ list.add(-1);
+ let res = list.get(0);
+ expect(res).assertEqual(-1);
+ });
+ it("SR000GGR4A_testAdd047", 0, function () {
+ let list = new List();
+ const obj = {};
+ list.add(obj);
+ let res = list.get(0);
+ expect(res).assertEqual(obj);
+ });
+ it("SR000GGR4A_testSort048", 0, function () {
+ let list = new List();
+ list.sort((a, b) => a - b);
+ let res1 = list.length;
+ expect(res1).assertEqual(0);
+ });
+ it("SR000GGR4A_testRemoveByIndex049", 0, function () {
+ let list = new List();
+ try {
+ let res = list.removeByIndex(1);
+ } catch (err) {
+ expect(err).assertEqual("Error: removeByIndex is out-of-bounds");
+ }
+ });
+ it("SR000GGR4A_testEqual050", 0, function () {
+ let list = new List();
+ let list1 = new List();
+ try {
+ let res = list.equal(list1);
+ } catch (err) {
+ expect(err).assertEqual("TypeError: Obj is not a valid object");
+ }
+ });
+ it("SR000GGR4A_testGetIndexOf051", 0, function () {
+ let list = new List();
+ let res = list.getIndexOf(1);
+ expect(res).assertEqual(-1);
+ });
+ it("SR000GGR4A_testForEach052", 0, function () {
+ let list = new List();
+ let num = 0;
+ try {
+ list.forEach((item, index) => {
+ num++;
+ });
+ } catch (err) {
+ expect(err).assertEqual("TypeError: Obj is not a valid object");
+ }
+ expect(num).assertEqual(0);
+ });
+ it("SR000GGR4A_testIsEmpty053", 0, function () {
+ let list = new List();
+ try {
+ let res = list.isEmpty();
+ } catch (err) {
+ expect(err).assertEqual("TypeError: is not callable");
+ }
+ });
+ it("SR000GGR4A_testHas054", 0, function () {
+ let list = new List();
+ try {
+ let res = list.has(1);
+ } catch (err) {
+ expect(err).assertEqual("TypeError: Obj is not a valid object");
+ }
+ });
+ it("SR000GGR4A_testGet055", 0, function () {
+ let list = new List();
+ try {
+ let res = list.get(1);
+ } catch (err) {
+ expect(err).assertEqual("TypeError: Obj is not a valid object");
+ }
+ });
+ it("SR000GGR4A_testClear056", 0, function () {
+ let list = new List();
+ list.clear();
+ let res1 = list.length;
+ expect(res1).assertEqual(0);
+ });
+ it("SR000GGR4A_testGetLast057", 0, function () {
+ let list = new List();
+ try {
+ let res = list.getLast();
+ } catch (err) {
+ expect(err).assertEqual("TypeError: Obj is not a valid object");
+ }
+ });
+ it("SR000GGR4A_testReplaceAllElements058", 0, function () {
+ let list = new List();
+ let num = 0;
+ try {
+ list.replaceAllElements((item, index) => {
+ num++;
+ });
+ } catch (err) {
+ expect(err).assertEqual("TypeError: Obj is not a valid object");
+ }
+ expect(num).assertEqual(0);
+ });
+ it("SR000GGR4A_testConvertToArray059", 0, function () {
+ let list = new List();
+ const res = list.convertToArray();
+ expect(res.length).assertEqual(0);
+ });
+ it("SR000GGR4A_testConvertToArray060", 0, function () {
+ let list = new List();
+ const res = list.convertToArray();
+ expect(res.length).assertEqual(0);
+ });
+ it("SR000GGR4A_testlterator061", 0, function () {
+ let list = new List();
+ for (let index = 0; index < 10; index++) {
+ list.add(index);
+ }
+ let num = 0;
+ for (const iterator of list) {
+ expect(iterator).assertEqual(num);
+ num++;
+ }
+ });
+ it("SR000GGR4A_testGetFirst062", 0, function () {
+ let list = new List();
+ try {
+ let res = list.getFirst();
+ } catch (err) {
+ expect(err).assertEqual("TypeError: Obj is not a valid object");
+ }
+ });
+ it("SR000GGR4A_testIterator063", 0, function () {
+ let list = new List();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+ list.add("a");
+ list.add("b");
+ list.removeByIndex(2);
+ let arr = [];
+ let itr = list[Symbol.iterator]();
+ let tmp = undefined;
+ do {
+ tmp = itr.next().value;
+ arr.push(tmp);
+ } while (tmp != undefined);
+ let a = ["a", "b", "a", "b"];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+});
diff --git a/compileruntime/containerLine_lib_standard/src/main/js/test/Main.test.js b/compileruntime/containerLine_lib_standard/src/main/js/test/Main.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..1880915df8ab3467958485b3d58bc89b98bc1efe
--- /dev/null
+++ b/compileruntime/containerLine_lib_standard/src/main/js/test/Main.test.js
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+require('./ExampleJsunit.test.js');
+require('./Deque.test.js');
+require('./ArrayList.test.js');
+require('./Queue.test.js');
+require('./Stack.test.js');
+require('./List.test.js');
+require('./LinkedList.test.js');
+require('./Vector.test.js');
+
diff --git a/compileruntime/util_lib_standard/src/main/js/test/Queue.test.js b/compileruntime/containerLine_lib_standard/src/main/js/test/Queue.test.js
similarity index 96%
rename from compileruntime/util_lib_standard/src/main/js/test/Queue.test.js
rename to compileruntime/containerLine_lib_standard/src/main/js/test/Queue.test.js
index 98ca9adef39f2fdd41f0b91a4bd8eb497625bf92..9647406b4eccc346469e405bec1d978b54ca8755 100644
--- a/compileruntime/util_lib_standard/src/main/js/test/Queue.test.js
+++ b/compileruntime/containerLine_lib_standard/src/main/js/test/Queue.test.js
@@ -1,201 +1,201 @@
-/*
- * Copyright (C) 2021 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 'deccjsunit/index';
-import Queue from "@ohos.util.Queue";
-
-describe("QueueTest", function () {
- it("SR000GGR48_testConstructor001", 0, function () {
- try {
- let queue = new Queue();
- } catch (err) {
- expect(err).assertEqual("Error:Cannot create new queue");
- }
- });
- it("SR000GGR48_testAdd002", 0, function () {
- let queue = new Queue();
- queue.add("四");
- let res = queue.getFirst();
- expect(res).assertEqual("四");
- });
- it("SR000GGR48_testAdd003", 0, function () {
- let queue = new Queue();
- queue.add(8);
- let res = queue.getFirst();
- expect(res).assertEqual(8);
- });
- it("SR000GGR48_testAdd004", 0, function () {
- let queue = new Queue();
- let a = ["a", "b", "c"];
- queue.add(a);
- let res = queue.getFirst();
- expect(res).assertEqual(a);
- });
- it("SR000GGR48_testGetFirst005", 0, function () {
- let queue = new Queue();
- queue.add(6);
- queue.add("四");
- let res = queue.getFirst();
- expect(res).assertEqual(6);
- });
- it("SR000GGR48_testPop006", 0, function () {
- let queue = new Queue();
- queue.add(6);
- queue.add("四");
- let res = queue.pop();
- let res1 = queue.getFirst();
- expect(res).assertEqual(6);
- expect(res1).assertEqual("四");
- });
- it("SR000GGR48_testForEach007", 0, function () {
- let queue = new Queue();
- queue.add(8);
- queue.add("一");
- queue.add("二");
- queue.add(1);
- queue.add(2);
- queue.add(3);
- queue.add(4);
- queue.add(5);
- queue.add(6);
- let c = ["a", "b", "c", "d"];
- queue.add(c);
- let arr = [];
- queue.forEach((item, index) => {
- arr.push(item);
- });
- let a = [8, "一", "二", 1, 2, 3, 4, 5, 6, c];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR48_testIterator008", 0, function () {
- let queue = new Queue();
- queue.add(8);
- queue.add("一");
- queue.add("二");
- queue.add(5);
- queue.add(6);
- queue.add("三");
- queue.add("四");
- let arr = [];
- for (let item of queue) {
- arr.push(item);
- }
- let a = [8, "一", "二", 5, 6, "三", "四"];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR48_testLength009", 0, function () {
- let queue = new Queue();
- queue.add(8);
- queue.add("一");
- queue.add("二");
- queue.add(1);
- queue.add(2);
- queue.add(3);
- queue.add(4);
- queue.add(5);
- queue.add(6);
- let res = queue.length;
- expect(9).assertEqual(res);
- });
- it("SR000GGR48_testAdd010", 0, function () {
- let queue = new Queue();
- queue.add("$");
- let res = queue.getFirst();
- expect(res).assertEqual("$");
- });
- it("SR000GGR48_testAdd011", 0, function () {
- let queue = new Queue();
- queue.add(" ");
- let res = queue.getFirst();
- expect(res).assertEqual(" ");
- });
- it("SR000GGR48_testAdd012", 0, function () {
- let queue = new Queue();
- queue.add(null);
- let res = queue.getFirst();
- expect(res).assertEqual(null);
- });
- it("SR000GGR48_testAdd013", 0, function () {
- let queue = new Queue();
- queue.add(undefined);
- let res = queue.getFirst();
- expect(res).assertEqual(undefined);
- });
- it("SR000GGR48_testAdd014", 0, function () {
- let queue = new Queue();
- for (let i = 0; i < 100; i++) {
- queue.add(i);
- }
- let res = queue.length;
- expect(res).assertEqual(100);
- });
- it("SR000GGR48_testGetFirst015", 0, function () {
- let queue = new Queue();
- let res = queue.getFirst();
- expect(res).assertEqual(undefined);
- });
- it("SR000GGR48_testPop016", 0, function () {
- let queue = new Queue();
- let res = queue.pop();
- expect(res).assertEqual(undefined);
- });
- it("SR000GGR48_testForEach017", 0, function () {
- let queue = new Queue();
- let arr = [];
- try {
- queue.forEach((item, index) => {
- arr.push(item);
- });
- } catch (err) {
- expect(err).assertEqual("Error: Queue: get out-of-bounds");
- }
- expect(arr.length).assertEqual(1);
- });
- it("SR000GGR48_testIterator018", 0, function () {
- let queue = new Queue();
- let arr = [];
- try {
- for (let item of queue) {
- arr.push(item);
- }
- } catch (err) {
- expect(err).assertEqual("Error:Cannot create new stack");
- }
- expect(arr.length).assertEqual(0);
- });
- it("SR000GGR48_testIterator019", 0, function () {
- let queue = new Queue();
- queue.add(8);
- queue.add("一");
- queue.add("二");
- queue.add(5);
- queue.add(6);
- queue.add("三");
- queue.add("四");
- let arr = [];
- let size = queue.length;
- let itr = queue[Symbol.iterator]();
- for (let i = 0; i < size; i++) {
- arr.push(itr.next().value);
- }
- let a = [8, "一", "二", 5, 6, "三", "四"];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
-});
+/*
+ * Copyright (C) 2021 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 'deccjsunit/index';
+import Queue from "@ohos.util.Queue";
+
+describe("QueueTest", function () {
+ it("SR000GGR48_testConstructor001", 0, function () {
+ try {
+ let queue = new Queue();
+ } catch (err) {
+ expect(err).assertEqual("Error:Cannot create new queue");
+ }
+ });
+ it("SR000GGR48_testAdd002", 0, function () {
+ let queue = new Queue();
+ queue.add("四");
+ let res = queue.getFirst();
+ expect(res).assertEqual("四");
+ });
+ it("SR000GGR48_testAdd003", 0, function () {
+ let queue = new Queue();
+ queue.add(8);
+ let res = queue.getFirst();
+ expect(res).assertEqual(8);
+ });
+ it("SR000GGR48_testAdd004", 0, function () {
+ let queue = new Queue();
+ let a = ["a", "b", "c"];
+ queue.add(a);
+ let res = queue.getFirst();
+ expect(res).assertEqual(a);
+ });
+ it("SR000GGR48_testGetFirst005", 0, function () {
+ let queue = new Queue();
+ queue.add(6);
+ queue.add("四");
+ let res = queue.getFirst();
+ expect(res).assertEqual(6);
+ });
+ it("SR000GGR48_testPop006", 0, function () {
+ let queue = new Queue();
+ queue.add(6);
+ queue.add("四");
+ let res = queue.pop();
+ let res1 = queue.getFirst();
+ expect(res).assertEqual(6);
+ expect(res1).assertEqual("四");
+ });
+ it("SR000GGR48_testForEach007", 0, function () {
+ let queue = new Queue();
+ queue.add(8);
+ queue.add("一");
+ queue.add("二");
+ queue.add(1);
+ queue.add(2);
+ queue.add(3);
+ queue.add(4);
+ queue.add(5);
+ queue.add(6);
+ let c = ["a", "b", "c", "d"];
+ queue.add(c);
+ let arr = [];
+ queue.forEach((item, index) => {
+ arr.push(item);
+ });
+ let a = [8, "一", "二", 1, 2, 3, 4, 5, 6, c];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR48_testIterator008", 0, function () {
+ let queue = new Queue();
+ queue.add(8);
+ queue.add("一");
+ queue.add("二");
+ queue.add(5);
+ queue.add(6);
+ queue.add("三");
+ queue.add("四");
+ let arr = [];
+ for (let item of queue) {
+ arr.push(item);
+ }
+ let a = [8, "一", "二", 5, 6, "三", "四"];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR48_testLength009", 0, function () {
+ let queue = new Queue();
+ queue.add(8);
+ queue.add("一");
+ queue.add("二");
+ queue.add(1);
+ queue.add(2);
+ queue.add(3);
+ queue.add(4);
+ queue.add(5);
+ queue.add(6);
+ let res = queue.length;
+ expect(9).assertEqual(res);
+ });
+ it("SR000GGR48_testAdd010", 0, function () {
+ let queue = new Queue();
+ queue.add("$");
+ let res = queue.getFirst();
+ expect(res).assertEqual("$");
+ });
+ it("SR000GGR48_testAdd011", 0, function () {
+ let queue = new Queue();
+ queue.add(" ");
+ let res = queue.getFirst();
+ expect(res).assertEqual(" ");
+ });
+ it("SR000GGR48_testAdd012", 0, function () {
+ let queue = new Queue();
+ queue.add(null);
+ let res = queue.getFirst();
+ expect(res).assertEqual(null);
+ });
+ it("SR000GGR48_testAdd013", 0, function () {
+ let queue = new Queue();
+ queue.add(undefined);
+ let res = queue.getFirst();
+ expect(res).assertEqual(undefined);
+ });
+ it("SR000GGR48_testAdd014", 0, function () {
+ let queue = new Queue();
+ for (let i = 0; i < 100; i++) {
+ queue.add(i);
+ }
+ let res = queue.length;
+ expect(res).assertEqual(100);
+ });
+ it("SR000GGR48_testGetFirst015", 0, function () {
+ let queue = new Queue();
+ let res = queue.getFirst();
+ expect(res).assertEqual(undefined);
+ });
+ it("SR000GGR48_testPop016", 0, function () {
+ let queue = new Queue();
+ let res = queue.pop();
+ expect(res).assertEqual(undefined);
+ });
+ it("SR000GGR48_testForEach017", 0, function () {
+ let queue = new Queue();
+ let arr = [];
+ try {
+ queue.forEach((item, index) => {
+ arr.push(item);
+ });
+ } catch (err) {
+ expect(err).assertEqual("Error: Queue: get out-of-bounds");
+ }
+ expect(arr.length).assertEqual(1);
+ });
+ it("SR000GGR48_testIterator018", 0, function () {
+ let queue = new Queue();
+ let arr = [];
+ try {
+ for (let item of queue) {
+ arr.push(item);
+ }
+ } catch (err) {
+ expect(err).assertEqual("Error:Cannot create new stack");
+ }
+ expect(arr.length).assertEqual(0);
+ });
+ it("SR000GGR48_testIterator019", 0, function () {
+ let queue = new Queue();
+ queue.add(8);
+ queue.add("一");
+ queue.add("二");
+ queue.add(5);
+ queue.add(6);
+ queue.add("三");
+ queue.add("四");
+ let arr = [];
+ let size = queue.length;
+ let itr = queue[Symbol.iterator]();
+ for (let i = 0; i < size; i++) {
+ arr.push(itr.next().value);
+ }
+ let a = [8, "一", "二", 5, 6, "三", "四"];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+});
diff --git a/compileruntime/util_lib_standard/src/main/js/test/Stack.test.js b/compileruntime/containerLine_lib_standard/src/main/js/test/Stack.test.js
similarity index 96%
rename from compileruntime/util_lib_standard/src/main/js/test/Stack.test.js
rename to compileruntime/containerLine_lib_standard/src/main/js/test/Stack.test.js
index 66fec72bbd3e2a4cfc106614059b55c62caac9e2..c72a064ac5c779ec05507dcfe1df09cf55c63c96 100644
--- a/compileruntime/util_lib_standard/src/main/js/test/Stack.test.js
+++ b/compileruntime/containerLine_lib_standard/src/main/js/test/Stack.test.js
@@ -1,320 +1,320 @@
-/*
- * Copyright (C) 2021 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 'deccjsunit/index';
-import Stack from "@ohos.util.Stack";
-
-describe("StackTest", function () {
- it("SR000GGR49_testConstructor001", 0, function () {
- try {
- let stack = new Stack();
- expect(stack != undefined).assertEqual(true);
- } catch (err) {
- expect(err).assertEqual("Error: Cannot create new stack");
- }
- });
- it("SR000GGR49_testPush002", 0, function () {
- let stack = new Stack();
- stack.push("四");
- let res = stack.peek();
- expect(res).assertEqual("四");
- });
- it("SR000GGR49_testPush003", 0, function () {
- let stack = new Stack();
- stack.push(8);
- let res = stack.peek();
- expect(res).assertEqual(8);
- });
- it("SR000GGR49_testPush004", 0, function () {
- let stack = new Stack();
- let a = {name: "lala", age: "13岁"};
- stack.push(a);
- let res = stack.peek();
- expect(res).assertEqual(a);
- });
- it("SR000GGR49_testPush005", 0, function () {
- let stack = new Stack();
- let a = [1, 2, 3, 4];
- stack.push(a);
- let res = stack.peek();
- expect(res).assertEqual(a);
- });
- it("SR000GGR49_testPeek006", 0, function () {
- let stack = new Stack();
- let a = [1, 2, 3, 4];
- stack.push(a);
- stack.push("A");
- stack.push("B");
- stack.push(1);
- let res = stack.peek();
- expect(res).assertEqual(1);
- });
- it("SR000GGR49_testLocate007", 0, function () {
- let stack = new Stack();
- let a = [1, 2, 3, 4];
- stack.push(8);
- stack.push(a);
- stack.push("A");
- stack.push("B");
- stack.push(1);
- let res = stack.locate("A");
- let res1 = stack.locate("C");
- expect(res).assertEqual(2);
- expect(res1).assertEqual(-1);
- });
- it("SR000GGR49_testPop008", 0, function () {
- let stack = new Stack();
- stack.push("B");
- stack.push(1);
- let res = stack.pop();
- let res1 = stack.peek();
- expect(res).assertEqual(1);
- expect(res1).assertEqual("B");
- });
- it("SR000GGR49_testForEach009", 0, function () {
- let stack = new Stack();
- stack.push(8);
- stack.push("三");
- stack.push(5);
- let c = {name: "lili", age: "13"};
- stack.push(c);
- stack.push(6);
- stack.push("四");
- let arr = [];
- stack.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]);
- }
- });
- it("SR000GGR49_testIterator010", 0, function () {
- let stack = new Stack();
- stack.push(8);
- stack.push("一");
- stack.push("二");
- stack.push(5);
- let c = [1, 2, 3, 4];
- stack.push(c);
- stack.push(6);
- stack.push("三");
- stack.push("四");
- let arr = [];
- for (let item of stack) {
- arr.push(item);
- }
- let a = [8, "一", "二", 5, c, 6, "三", "四"];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR49_testLength011_1", 0, function () {
- let stack = new Stack();
- stack.push(8);
- stack.push("一");
- stack.push("二");
- stack.push(5);
- let res = stack.length;
- expect(4).assertEqual(res);
- });
- it("SR000GGR49_testLength011_2", 0, function () {
- let stack = new Stack();
- let res = stack.length;
- expect(0).assertEqual(res);
- });
- it("SR000GGR49_testIsEmpty012_1", 0, function () {
- let stack = new Stack();
- stack.push(8);
- stack.push("一");
- stack.push("二");
- stack.push(5);
- let res = stack.isEmpty();
- expect(res).assertEqual(false);
- });
- it("SR000GGR49_testIsEmpty012_2", 0, function () {
- let stack = new Stack();
- let res = stack.isEmpty();
- expect(res).assertEqual(true);
- });
- it("SR000GGR49_testPush013", 0, function () {
- let stack = new Stack();
- stack.push("你好世界");
- let res = stack.peek();
- expect(res).assertEqual("你好世界");
- });
- it("SR000GGR49_testPush014", 0, function () {
- let stack = new Stack();
- stack.push(1234);
- let res = stack.peek();
- expect(res).assertEqual(1234);
- });
- it("SR000GGR49_testPush015", 0, function () {
- let stack = new Stack();
- stack.push(1.234);
- let res = stack.peek();
- expect(res).assertEqual(1.234);
- });
- it("SR000GGR49_testPush016", 0, function () {
- let stack = new Stack();
- stack.push(-1234);
- let res = stack.peek();
- expect(res).assertEqual(-1234);
- });
- it("SR000GGR49_testPush017", 0, function () {
- let stack = new Stack();
- stack.push(0);
- let res = stack.peek();
- expect(res).assertEqual(0);
- });
- it("SR000GGR49_testPush018", 0, function () {
- let stack = new Stack();
- stack.push(10);
- stack.push(3.14);
- stack.push(-2);
- stack.push("AB");
- stack.push("*");
- let res = stack.peek();
- expect(res).assertEqual("*");
- });
- it("SR000GGR49_testPush019", 0, function () {
- let stack = new Stack();
- let arr = {};
- stack.push(arr);
- let res = stack.peek();
- expect(res).assertEqual(arr);
- });
- it("SR000GGR49_testPush020", 0, function () {
- let stack = new Stack();
- let arr = [];
- stack.push(arr);
- let res = stack.peek();
- expect(res).assertEqual(arr);
- });
- it("SR000GGR49_testPush021", 0, function () {
- let stack = new Stack();
- stack.push("hello world");
- let res = stack.peek();
- expect(res).assertEqual("hello world");
- });
- it("SR000GGR49_testPush022", 0, function () {
- let stack = new Stack();
- stack.push("~!@#$^&*()_+-*/=.?<>:;|{}[]");
- let res = stack.peek();
- expect(res).assertEqual("~!@#$^&*()_+-*/=.?<>:;|{}[]");
- });
- it("SR000GGR49_testPush023", 0, function () {
- let stack = new Stack();
- stack.push("");
- let res = stack.peek();
- expect(res).assertEqual("");
- });
- it("SR000GGR49_testPush024", 0, function () {
- let stack = new Stack();
- stack.push(true);
- let res = stack.peek();
- expect(res).assertEqual(true);
- });
- it("SR000GGR49_testPush025", 0, function () {
- let stack = new Stack();
- stack.push(false);
- let res = stack.peek();
- expect(res).assertEqual(false);
- });
- it("SR000GGR49_testPush026", 0, function () {
- let stack = new Stack();
- stack.push(null);
- let res = stack.peek();
- expect(res).assertEqual(null);
- });
- it("SR000GGR49_testPush027", 0, function () {
- let stack = new Stack();
- stack.push(undefined);
- let res = stack.peek();
- expect(res).assertEqual(undefined);
- });
- it("SR000GGR49_testPeek028", 0, function () {
- let stack = new Stack();
- try {
- let res = stack.peek();
- } catch (err) {
- expect(err).assertEqual("Error: Stack: get out-of-bounds");
- }
- });
- it("SR000GGR49_testPop029", 0, function () {
- let stack = new Stack();
- try {
- let res = stack.pop();
- } catch (err) {
- expect(err).assertEqual("Error: Stack: get out-of-bounds");
- }
- });
- it("SR000GGR49_testForEach030", 0, function () {
- let stack = new Stack();
- let arr = [];
- try {
- stack.forEach((item, index) => {
- arr.push(item);
- });
- } catch (err) {
- expect(err).assertEqual("Error:Cannot create new stack");
- }
- expect(arr.length).assertEqual(0);
- });
- it("SR000GGR49_testIterator031", 0, function () {
- let stack = new Stack();
- let arr = [];
- try {
- for (let item of stack) {
- arr.push(item);
- }
- } catch (err) {
- expect(err).assertEqual("Error:Cannot create new stack");
- }
- expect(arr.length).assertEqual(0);
- });
- it("SR000GGR49_testPush032", 0, function () {
- let stack = new Stack();
- for (let i = 0; i < 1000; i++) {
- stack.push(i);
- }
- let res = stack.length;
- expect(res).assertEqual(1000);
- let res1 = stack.peek();
- expect(res1).assertEqual(999);
- });
- it("SR000GGR49_testIterator033", 0, function () {
- let stack = new Stack();
- stack.push(8);
- stack.push("一");
- stack.push("二");
- stack.push(5);
- let c = [1, 2, 3, 4];
- stack.push(c);
- stack.push(6);
- stack.push("三");
- stack.push("四");
- let arr = [];
- let itr = stack[Symbol.iterator]();
- let tmp = undefined;
- do {
- tmp = itr.next().value;
- arr.push(tmp);
- } while (tmp != undefined);
- let a = [8, "一", "二", 5, c, 6, "三", "四"];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
-});
+/*
+ * Copyright (C) 2021 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 'deccjsunit/index';
+import Stack from "@ohos.util.Stack";
+
+describe("StackTest", function () {
+ it("SR000GGR49_testConstructor001", 0, function () {
+ try {
+ let stack = new Stack();
+ expect(stack != undefined).assertEqual(true);
+ } catch (err) {
+ expect(err).assertEqual("Error: Cannot create new stack");
+ }
+ });
+ it("SR000GGR49_testPush002", 0, function () {
+ let stack = new Stack();
+ stack.push("四");
+ let res = stack.peek();
+ expect(res).assertEqual("四");
+ });
+ it("SR000GGR49_testPush003", 0, function () {
+ let stack = new Stack();
+ stack.push(8);
+ let res = stack.peek();
+ expect(res).assertEqual(8);
+ });
+ it("SR000GGR49_testPush004", 0, function () {
+ let stack = new Stack();
+ let a = {name: "lala", age: "13岁"};
+ stack.push(a);
+ let res = stack.peek();
+ expect(res).assertEqual(a);
+ });
+ it("SR000GGR49_testPush005", 0, function () {
+ let stack = new Stack();
+ let a = [1, 2, 3, 4];
+ stack.push(a);
+ let res = stack.peek();
+ expect(res).assertEqual(a);
+ });
+ it("SR000GGR49_testPeek006", 0, function () {
+ let stack = new Stack();
+ let a = [1, 2, 3, 4];
+ stack.push(a);
+ stack.push("A");
+ stack.push("B");
+ stack.push(1);
+ let res = stack.peek();
+ expect(res).assertEqual(1);
+ });
+ it("SR000GGR49_testLocate007", 0, function () {
+ let stack = new Stack();
+ let a = [1, 2, 3, 4];
+ stack.push(8);
+ stack.push(a);
+ stack.push("A");
+ stack.push("B");
+ stack.push(1);
+ let res = stack.locate("A");
+ let res1 = stack.locate("C");
+ expect(res).assertEqual(2);
+ expect(res1).assertEqual(-1);
+ });
+ it("SR000GGR49_testPop008", 0, function () {
+ let stack = new Stack();
+ stack.push("B");
+ stack.push(1);
+ let res = stack.pop();
+ let res1 = stack.peek();
+ expect(res).assertEqual(1);
+ expect(res1).assertEqual("B");
+ });
+ it("SR000GGR49_testForEach009", 0, function () {
+ let stack = new Stack();
+ stack.push(8);
+ stack.push("三");
+ stack.push(5);
+ let c = {name: "lili", age: "13"};
+ stack.push(c);
+ stack.push(6);
+ stack.push("四");
+ let arr = [];
+ stack.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]);
+ }
+ });
+ it("SR000GGR49_testIterator010", 0, function () {
+ let stack = new Stack();
+ stack.push(8);
+ stack.push("一");
+ stack.push("二");
+ stack.push(5);
+ let c = [1, 2, 3, 4];
+ stack.push(c);
+ stack.push(6);
+ stack.push("三");
+ stack.push("四");
+ let arr = [];
+ for (let item of stack) {
+ arr.push(item);
+ }
+ let a = [8, "一", "二", 5, c, 6, "三", "四"];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR49_testLength011_1", 0, function () {
+ let stack = new Stack();
+ stack.push(8);
+ stack.push("一");
+ stack.push("二");
+ stack.push(5);
+ let res = stack.length;
+ expect(4).assertEqual(res);
+ });
+ it("SR000GGR49_testLength011_2", 0, function () {
+ let stack = new Stack();
+ let res = stack.length;
+ expect(0).assertEqual(res);
+ });
+ it("SR000GGR49_testIsEmpty012_1", 0, function () {
+ let stack = new Stack();
+ stack.push(8);
+ stack.push("一");
+ stack.push("二");
+ stack.push(5);
+ let res = stack.isEmpty();
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR49_testIsEmpty012_2", 0, function () {
+ let stack = new Stack();
+ let res = stack.isEmpty();
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR49_testPush013", 0, function () {
+ let stack = new Stack();
+ stack.push("你好世界");
+ let res = stack.peek();
+ expect(res).assertEqual("你好世界");
+ });
+ it("SR000GGR49_testPush014", 0, function () {
+ let stack = new Stack();
+ stack.push(1234);
+ let res = stack.peek();
+ expect(res).assertEqual(1234);
+ });
+ it("SR000GGR49_testPush015", 0, function () {
+ let stack = new Stack();
+ stack.push(1.234);
+ let res = stack.peek();
+ expect(res).assertEqual(1.234);
+ });
+ it("SR000GGR49_testPush016", 0, function () {
+ let stack = new Stack();
+ stack.push(-1234);
+ let res = stack.peek();
+ expect(res).assertEqual(-1234);
+ });
+ it("SR000GGR49_testPush017", 0, function () {
+ let stack = new Stack();
+ stack.push(0);
+ let res = stack.peek();
+ expect(res).assertEqual(0);
+ });
+ it("SR000GGR49_testPush018", 0, function () {
+ let stack = new Stack();
+ stack.push(10);
+ stack.push(3.14);
+ stack.push(-2);
+ stack.push("AB");
+ stack.push("*");
+ let res = stack.peek();
+ expect(res).assertEqual("*");
+ });
+ it("SR000GGR49_testPush019", 0, function () {
+ let stack = new Stack();
+ let arr = {};
+ stack.push(arr);
+ let res = stack.peek();
+ expect(res).assertEqual(arr);
+ });
+ it("SR000GGR49_testPush020", 0, function () {
+ let stack = new Stack();
+ let arr = [];
+ stack.push(arr);
+ let res = stack.peek();
+ expect(res).assertEqual(arr);
+ });
+ it("SR000GGR49_testPush021", 0, function () {
+ let stack = new Stack();
+ stack.push("hello world");
+ let res = stack.peek();
+ expect(res).assertEqual("hello world");
+ });
+ it("SR000GGR49_testPush022", 0, function () {
+ let stack = new Stack();
+ stack.push("~!@#$^&*()_+-*/=.?<>:;|{}[]");
+ let res = stack.peek();
+ expect(res).assertEqual("~!@#$^&*()_+-*/=.?<>:;|{}[]");
+ });
+ it("SR000GGR49_testPush023", 0, function () {
+ let stack = new Stack();
+ stack.push("");
+ let res = stack.peek();
+ expect(res).assertEqual("");
+ });
+ it("SR000GGR49_testPush024", 0, function () {
+ let stack = new Stack();
+ stack.push(true);
+ let res = stack.peek();
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR49_testPush025", 0, function () {
+ let stack = new Stack();
+ stack.push(false);
+ let res = stack.peek();
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR49_testPush026", 0, function () {
+ let stack = new Stack();
+ stack.push(null);
+ let res = stack.peek();
+ expect(res).assertEqual(null);
+ });
+ it("SR000GGR49_testPush027", 0, function () {
+ let stack = new Stack();
+ stack.push(undefined);
+ let res = stack.peek();
+ expect(res).assertEqual(undefined);
+ });
+ it("SR000GGR49_testPeek028", 0, function () {
+ let stack = new Stack();
+ try {
+ let res = stack.peek();
+ } catch (err) {
+ expect(err).assertEqual("Error: Stack: get out-of-bounds");
+ }
+ });
+ it("SR000GGR49_testPop029", 0, function () {
+ let stack = new Stack();
+ try {
+ let res = stack.pop();
+ } catch (err) {
+ expect(err).assertEqual("Error: Stack: get out-of-bounds");
+ }
+ });
+ it("SR000GGR49_testForEach030", 0, function () {
+ let stack = new Stack();
+ let arr = [];
+ try {
+ stack.forEach((item, index) => {
+ arr.push(item);
+ });
+ } catch (err) {
+ expect(err).assertEqual("Error:Cannot create new stack");
+ }
+ expect(arr.length).assertEqual(0);
+ });
+ it("SR000GGR49_testIterator031", 0, function () {
+ let stack = new Stack();
+ let arr = [];
+ try {
+ for (let item of stack) {
+ arr.push(item);
+ }
+ } catch (err) {
+ expect(err).assertEqual("Error:Cannot create new stack");
+ }
+ expect(arr.length).assertEqual(0);
+ });
+ it("SR000GGR49_testPush032", 0, function () {
+ let stack = new Stack();
+ for (let i = 0; i < 1000; i++) {
+ stack.push(i);
+ }
+ let res = stack.length;
+ expect(res).assertEqual(1000);
+ let res1 = stack.peek();
+ expect(res1).assertEqual(999);
+ });
+ it("SR000GGR49_testIterator033", 0, function () {
+ let stack = new Stack();
+ stack.push(8);
+ stack.push("一");
+ stack.push("二");
+ stack.push(5);
+ let c = [1, 2, 3, 4];
+ stack.push(c);
+ stack.push(6);
+ stack.push("三");
+ stack.push("四");
+ let arr = [];
+ let itr = stack[Symbol.iterator]();
+ let tmp = undefined;
+ do {
+ tmp = itr.next().value;
+ arr.push(tmp);
+ } while (tmp != undefined);
+ let a = [8, "一", "二", 5, c, 6, "三", "四"];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+});
diff --git a/compileruntime/util_lib_standard/src/main/js/test/Vector.test.js b/compileruntime/containerLine_lib_standard/src/main/js/test/Vector.test.js
similarity index 96%
rename from compileruntime/util_lib_standard/src/main/js/test/Vector.test.js
rename to compileruntime/containerLine_lib_standard/src/main/js/test/Vector.test.js
index 0004ea46531782364abc23baecb493ce30155ad8..f5a0a6cfd8c46582aa1e293ed834d5d9f76cafbf 100644
--- a/compileruntime/util_lib_standard/src/main/js/test/Vector.test.js
+++ b/compileruntime/containerLine_lib_standard/src/main/js/test/Vector.test.js
@@ -1,846 +1,846 @@
-/*
- * Copyright (C) 2021 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 'deccjsunit/index';
-import Vector from "@ohos.util.Vector";
-
-describe("VectorTest", function () {
- it("SR000GGR47_testConstructor001", 0, function () {
- try {
- let vector = new Vector();
- } catch (err) {
- expect(err).assertEqual("Error: Cannot create new vector");
- }
- });
- it("SR000GGR47_testAdd002", 0, function () {
- let vector = new Vector();
- vector.add("四");
- let res = vector.getFirstElement();
- expect(res).assertEqual("四");
- });
- it("SR000GGR47_testAdd003 ", 0, function () {
- let vector = new Vector();
- vector.add(4);
- let res = vector.getFirstElement();
- expect(res).assertEqual(4);
- });
- it("SR000GGR47_testAdd004 ", 0, function () {
- let vector = new Vector();
- let a = {name: "lala", age: "13岁"};
- vector.add(a);
- let res = vector.getFirstElement();
- expect(res).assertEqual(a);
- });
- it("SR000GGR47_testAdd005 ", 0, function () {
- let vector = new Vector();
- let a = [1, 2, 3, 4];
- vector.add(a);
- let res = vector.getFirstElement();
- expect(res).assertEqual(a);
- });
- it("SR000GGR47_testInsert006", 0, function () {
- let vector = new Vector();
- vector.add("四");
- vector.add("三");
- vector.add(1);
- vector.add("a");
- vector.insert(8, 2);
- let res = vector.get(2);
- expect(res).assertEqual(8);
- });
- it("SR000GGR47_testInsert007", 0, function () {
- let vector = new Vector();
- vector.add("四");
- vector.add("三");
- vector.add(1);
- vector.add("a");
- try {
- vector.insert(-1, 2);
- } catch (err) {
- expect(err).assertEqual("Vector: get out-of-bounds");
- }
- });
- it("SR000GGR47_testInsert008", 0, function () {
- let vector = new Vector();
- vector.add("四");
- vector.add("三");
- vector.add(1);
- vector.add("a");
- let capacity = vector.getCapacity();
- try {
- vector.insert(capacity, 2);
- } catch (err) {
- expect(err).assertEqual("Vector: get out-of-bounds");
- }
- });
- it("SR000GGR47_testInsert009", 0, function () {
- let vector = new Vector();
- vector.add("四");
- vector.add("三");
- vector.add(1);
- vector.add("a");
- let capacity = vector.getCapacity();
- try {
- vector.insert(capacity + 1, 2);
- } catch (err) {
- expect(err).assertEqual("Vector: get out-of-bounds");
- }
- });
- it("SR000GGR47_testLength010", 0, function () {
- let vector = new Vector();
- vector.add("四");
- vector.add("三");
- vector.add(1);
- vector.add("a");
- let res = vector.length;
- expect(res).assertEqual(4);
- });
- it("SR000GGR47_testHas011", 0, function () {
- let vector = new Vector();
- vector.add("四");
- vector.add("三");
- vector.add(1);
- vector.add("a");
- vector.insert(8, 2);
- let res = vector.has(8);
- expect(res).assertEqual(true);
- });
- it("SR000GGR47_testHas012", 0, function () {
- let vector = new Vector();
- vector.add("四");
- vector.add("三");
- vector.add(1);
- vector.add("a");
- vector.insert(8, 2);
- let res1 = vector.has("二");
- expect(res1).assertEqual(false);
- });
- it("SR000GGR47_testGet013", 0, function () {
- let vector = new Vector();
- vector.add("四");
- vector.add("三");
- vector.add(1);
- vector.add("a");
- vector.insert(8, 2);
- let res1 = vector.get(1);
- expect(res1).assertEqual("三");
- });
- it("SR000GGR47_testGet014", 0, function () {
- let vector = new Vector();
- vector.add("四");
- vector.add("三");
- vector.add(1);
- vector.add("a");
- vector.insert(8, 2);
- try {
- let res = vector.get(10);
- } catch (err) {
- expect(err).assertEqual("Error: Vector: get out-of-bounds");
- }
- });
- it("SR000GGR47_testGetIndexOf015", 0, function () {
- let vector = new Vector();
- vector.add(1);
- vector.add("三");
- vector.add(1);
- vector.add("a");
- vector.insert(1, 2);
- let res1 = vector.getIndexOf(1);
- expect(res1).assertEqual(0);
- });
- it("SR000GGR47_testGetFirstElement016", 0, function () {
- let vector = new Vector();
- vector.add("四");
- vector.add("三");
- vector.add(1);
- vector.add("a");
- vector.insert(8, 2);
- try {
- let res = vector.getFirstElement();
- } catch (err) {
- expect(err).assertEqual("Error: Vector: get out-of-bounds");
- }
- });
- it("SR000GGR47_testGetFirstElement017", 0, function () {
- let vector = new Vector();
- try {
- let res = vector.getFirstElement();
- } catch (err) {
- expect(err).assertEqual("Error: Vector: get out-of-bounds");
- }
- });
- it("SR000GGR47_testSet018", 0, function () {
- let vector = new Vector();
- vector.add("四");
- vector.add("三");
- vector.add(1);
- vector.add("a");
- vector.insert(8, 2);
- vector.set(1, "二");
- let res = vector.get(1);
- expect(res).assertEqual("二");
- });
- it("SR000GGR47_testRemoveByIndex019", 0, function () {
- let vector = new Vector();
- vector.add("四");
- vector.add("三");
- vector.add(1);
- vector.add("a");
- vector.removeByIndex(2);
- let res = vector.has(1);
- expect(res).assertEqual(false);
- });
- it("SR000GGR47_testRemove020", 0, function () {
- let vector = new Vector();
- vector.add("四");
- vector.add("三");
- vector.add(1);
- vector.add("a");
- vector.remove("三");
- let res = vector.has("三");
- expect(res).assertEqual(false);
- });
- it("SR000GGR47_testRemove021", 0, function () {
- let vector = new Vector();
- vector.add("四");
- vector.add("三");
- vector.add(1);
- vector.add("a");
- let res = vector.remove(2);
- expect(res).assertEqual(false);
- });
- it("SR000GGR47_testGetLastElement022", 0, function () {
- let vector = new Vector();
- vector.add("四");
- vector.add("三");
- vector.add(1);
- vector.add("a");
- let res1 = vector.length;
- let res = vector.getLastElement();
- expect(res).assertEqual("a");
- });
- it("SR000GGR47_testGetLastElement023", 0, function () {
- let vector = new Vector();
- let res1 = vector.length;
- try {
- let res = vector.getLastElement();
- } catch (err) {
- expect(err).assertEqual("Error: Vector: get out-of-bounds");
- }
- });
- it("SR000GGR47_testGetLastIndexOf024", 0, function () {
- let vector = new Vector();
- vector.add("四");
- vector.add("三");
- vector.add(1);
- vector.add("a");
- vector.add(1);
- vector.add("b");
- let res = vector.getLastIndexOf(1);
- expect(res).assertEqual(4);
- });
- it("SR000GGR47_testGetLastIndexFrom025", 0, function () {
- let vector = new Vector();
- vector.add("四");
- vector.add("三");
- vector.add(1);
- vector.add("a");
- vector.add(1);
- vector.add("b");
- vector.add("c");
- vector.add(1);
- let res = vector.getLastIndexFrom(1, 5);
- expect(res).assertEqual(4);
- });
- it("SR000GGR47_testGetIndexFrom026", 0, function () {
- let vector = new Vector();
- vector.add("四");
- vector.add("三");
- vector.add(1);
- vector.add("a");
- vector.add(1);
- vector.add("b");
- vector.add("c");
- vector.add(1);
- let res = vector.getIndexFrom(1, 5);
- expect(res).assertEqual(7);
- });
- it("SR000GGR47_testRemoveByRange027", 0, function () {
- let vector = new Vector();
- vector.add("四");
- vector.add("三");
- vector.add(1);
- vector.add("a");
- vector.add(1);
- vector.add("b");
- vector.add("c");
- vector.add(1);
- vector.removeByRange(1, 3);
- let arr = [];
- vector.forEach((item, index) => {
- arr.push(item);
- });
- let a = ["四", "a", 1, "b", "c", 1];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR47_testRemoveByRange028", 0, function () {
- let vector = new Vector();
- vector.add("四");
- vector.add("三");
- vector.add(1);
- vector.add("a");
- vector.add(1);
- vector.add("b");
- vector.add("c");
- vector.add(1);
- try {
- vector.removeByRange(3, 1);
- } catch (err) {
- expect(err).assertEqual("Error: fromIndex cannot be less than or equal to toIndex");
- }
- });
- it("SR000GGR47_testRemoveByRange029", 0, function () {
- let vector = new Vector();
- vector.add("四");
- vector.add("三");
- vector.add(1);
- let length = vector.length;
- try {
- vector.removeByRange(length + 1, 7);
- } catch (err) {
- expect(err).assertEqual("Error: Vector: set out-of-bounds");
- }
- });
- it("SR000GGR47_testRemoveByRange030", 0, function () {
- let vector = new Vector();
- vector.add("四");
- vector.add("三");
- vector.add(1);
- let length = vector.length;
- try {
- vector.removeByRange(1, 7);
- } catch (err) {
- expect(err).assertEqual("vector: deleteProperty out-of-bounds");
- }
- });
- it("SR000GGR47_testRemoveByRange031", 0, function () {
- let vector = new Vector();
- vector.add("四");
- vector.add("三");
- vector.add(1);
- vector.add("a");
- vector.add(1);
- vector.add("b");
- vector.add("c");
- vector.add(1);
- let capacity = vector.getCapacity();
- try {
- vector.removeByRange(0, capacity);
- } catch (err) {
- expect(err).assertEqual("Error: Vector: set out-of-bounds");
- }
- let arr = [];
- vector.forEach((item, index) => {
- arr.push(item);
- });
- expect(arr.length).assertEqual(1);
- });
- it("SR000GGR47_testRemoveByRange032", 0, function () {
- let vector = new Vector();
- vector.add("四");
- vector.add("三");
- vector.add(1);
- vector.add("a");
- vector.add(1);
- vector.add("b");
- vector.add("c");
- vector.add(1);
- let capacity = vector.getCapacity();
- try {
- vector.removeByRange(-1, capacity);
- } catch (err) {
- expect(err).assertEqual("Error: Vector: set out-of-bounds");
- }
- });
- it("SR000GGR47_testRemoveByRange033", 0, function () {
- let vector = new Vector();
- vector.add("四");
- vector.add("三");
- vector.add(1);
- vector.add("a");
- vector.add(1);
- vector.add("b");
- vector.add("c");
- vector.add(1);
- let capacity = vector.getCapacity();
- vector.removeByRange(0, capacity + 1);
- let length = vector.length;
- expect(length).assertEqual(1);
- });
- it("SR000GGR47_testSetLength034", 0, function () {
- let vector = new Vector();
- vector.add("四");
- vector.add("三");
- vector.add(1);
- vector.add("a");
- vector.add(1);
- vector.add("b");
- vector.add("c");
- vector.add(1);
- vector.setLength(5);
- let res1 = vector.length;
- expect(res1).assertEqual(5);
- });
- it("SR000GGR47_testReplaceAllElements035", 0, function () {
- let vector = new Vector();
- vector.add(4);
- vector.add(3);
- vector.add(1);
- vector.add(2);
- vector.add(14);
- vector.replaceAllElements((item, index) => {
- return (item = 2 * item);
- });
- let arr = [];
- vector.forEach((item, index) => {
- arr.push(item);
- });
- let a = [8, 6, 2, 4, 28];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR47_testForEach036", 0, function () {
- let vector = new Vector();
- vector.add(4);
- vector.add(3);
- vector.add(1);
- vector.add(2);
- vector.add(14);
- let arr = [];
- vector.forEach((item, index) => {
- arr.push(item);
- });
- let a = [4, 3, 1, 2, 14];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR47_testForEach037", 0, function () {
- let vector = new Vector();
- let arr = [];
- vector.forEach((item, index) => {
- arr.push(item);
- });
- let a = [4, 3, 1, 2, 14];
- expect(arr.length).assertEqual(0);
- });
- it("SR000GGR47_testConstructor038", 0, function () {
- let vector = new Vector();
- vector.add(4);
- vector.add(3);
- vector.add(1);
- vector.add(2);
- vector.add(14);
- let res = vector.subVector(2, 4);
- let arr = [];
- res.forEach((item, index) => {
- arr.push(item);
- });
- let a = [1, 2];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR47_testConstructor039", 0, function () {
- let vector = new Vector();
- vector.add(4);
- vector.add(3);
- vector.add(1);
- vector.add(2);
- vector.add(14);
- try {
- let res = vector.subVector(4, 2);
- } catch (err) {
- expect(err).assertEqual(
- "Error: fromIndex cannot be less than or equal to toIndex"
- );
- }
- });
- it("SR000GGR47_testConstructor040", 0, function () {
- let vector = new Vector();
- vector.add(4);
- vector.add(3);
- vector.add(1);
- vector.add(2);
- vector.add(14);
- let length = vector.length;
- try {
- let res = vector.subVector(length + 1, length + 3);
- } catch (err) {
- expect(err).assertEqual("Error: fromIndex or toIndex is out-of-bounds");
- }
- });
- it("SR000GGR47_testConstructor041", 0, function () {
- let vector = new Vector();
- vector.add(4);
- vector.add(3);
- vector.add(1);
- vector.add(2);
- vector.add(14);
- let length = vector.length;
- try {
- let res = vector.subVector(1, length + 1);
- } catch (err) {
- expect(err).assertEqual("Vector: get out-of-bounds");
- }
- });
- it("SR000GGR47_testClear042", 0, function () {
- let vector = new Vector();
- vector.add(4);
- vector.add(3);
- vector.add(1);
- vector.add(2);
- vector.add(14);
- vector.clear();
- let res = vector.length;
- expect(res).assertEqual(0);
- });
- it("SR000GGR47_testConvertToArray043", 0, function () {
- let vector = new Vector();
- vector.add(4);
- vector.add(3);
- vector.add(1);
- vector.add(2);
- vector.add(14);
- let arr = vector.convertToArray();
- let a = [4, 3, 1, 2, 14];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR47_testCopyToArray044", 0, function () {
- let vector = new Vector();
- vector.add(4);
- vector.add(3);
- vector.add(1);
- vector.add(2);
- vector.add(14);
- let arr1 = ["a", "b", "c"];
- let res = vector.copyToArray(arr1);
- let a = [4, 3, 1];
- for (let i = 0; i < a.length; i++) {
- expect(arr1[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR47_testToString045", 0, function () {
- let vector = new Vector();
- vector.add(4);
- vector.add(3);
- vector.add(1);
- vector.add(2);
- vector.add(14);
- let res = vector.toString();
- expect(res).assertEqual("4,3,1,2,14");
- });
- it("SR000GGR47_testClone046", 0, function () {
- let vector = new Vector();
- vector.add(4);
- vector.add(3);
- vector.add(1);
- vector.add(2);
- vector.add(14);
- let res = vector.clone();
- let arr = [];
- res.forEach((item, index) => {
- arr.push(item);
- });
- let a = [4, 3, 1, 2, 14];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR47_testGetCapacity047", 0, function () {
- let vector = new Vector();
- vector.add(4);
- vector.add(3);
- vector.add(1);
- vector.add(2);
- vector.add(14);
- let res = vector.getCapacity();
- expect(res).assertEqual(10);
- });
- it("SR000GGR47_testGetCapacity048", 0, function () {
- let vector = new Vector();
- vector.add(4);
- vector.add(3);
- vector.add(1);
- vector.add(2);
- vector.add(14);
- vector.add("a");
- vector.add("b");
- vector.add("c");
- vector.add("d");
- vector.add("v");
- let a = [1, 2, 3, 4];
- vector.add(a);
- let res = vector.getCapacity();
- expect(res).assertEqual(20);
- });
- it("SR000GGR47_testIncreaseCapacityTo049", 0, function () {
- let vector = new Vector();
- vector.add(4);
- vector.add(3);
- vector.add(1);
- vector.add(2);
- vector.add(14);
- vector.increaseCapacityTo(30);
- let res = vector.getCapacity();
- expect(res).assertEqual(30);
- });
- it("SR000GGR47_testTrimToCurrentLength050", 0, function () {
- let vector = new Vector();
- vector.add(4);
- vector.add(3);
- vector.add(1);
- vector.add(2);
- vector.add(14);
- vector.trimToCurrentLength();
- let res = vector.getCapacity();
- expect(res).assertEqual(5);
- });
- it("SR000GGR47_testSetLength051", 0, function () {
- let vector = new Vector();
- vector.add(4);
- vector.add(3);
- vector.add(1);
- vector.add(2);
- vector.add(14);
- vector.setLength(7);
- let res1 = vector.length;
- expect(res1).assertEqual(7);
- });
- it("SR000GGR47_testIterator052", 0, function () {
- let vector = new Vector();
- vector.add(8);
- vector.add("一");
- vector.add("二");
- vector.add(5);
- let c = [1, 2, 3, 4];
- vector.add(c);
- vector.add(6);
- vector.add("三");
- vector.add("四");
- let arr = [];
- for (let item of vector) {
- arr.push(item);
- }
- let a = [8, "一", "二", 5, c, 6, "三", "四"];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR47_testIteratorAndRemove053", 0, function () {
- let vector = new Vector();
- vector.add(8);
- vector.add("一");
- vector.add("二");
- vector.add(5);
- let c = [1, 2, 3, 4];
- vector.add(c);
- vector.add(6);
- vector.add(8);
- vector.add("三");
- vector.add("四");
- let arr = [];
- for (let item of vector) {
- if (item == 8) {
- vector.remove(8);
- }
- }
- for (let item of vector) {
- arr.push(item);
- }
- let a = ["一", "二", 5, c, 6, "三", "四"];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR47_testIteratorAndRemove054", 0, function () {
- let vector = new Vector();
- vector.add(8);
- vector.add("一");
- vector.add("二");
- vector.add(5);
- let c = [1, 2, 3, 4];
- vector.add(c);
- vector.add(6);
- vector.add("三");
- vector.add("四");
- let arr = [];
- for (let item of vector) {
- if (item == 123) {
- vector.remove(123);
- } else {
- arr.push(item);
- }
- }
- let a = [8, "一", "二", 5, c, 6, "三", "四"];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR47_testIterator055", 0, function () {
- let vector = new Vector();
- let arr = [];
- for (let item of vector) {
- arr.push(item);
- }
- expect(arr.length).assertEqual(0);
- });
- it("SR000GGR47_testSort056", 0, function () {
- let vector = new Vector();
- vector.add(4);
- vector.add(3);
- vector.add(1);
- vector.add(2);
- vector.add(14);
- vector.sort((a, b) => a - b);
- let arr = [];
- vector.forEach((item, index) => {
- arr.push(item);
- });
- let a = [1, 2, 3, 4, 14];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
- it("SR000GGR47_testisEmpty057", 0, function () {
- let vector = new Vector();
- vector.add("四");
- let res = vector.isEmpty();
- expect(res).assertEqual(false);
- });
- it("SR000GGR47_testisEmpty058", 0, function () {
- let vector = new Vector();
- let res = vector.isEmpty();
- expect(res).assertEqual(true);
- });
- it("SR000GGR47_testFor059", 0, function () {
- let vector = new Vector();
- vector.add("四");
- let length = vector.length;
- try {
- for (let i = 0; i < length; i++) {
- console.log(vector[i]);
- }
- } catch (err) {
- expect(err).assertEqual("Error: Cannot create new vector");
- }
- });
- it("SR000GGR47_testAdd060", 0, function () {
- let vector = new Vector();
- for (let i = 0; i < 100; i++) {
- let res3 = vector.add(i);
- }
- let res = vector.getLastElement();
- let res1 = vector.length;
- expect(res).assertEqual(99);
- expect(res1).assertEqual(100);
- });
- it("SR000GGR47_testAdd061 ", 0, function () {
- let vector = new Vector();
- vector.add("%");
- let res = vector.getFirstElement();
- expect(res).assertEqual("%");
- });
- it("SR000GGR47_testAdd062 ", 0, function () {
- let vector = new Vector();
- vector.add(1.89);
- let res = vector.getFirstElement();
- expect(res).assertEqual(1.89);
- });
- it("SR000GGR47_testAdd063 ", 0, function () {
- let vector = new Vector();
- vector.add("");
- let res = vector.getFirstElement();
- expect(res).assertEqual("");
- });
- it("SR000GGR47_testAdd064 ", 0, function () {
- let vector = new Vector();
- vector.add(true);
- let res = vector.getFirstElement();
- expect(res).assertEqual(true);
- });
- it("SR000GGR47_testGetIndexOf065", 0, function () {
- let vector = new Vector();
- vector.add(1);
- vector.add(2);
- vector.add(3);
- let res = vector.getIndexOf(23);
- expect(res).assertEqual(-1);
- });
- it("SR000GGR47_testSet066", 0, function () {
- let vector = new Vector();
- vector.add("四");
- vector.add("三");
- try {
- vector.set(12, "二");
- } catch (err) {
- expect(err).assertEqual("Error: Vector: set out-of-bounds");
- }
- });
- it("SR000GGR47_testRemoveByIndex067", 0, function () {
- let vector = new Vector();
- vector.add("四");
- vector.add("三");
- try {
- vector.removeByIndex(12);
- } catch (err) {
- expect(err).assertEqual("Error: Vector: get out-of-bounds");
- }
- });
- it("SR000GGR47_testGetLastIndexOf068", 0, function () {
- let vector = new Vector();
- vector.add("四");
- vector.add("三");
- let res = vector.getLastIndexOf("二");
- expect(res).assertEqual(-1);
- });
- it("SR000GGR47_testIterator069", 0, function () {
- let vector = new Vector();
- vector.add(8);
- vector.add("一");
- vector.add("二");
- vector.add(5);
- let c = [1, 2, 3, 4];
- vector.add(c);
- vector.add(6);
- vector.add("三");
- vector.add("四");
- let arr = [];
- let itr = vector[Symbol.iterator]();
- let tmp = undefined;
- do {
- tmp = itr.next().value;
- arr.push(tmp);
- } while (tmp != undefined);
- let a = [8, "一", "二", 5, c, 6, "三", "四"];
- for (let i = 0; i < a.length; i++) {
- expect(arr[i]).assertEqual(a[i]);
- }
- });
-});
+/*
+ * Copyright (C) 2021 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 'deccjsunit/index';
+import Vector from "@ohos.util.Vector";
+
+describe("VectorTest", function () {
+ it("SR000GGR47_testConstructor001", 0, function () {
+ try {
+ let vector = new Vector();
+ } catch (err) {
+ expect(err).assertEqual("Error: Cannot create new vector");
+ }
+ });
+ it("SR000GGR47_testAdd002", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ let res = vector.getFirstElement();
+ expect(res).assertEqual("四");
+ });
+ it("SR000GGR47_testAdd003 ", 0, function () {
+ let vector = new Vector();
+ vector.add(4);
+ let res = vector.getFirstElement();
+ expect(res).assertEqual(4);
+ });
+ it("SR000GGR47_testAdd004 ", 0, function () {
+ let vector = new Vector();
+ let a = {name: "lala", age: "13岁"};
+ vector.add(a);
+ let res = vector.getFirstElement();
+ expect(res).assertEqual(a);
+ });
+ it("SR000GGR47_testAdd005 ", 0, function () {
+ let vector = new Vector();
+ let a = [1, 2, 3, 4];
+ vector.add(a);
+ let res = vector.getFirstElement();
+ expect(res).assertEqual(a);
+ });
+ it("SR000GGR47_testInsert006", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ vector.add("三");
+ vector.add(1);
+ vector.add("a");
+ vector.insert(8, 2);
+ let res = vector.get(2);
+ expect(res).assertEqual(8);
+ });
+ it("SR000GGR47_testInsert007", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ vector.add("三");
+ vector.add(1);
+ vector.add("a");
+ try {
+ vector.insert(-1, 2);
+ } catch (err) {
+ expect(err).assertEqual("Vector: get out-of-bounds");
+ }
+ });
+ it("SR000GGR47_testInsert008", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ vector.add("三");
+ vector.add(1);
+ vector.add("a");
+ let capacity = vector.getCapacity();
+ try {
+ vector.insert(capacity, 2);
+ } catch (err) {
+ expect(err).assertEqual("Vector: get out-of-bounds");
+ }
+ });
+ it("SR000GGR47_testInsert009", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ vector.add("三");
+ vector.add(1);
+ vector.add("a");
+ let capacity = vector.getCapacity();
+ try {
+ vector.insert(capacity + 1, 2);
+ } catch (err) {
+ expect(err).assertEqual("Vector: get out-of-bounds");
+ }
+ });
+ it("SR000GGR47_testLength010", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ vector.add("三");
+ vector.add(1);
+ vector.add("a");
+ let res = vector.length;
+ expect(res).assertEqual(4);
+ });
+ it("SR000GGR47_testHas011", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ vector.add("三");
+ vector.add(1);
+ vector.add("a");
+ vector.insert(8, 2);
+ let res = vector.has(8);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR47_testHas012", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ vector.add("三");
+ vector.add(1);
+ vector.add("a");
+ vector.insert(8, 2);
+ let res1 = vector.has("二");
+ expect(res1).assertEqual(false);
+ });
+ it("SR000GGR47_testGet013", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ vector.add("三");
+ vector.add(1);
+ vector.add("a");
+ vector.insert(8, 2);
+ let res1 = vector.get(1);
+ expect(res1).assertEqual("三");
+ });
+ it("SR000GGR47_testGet014", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ vector.add("三");
+ vector.add(1);
+ vector.add("a");
+ vector.insert(8, 2);
+ try {
+ let res = vector.get(10);
+ } catch (err) {
+ expect(err).assertEqual("Error: Vector: get out-of-bounds");
+ }
+ });
+ it("SR000GGR47_testGetIndexOf015", 0, function () {
+ let vector = new Vector();
+ vector.add(1);
+ vector.add("三");
+ vector.add(1);
+ vector.add("a");
+ vector.insert(1, 2);
+ let res1 = vector.getIndexOf(1);
+ expect(res1).assertEqual(0);
+ });
+ it("SR000GGR47_testGetFirstElement016", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ vector.add("三");
+ vector.add(1);
+ vector.add("a");
+ vector.insert(8, 2);
+ try {
+ let res = vector.getFirstElement();
+ } catch (err) {
+ expect(err).assertEqual("Error: Vector: get out-of-bounds");
+ }
+ });
+ it("SR000GGR47_testGetFirstElement017", 0, function () {
+ let vector = new Vector();
+ try {
+ let res = vector.getFirstElement();
+ } catch (err) {
+ expect(err).assertEqual("Error: Vector: get out-of-bounds");
+ }
+ });
+ it("SR000GGR47_testSet018", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ vector.add("三");
+ vector.add(1);
+ vector.add("a");
+ vector.insert(8, 2);
+ vector.set(1, "二");
+ let res = vector.get(1);
+ expect(res).assertEqual("二");
+ });
+ it("SR000GGR47_testRemoveByIndex019", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ vector.add("三");
+ vector.add(1);
+ vector.add("a");
+ vector.removeByIndex(2);
+ let res = vector.has(1);
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR47_testRemove020", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ vector.add("三");
+ vector.add(1);
+ vector.add("a");
+ vector.remove("三");
+ let res = vector.has("三");
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR47_testRemove021", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ vector.add("三");
+ vector.add(1);
+ vector.add("a");
+ let res = vector.remove(2);
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR47_testGetLastElement022", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ vector.add("三");
+ vector.add(1);
+ vector.add("a");
+ let res1 = vector.length;
+ let res = vector.getLastElement();
+ expect(res).assertEqual("a");
+ });
+ it("SR000GGR47_testGetLastElement023", 0, function () {
+ let vector = new Vector();
+ let res1 = vector.length;
+ try {
+ let res = vector.getLastElement();
+ } catch (err) {
+ expect(err).assertEqual("Error: Vector: get out-of-bounds");
+ }
+ });
+ it("SR000GGR47_testGetLastIndexOf024", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ vector.add("三");
+ vector.add(1);
+ vector.add("a");
+ vector.add(1);
+ vector.add("b");
+ let res = vector.getLastIndexOf(1);
+ expect(res).assertEqual(4);
+ });
+ it("SR000GGR47_testGetLastIndexFrom025", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ vector.add("三");
+ vector.add(1);
+ vector.add("a");
+ vector.add(1);
+ vector.add("b");
+ vector.add("c");
+ vector.add(1);
+ let res = vector.getLastIndexFrom(1, 5);
+ expect(res).assertEqual(4);
+ });
+ it("SR000GGR47_testGetIndexFrom026", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ vector.add("三");
+ vector.add(1);
+ vector.add("a");
+ vector.add(1);
+ vector.add("b");
+ vector.add("c");
+ vector.add(1);
+ let res = vector.getIndexFrom(1, 5);
+ expect(res).assertEqual(7);
+ });
+ it("SR000GGR47_testRemoveByRange027", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ vector.add("三");
+ vector.add(1);
+ vector.add("a");
+ vector.add(1);
+ vector.add("b");
+ vector.add("c");
+ vector.add(1);
+ vector.removeByRange(1, 3);
+ let arr = [];
+ vector.forEach((item, index) => {
+ arr.push(item);
+ });
+ let a = ["四", "a", 1, "b", "c", 1];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR47_testRemoveByRange028", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ vector.add("三");
+ vector.add(1);
+ vector.add("a");
+ vector.add(1);
+ vector.add("b");
+ vector.add("c");
+ vector.add(1);
+ try {
+ vector.removeByRange(3, 1);
+ } catch (err) {
+ expect(err).assertEqual("Error: fromIndex cannot be less than or equal to toIndex");
+ }
+ });
+ it("SR000GGR47_testRemoveByRange029", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ vector.add("三");
+ vector.add(1);
+ let length = vector.length;
+ try {
+ vector.removeByRange(length + 1, 7);
+ } catch (err) {
+ expect(err).assertEqual("Error: Vector: set out-of-bounds");
+ }
+ });
+ it("SR000GGR47_testRemoveByRange030", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ vector.add("三");
+ vector.add(1);
+ let length = vector.length;
+ try {
+ vector.removeByRange(1, 7);
+ } catch (err) {
+ expect(err).assertEqual("vector: deleteProperty out-of-bounds");
+ }
+ });
+ it("SR000GGR47_testRemoveByRange031", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ vector.add("三");
+ vector.add(1);
+ vector.add("a");
+ vector.add(1);
+ vector.add("b");
+ vector.add("c");
+ vector.add(1);
+ let capacity = vector.getCapacity();
+ try {
+ vector.removeByRange(0, capacity);
+ } catch (err) {
+ expect(err).assertEqual("Error: Vector: set out-of-bounds");
+ }
+ let arr = [];
+ vector.forEach((item, index) => {
+ arr.push(item);
+ });
+ expect(arr.length).assertEqual(1);
+ });
+ it("SR000GGR47_testRemoveByRange032", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ vector.add("三");
+ vector.add(1);
+ vector.add("a");
+ vector.add(1);
+ vector.add("b");
+ vector.add("c");
+ vector.add(1);
+ let capacity = vector.getCapacity();
+ try {
+ vector.removeByRange(-1, capacity);
+ } catch (err) {
+ expect(err).assertEqual("Error: Vector: set out-of-bounds");
+ }
+ });
+ it("SR000GGR47_testRemoveByRange033", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ vector.add("三");
+ vector.add(1);
+ vector.add("a");
+ vector.add(1);
+ vector.add("b");
+ vector.add("c");
+ vector.add(1);
+ let capacity = vector.getCapacity();
+ vector.removeByRange(0, capacity + 1);
+ let length = vector.length;
+ expect(length).assertEqual(1);
+ });
+ it("SR000GGR47_testSetLength034", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ vector.add("三");
+ vector.add(1);
+ vector.add("a");
+ vector.add(1);
+ vector.add("b");
+ vector.add("c");
+ vector.add(1);
+ vector.setLength(5);
+ let res1 = vector.length;
+ expect(res1).assertEqual(5);
+ });
+ it("SR000GGR47_testReplaceAllElements035", 0, function () {
+ let vector = new Vector();
+ vector.add(4);
+ vector.add(3);
+ vector.add(1);
+ vector.add(2);
+ vector.add(14);
+ vector.replaceAllElements((item, index) => {
+ return (item = 2 * item);
+ });
+ let arr = [];
+ vector.forEach((item, index) => {
+ arr.push(item);
+ });
+ let a = [8, 6, 2, 4, 28];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR47_testForEach036", 0, function () {
+ let vector = new Vector();
+ vector.add(4);
+ vector.add(3);
+ vector.add(1);
+ vector.add(2);
+ vector.add(14);
+ let arr = [];
+ vector.forEach((item, index) => {
+ arr.push(item);
+ });
+ let a = [4, 3, 1, 2, 14];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR47_testForEach037", 0, function () {
+ let vector = new Vector();
+ let arr = [];
+ vector.forEach((item, index) => {
+ arr.push(item);
+ });
+ let a = [4, 3, 1, 2, 14];
+ expect(arr.length).assertEqual(0);
+ });
+ it("SR000GGR47_testConstructor038", 0, function () {
+ let vector = new Vector();
+ vector.add(4);
+ vector.add(3);
+ vector.add(1);
+ vector.add(2);
+ vector.add(14);
+ let res = vector.subVector(2, 4);
+ let arr = [];
+ res.forEach((item, index) => {
+ arr.push(item);
+ });
+ let a = [1, 2];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR47_testConstructor039", 0, function () {
+ let vector = new Vector();
+ vector.add(4);
+ vector.add(3);
+ vector.add(1);
+ vector.add(2);
+ vector.add(14);
+ try {
+ let res = vector.subVector(4, 2);
+ } catch (err) {
+ expect(err).assertEqual(
+ "Error: fromIndex cannot be less than or equal to toIndex"
+ );
+ }
+ });
+ it("SR000GGR47_testConstructor040", 0, function () {
+ let vector = new Vector();
+ vector.add(4);
+ vector.add(3);
+ vector.add(1);
+ vector.add(2);
+ vector.add(14);
+ let length = vector.length;
+ try {
+ let res = vector.subVector(length + 1, length + 3);
+ } catch (err) {
+ expect(err).assertEqual("Error: fromIndex or toIndex is out-of-bounds");
+ }
+ });
+ it("SR000GGR47_testConstructor041", 0, function () {
+ let vector = new Vector();
+ vector.add(4);
+ vector.add(3);
+ vector.add(1);
+ vector.add(2);
+ vector.add(14);
+ let length = vector.length;
+ try {
+ let res = vector.subVector(1, length + 1);
+ } catch (err) {
+ expect(err).assertEqual("Vector: get out-of-bounds");
+ }
+ });
+ it("SR000GGR47_testClear042", 0, function () {
+ let vector = new Vector();
+ vector.add(4);
+ vector.add(3);
+ vector.add(1);
+ vector.add(2);
+ vector.add(14);
+ vector.clear();
+ let res = vector.length;
+ expect(res).assertEqual(0);
+ });
+ it("SR000GGR47_testConvertToArray043", 0, function () {
+ let vector = new Vector();
+ vector.add(4);
+ vector.add(3);
+ vector.add(1);
+ vector.add(2);
+ vector.add(14);
+ let arr = vector.convertToArray();
+ let a = [4, 3, 1, 2, 14];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR47_testCopyToArray044", 0, function () {
+ let vector = new Vector();
+ vector.add(4);
+ vector.add(3);
+ vector.add(1);
+ vector.add(2);
+ vector.add(14);
+ let arr1 = ["a", "b", "c"];
+ let res = vector.copyToArray(arr1);
+ let a = [4, 3, 1];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr1[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR47_testToString045", 0, function () {
+ let vector = new Vector();
+ vector.add(4);
+ vector.add(3);
+ vector.add(1);
+ vector.add(2);
+ vector.add(14);
+ let res = vector.toString();
+ expect(res).assertEqual("4,3,1,2,14");
+ });
+ it("SR000GGR47_testClone046", 0, function () {
+ let vector = new Vector();
+ vector.add(4);
+ vector.add(3);
+ vector.add(1);
+ vector.add(2);
+ vector.add(14);
+ let res = vector.clone();
+ let arr = [];
+ res.forEach((item, index) => {
+ arr.push(item);
+ });
+ let a = [4, 3, 1, 2, 14];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR47_testGetCapacity047", 0, function () {
+ let vector = new Vector();
+ vector.add(4);
+ vector.add(3);
+ vector.add(1);
+ vector.add(2);
+ vector.add(14);
+ let res = vector.getCapacity();
+ expect(res).assertEqual(10);
+ });
+ it("SR000GGR47_testGetCapacity048", 0, function () {
+ let vector = new Vector();
+ vector.add(4);
+ vector.add(3);
+ vector.add(1);
+ vector.add(2);
+ vector.add(14);
+ vector.add("a");
+ vector.add("b");
+ vector.add("c");
+ vector.add("d");
+ vector.add("v");
+ let a = [1, 2, 3, 4];
+ vector.add(a);
+ let res = vector.getCapacity();
+ expect(res).assertEqual(20);
+ });
+ it("SR000GGR47_testIncreaseCapacityTo049", 0, function () {
+ let vector = new Vector();
+ vector.add(4);
+ vector.add(3);
+ vector.add(1);
+ vector.add(2);
+ vector.add(14);
+ vector.increaseCapacityTo(30);
+ let res = vector.getCapacity();
+ expect(res).assertEqual(30);
+ });
+ it("SR000GGR47_testTrimToCurrentLength050", 0, function () {
+ let vector = new Vector();
+ vector.add(4);
+ vector.add(3);
+ vector.add(1);
+ vector.add(2);
+ vector.add(14);
+ vector.trimToCurrentLength();
+ let res = vector.getCapacity();
+ expect(res).assertEqual(5);
+ });
+ it("SR000GGR47_testSetLength051", 0, function () {
+ let vector = new Vector();
+ vector.add(4);
+ vector.add(3);
+ vector.add(1);
+ vector.add(2);
+ vector.add(14);
+ vector.setLength(7);
+ let res1 = vector.length;
+ expect(res1).assertEqual(7);
+ });
+ it("SR000GGR47_testIterator052", 0, function () {
+ let vector = new Vector();
+ vector.add(8);
+ vector.add("一");
+ vector.add("二");
+ vector.add(5);
+ let c = [1, 2, 3, 4];
+ vector.add(c);
+ vector.add(6);
+ vector.add("三");
+ vector.add("四");
+ let arr = [];
+ for (let item of vector) {
+ arr.push(item);
+ }
+ let a = [8, "一", "二", 5, c, 6, "三", "四"];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR47_testIteratorAndRemove053", 0, function () {
+ let vector = new Vector();
+ vector.add(8);
+ vector.add("一");
+ vector.add("二");
+ vector.add(5);
+ let c = [1, 2, 3, 4];
+ vector.add(c);
+ vector.add(6);
+ vector.add(8);
+ vector.add("三");
+ vector.add("四");
+ let arr = [];
+ for (let item of vector) {
+ if (item == 8) {
+ vector.remove(8);
+ }
+ }
+ for (let item of vector) {
+ arr.push(item);
+ }
+ let a = ["一", "二", 5, c, 6, "三", "四"];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR47_testIteratorAndRemove054", 0, function () {
+ let vector = new Vector();
+ vector.add(8);
+ vector.add("一");
+ vector.add("二");
+ vector.add(5);
+ let c = [1, 2, 3, 4];
+ vector.add(c);
+ vector.add(6);
+ vector.add("三");
+ vector.add("四");
+ let arr = [];
+ for (let item of vector) {
+ if (item == 123) {
+ vector.remove(123);
+ } else {
+ arr.push(item);
+ }
+ }
+ let a = [8, "一", "二", 5, c, 6, "三", "四"];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR47_testIterator055", 0, function () {
+ let vector = new Vector();
+ let arr = [];
+ for (let item of vector) {
+ arr.push(item);
+ }
+ expect(arr.length).assertEqual(0);
+ });
+ it("SR000GGR47_testSort056", 0, function () {
+ let vector = new Vector();
+ vector.add(4);
+ vector.add(3);
+ vector.add(1);
+ vector.add(2);
+ vector.add(14);
+ vector.sort((a, b) => a - b);
+ let arr = [];
+ vector.forEach((item, index) => {
+ arr.push(item);
+ });
+ let a = [1, 2, 3, 4, 14];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+ it("SR000GGR47_testisEmpty057", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ let res = vector.isEmpty();
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR47_testisEmpty058", 0, function () {
+ let vector = new Vector();
+ let res = vector.isEmpty();
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR47_testFor059", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ let length = vector.length;
+ try {
+ for (let i = 0; i < length; i++) {
+ console.log(vector[i]);
+ }
+ } catch (err) {
+ expect(err).assertEqual("Error: Cannot create new vector");
+ }
+ });
+ it("SR000GGR47_testAdd060", 0, function () {
+ let vector = new Vector();
+ for (let i = 0; i < 100; i++) {
+ let res3 = vector.add(i);
+ }
+ let res = vector.getLastElement();
+ let res1 = vector.length;
+ expect(res).assertEqual(99);
+ expect(res1).assertEqual(100);
+ });
+ it("SR000GGR47_testAdd061 ", 0, function () {
+ let vector = new Vector();
+ vector.add("%");
+ let res = vector.getFirstElement();
+ expect(res).assertEqual("%");
+ });
+ it("SR000GGR47_testAdd062 ", 0, function () {
+ let vector = new Vector();
+ vector.add(1.89);
+ let res = vector.getFirstElement();
+ expect(res).assertEqual(1.89);
+ });
+ it("SR000GGR47_testAdd063 ", 0, function () {
+ let vector = new Vector();
+ vector.add("");
+ let res = vector.getFirstElement();
+ expect(res).assertEqual("");
+ });
+ it("SR000GGR47_testAdd064 ", 0, function () {
+ let vector = new Vector();
+ vector.add(true);
+ let res = vector.getFirstElement();
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR47_testGetIndexOf065", 0, function () {
+ let vector = new Vector();
+ vector.add(1);
+ vector.add(2);
+ vector.add(3);
+ let res = vector.getIndexOf(23);
+ expect(res).assertEqual(-1);
+ });
+ it("SR000GGR47_testSet066", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ vector.add("三");
+ try {
+ vector.set(12, "二");
+ } catch (err) {
+ expect(err).assertEqual("Error: Vector: set out-of-bounds");
+ }
+ });
+ it("SR000GGR47_testRemoveByIndex067", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ vector.add("三");
+ try {
+ vector.removeByIndex(12);
+ } catch (err) {
+ expect(err).assertEqual("Error: Vector: get out-of-bounds");
+ }
+ });
+ it("SR000GGR47_testGetLastIndexOf068", 0, function () {
+ let vector = new Vector();
+ vector.add("四");
+ vector.add("三");
+ let res = vector.getLastIndexOf("二");
+ expect(res).assertEqual(-1);
+ });
+ it("SR000GGR47_testIterator069", 0, function () {
+ let vector = new Vector();
+ vector.add(8);
+ vector.add("一");
+ vector.add("二");
+ vector.add(5);
+ let c = [1, 2, 3, 4];
+ vector.add(c);
+ vector.add(6);
+ vector.add("三");
+ vector.add("四");
+ let arr = [];
+ let itr = vector[Symbol.iterator]();
+ let tmp = undefined;
+ do {
+ tmp = itr.next().value;
+ arr.push(tmp);
+ } while (tmp != undefined);
+ let a = [8, "一", "二", 5, c, 6, "三", "四"];
+ for (let i = 0; i < a.length; i++) {
+ expect(arr[i]).assertEqual(a[i]);
+ }
+ });
+});
diff --git a/compileruntime/containerLine_lib_standard/src/main/resources/base/element/string.json b/compileruntime/containerLine_lib_standard/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..0bae6bd40f7360d5d818998221b199d3ec0f69c0
--- /dev/null
+++ b/compileruntime/containerLine_lib_standard/src/main/resources/base/element/string.json
@@ -0,0 +1,12 @@
+{
+ "string": [
+ {
+ "name": "entry_MainAbility",
+ "value": "entry_MainAbility"
+ },
+ {
+ "name": "mainability_description",
+ "value": "JS_Empty Ability"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/compileruntime/containerLine_lib_standard/src/main/resources/base/media/icon.png b/compileruntime/containerLine_lib_standard/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/compileruntime/containerLine_lib_standard/src/main/resources/base/media/icon.png differ
diff --git a/compileruntime/containerRelation_lib_standard/BUILD.gn b/compileruntime/containerRelation_lib_standard/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..10bdffaa96a02b4fa69c17665524b03f773654a3
--- /dev/null
+++ b/compileruntime/containerRelation_lib_standard/BUILD.gn
@@ -0,0 +1,39 @@
+# Copyright (C) 2021 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("containerRelation_js_test") {
+ hap_profile = "./src/main/config.json"
+ js2abc = true
+ deps = [
+ ":containerRelation_js_assets",
+ ":containerRelation_resources",
+ ]
+
+ # shared_libraries = [
+ # "//third_party/giflib:libgif",
+ # "//third_party/libpng:libpng",
+ # ]
+ certificate_profile = "./signature/openharmony_sx.p7b"
+ hap_name = "ActsContainerRelationJsTest"
+
+ # part_name = "prebuilt_hap"
+ # subsystem_name = "xts"
+}
+ohos_js_assets("containerRelation_js_assets") {
+ source_dir = "./src/main/js/default"
+}
+ohos_resources("containerRelation_resources") {
+ sources = [ "./src/main/resources" ]
+ hap_profile = "./src/main/config.json"
+}
diff --git a/compileruntime/containerRelation_lib_standard/Test.json b/compileruntime/containerRelation_lib_standard/Test.json
new file mode 100644
index 0000000000000000000000000000000000000000..263941425c7561af91fa98ddc1f41cc97492a472
--- /dev/null
+++ b/compileruntime/containerRelation_lib_standard/Test.json
@@ -0,0 +1,18 @@
+{
+ "description": "Configuration for startup util js api Tests",
+ "driver": {
+ "type": "JSUnitTest",
+ "test-timeout": "300000",
+ "package": "com.example.containerRelation",
+ "shell-timeout": "60000"
+ },
+ "kits": [
+ {
+ "test-file-name": [
+ "ActsContainerRelationJsTest.hap"
+ ],
+ "type": "AppInstallKit",
+ "cleanup-apps": true
+ }
+ ]
+}
\ No newline at end of file
diff --git a/compileruntime/containerRelation_lib_standard/signature/openharmony_sx.p7b b/compileruntime/containerRelation_lib_standard/signature/openharmony_sx.p7b
new file mode 100644
index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5
Binary files /dev/null and b/compileruntime/containerRelation_lib_standard/signature/openharmony_sx.p7b differ
diff --git a/compileruntime/containerRelation_lib_standard/src/main/config.json b/compileruntime/containerRelation_lib_standard/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..d971ffd4c50440b517a3aeffa501d3955b600f5c
--- /dev/null
+++ b/compileruntime/containerRelation_lib_standard/src/main/config.json
@@ -0,0 +1,62 @@
+{
+ "app": {
+ "bundleName": "com.example.containerRelation",
+ "vendor": "example",
+ "version": {
+ "code": 1000000,
+ "name": "1.0.0"
+ },
+ "apiVersion": {
+ "compatible": 4,
+ "target": 5
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.example.containerRelation",
+ "name": ".MyApplication",
+ "mainAbility": "com.example.containerRelation.MainAbility",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry",
+ "moduleType": "entry",
+ "installationFree": false
+ },
+ "abilities": [
+ {
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ],
+ "visible": true,
+ "name": "com.example.containerRelation.MainAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:entry_MainAbility",
+ "type": "page",
+ "launchType": "standard"
+ }
+ ],
+ "js": [
+ {
+ "pages": [
+ "pages/index/index"
+ ],
+ "name": "default",
+ "window": {
+ "designWidth": 720,
+ "autoDesignWidth": true
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/compileruntime/containerRelation_lib_standard/src/main/js/default/app.js b/compileruntime/containerRelation_lib_standard/src/main/js/default/app.js
new file mode 100644
index 0000000000000000000000000000000000000000..ef92b6e96e9db7d997b0be7c2068d560b1cab26d
--- /dev/null
+++ b/compileruntime/containerRelation_lib_standard/src/main/js/default/app.js
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+export default {
+ onCreate() {
+ console.info('AceApplication onCreate');
+ },
+ onDestroy() {
+ console.info('AceApplication onDestroy');
+ }
+};
diff --git a/compileruntime/containerRelation_lib_standard/src/main/js/default/i18n/en-US.json b/compileruntime/containerRelation_lib_standard/src/main/js/default/i18n/en-US.json
new file mode 100644
index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c
--- /dev/null
+++ b/compileruntime/containerRelation_lib_standard/src/main/js/default/i18n/en-US.json
@@ -0,0 +1,6 @@
+{
+ "strings": {
+ "hello": "Hello",
+ "world": "World"
+ }
+}
\ No newline at end of file
diff --git a/compileruntime/containerRelation_lib_standard/src/main/js/default/i18n/zh-CN.json b/compileruntime/containerRelation_lib_standard/src/main/js/default/i18n/zh-CN.json
new file mode 100644
index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f
--- /dev/null
+++ b/compileruntime/containerRelation_lib_standard/src/main/js/default/i18n/zh-CN.json
@@ -0,0 +1,6 @@
+{
+ "strings": {
+ "hello": "您好",
+ "world": "世界"
+ }
+}
\ No newline at end of file
diff --git a/compileruntime/containerRelation_lib_standard/src/main/js/default/pages/index/index.css b/compileruntime/containerRelation_lib_standard/src/main/js/default/pages/index/index.css
new file mode 100644
index 0000000000000000000000000000000000000000..2b1965821483f4f8c8b97c86ef07fe87ea767d01
--- /dev/null
+++ b/compileruntime/containerRelation_lib_standard/src/main/js/default/pages/index/index.css
@@ -0,0 +1,44 @@
+.container {
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+}
+
+.title {
+ font-size: 40px;
+ color: #000000;
+ opacity: 0.9;
+}
+
+@media screen and (device-type: tablet) and (orientation: landscape) {
+ .title {
+ font-size: 100px;
+ }
+}
+
+@media screen and (device-type: wearable) {
+ .title {
+ font-size: 28px;
+ color: #FFFFFF;
+ }
+}
+
+@media screen and (device-type: tv) {
+ .container {
+ background-image: url("../../common/images/Wallpaper.png");
+ background-size: cover;
+ background-repeat: no-repeat;
+ background-position: center;
+ }
+
+ .title {
+ font-size: 100px;
+ color: #FFFFFF;
+ }
+}
+
+@media screen and (device-type: phone) and (orientation: landscape) {
+ .title {
+ font-size: 60px;
+ }
+}
diff --git a/compileruntime/containerRelation_lib_standard/src/main/js/default/pages/index/index.hml b/compileruntime/containerRelation_lib_standard/src/main/js/default/pages/index/index.hml
new file mode 100644
index 0000000000000000000000000000000000000000..20a4e40d9a4ee698bf8e485840457dd43233a376
--- /dev/null
+++ b/compileruntime/containerRelation_lib_standard/src/main/js/default/pages/index/index.hml
@@ -0,0 +1,5 @@
+
+
+ {{ $t('strings.hello') }} {{title}}
+
+
\ No newline at end of file
diff --git a/compileruntime/containerRelation_lib_standard/src/main/js/default/pages/index/index.js b/compileruntime/containerRelation_lib_standard/src/main/js/default/pages/index/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..300a1758a515674d193b32a393c1b1da897614d8
--- /dev/null
+++ b/compileruntime/containerRelation_lib_standard/src/main/js/default/pages/index/index.js
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2021 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 file from '@system.file'
+import app from '@system.app'
+import device from '@system.device'
+import router from '@system.router'
+import {Core} from 'deccjsunit/index'
+
+export default {
+ data: {
+ title: ""
+ },
+ onInit() {
+ this.title = this.$t('strings.world');
+ },
+ onShow() {
+ console.info('onShow finish')
+ const core = Core.getInstance()
+ core.init()
+ require('../../../test/Main.test')
+ core.execute()
+ },
+ onReady() {
+ },
+}
\ No newline at end of file
diff --git a/compileruntime/containerRelation_lib_standard/src/main/js/test/ExampleJsunit.test.js b/compileruntime/containerRelation_lib_standard/src/main/js/test/ExampleJsunit.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..a46419640e38427a40d27eec75ddc8eb183a89d4
--- /dev/null
+++ b/compileruntime/containerRelation_lib_standard/src/main/js/test/ExampleJsunit.test.js
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2021 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 app from '@system.app'
+import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
+
+describe('appInfoTest', function () {
+ it('app_info_test_001', 0, function () {
+ var info = app.getInfo()
+ expect(info.versionCode).assertEqual('1000000')
+ })
+})
\ No newline at end of file
diff --git a/compileruntime/util_lib_standard/src/main/js/test/HashMap.test.js b/compileruntime/containerRelation_lib_standard/src/main/js/test/HashMap.test.js
similarity index 96%
rename from compileruntime/util_lib_standard/src/main/js/test/HashMap.test.js
rename to compileruntime/containerRelation_lib_standard/src/main/js/test/HashMap.test.js
index 5658da1c294dc0ddc80c8816ac150375e70ace1d..f1e3d72753befa6c83a47307ac7046d57911fd00 100644
--- a/compileruntime/util_lib_standard/src/main/js/test/HashMap.test.js
+++ b/compileruntime/containerRelation_lib_standard/src/main/js/test/HashMap.test.js
@@ -1,479 +1,479 @@
-/*
- * Copyright (C) 2021 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 'deccjsunit/index';
-import HashMap from "@ohos.util.HashMap";
-
-describe("HashMapTest", function () {
- it("SR000GGR4B_testConstructor001", 0, function () {
- try {
- let hashMap = new HashMap();
- expect(hashMap != undefined).assertEqual(true);
- } catch (err) {
- expect(err).assertEqual("Error: Cannot create new HashMap");
- }
- });
- it("SR000GGR4B_testSet002_1", 0, function () {
- let hashMap = new HashMap();
- hashMap.set(1, "A");
- let res = hashMap.get(1);
- expect(res).assertEqual("A");
- });
- it("SR000GGR4B_testSet002_2", 0, function () {
- let hashMap = new HashMap();
- hashMap.set(1, 2);
- let res = hashMap.get(1);
- expect(res).assertEqual(2);
- });
- it("SR000GGR4B_testSet002_3", 0, function () {
- let hashMap = new HashMap();
- let c = [1, 2, 3];
- hashMap.set(1, c);
- let res = hashMap.get(1);
- expect(res).assertEqual(c);
- });
- it("SR000GGR4B_testSet002_4", 0, function () {
- let hashMap = new HashMap();
- let c = {name: "lili", age: "13"};
- hashMap.set(1, c);
- let res = hashMap.get(1);
- expect(res).assertEqual(c);
- });
- it("SR000GGR4B_testSet002_5", 0, function () {
- let hashMap = new HashMap();
- hashMap.set("a", "A");
- let res = hashMap.get("a");
- expect(res).assertEqual("A");
- });
- it("SR000GGR4B_testSet002_6", 0, function () {
- let hashMap = new HashMap();
- hashMap.set("", "A");
- let res = hashMap.get("");
- expect(res).assertEqual("A");
- });
- it("SR000GGR4B_testSet002_7", 0, function () {
- let hashMap = new HashMap();
- hashMap.set("$", "A");
- let res = hashMap.get("$");
- expect(res).assertEqual("A");
- });
- it("SR000GGR4B_testSet002_8", 0, function () {
- let hashMap = new HashMap();
- hashMap.set(3.14, "A");
- let res = hashMap.get(3.14);
- expect(res).assertEqual("A");
- });
- it("SR000GGR4B_testSet002_9", 0, function () {
- let hashMap = new HashMap();
- hashMap.set(0.3, "A");
- let res = hashMap.get(0.3);
- expect(res).assertEqual("A");
- });
- it("SR000GGR4B_testSet002_10", 0, function () {
- let hashMap = new HashMap();
- hashMap.set(-1, "A");
- let res = hashMap.get(-1);
- expect(res).assertEqual("A");
- });
- it("SR000GGR4B_testSet002_11", 0, function () {
- let hashMap = new HashMap();
- let a = {};
- hashMap.set(a, "A");
- let res = hashMap.get(a);
- expect(res).assertEqual("A");
- });
- it("SR000GGR4B_testSet002_12", 0, function () {
- let hashMap = new HashMap();
- hashMap.set(1, null);
- let res = hashMap.get(1);
- expect(res).assertEqual(null);
- });
- it("SR000GGR4B_testSet002_13", 0, function () {
- let hashMap = new HashMap();
- hashMap.set(1, "$");
- let res = hashMap.get(1);
- expect(res).assertEqual("$");
- });
- it("SR000GGR4B_testSet002_14", 0, function () {
- let hashMap = new HashMap();
- hashMap.set(1, 3.14);
- let res = hashMap.get(1);
- expect(res).assertEqual(3.14);
- });
- it("SR000GGR4B_testSet002_15", 0, function () {
- let hashMap = new HashMap();
- hashMap.set(1, -1);
- let res = hashMap.get(1);
- expect(res).assertEqual(-1);
- });
- it("SR000GGR4B_testSet002_16", 0, function () {
- let hashMap = new HashMap();
- let a = {};
- hashMap.set(1, a);
- let res = hashMap.get(1);
- expect(res).assertEqual(a);
- });
- it("SR000GGR4B_testSet002_17", 0, function () {
- let hashMap = new HashMap();
- for (let i = 0; i < 100; i++) {
- hashMap.set(1, i);
- }
- let res = hashMap.get(1);
- let res1 = hashMap.length;
- expect(res).assertEqual(99);
- expect(res1).assertEqual(1);
- });
- it("SR000GGR4B_testSet002_18", 0, function () {
- let hashMap = new HashMap();
- for (let i = 0; i < 100; i++) {
- hashMap.set(i, 1);
- let res = hashMap.get(i);
- expect(res).assertEqual(1);
- }
- let res1 = hashMap.length;
- expect(res1).assertEqual(100);
- });
- it("SR000GGR4B_testLength003", 0, function () {
- let hashMap = new HashMap();
- hashMap.set(1, "A");
- hashMap.set(2, "B");
- hashMap.set(3, "C");
- hashMap.set(4, "D");
- hashMap.set(5, "E");
- let res = hashMap.length;
- expect(res).assertEqual(5);
- });
- it("SR000GGR4B_testHasKey004_1", 0, function () {
- let hashMap = new HashMap();
- hashMap.set(1, "A");
- hashMap.set(2, "B");
- hashMap.set(3, "C");
- hashMap.set(4, "D");
- hashMap.set(5, "E");
- let res = hashMap.hasKey(3);
- expect(res).assertEqual(true);
- let res1 = hashMap.hasKey(8);
- expect(res1).assertEqual(false);
- });
- it("SR000GGR4B_testHasKey004_2", 0, function () {
- let hashMap = new HashMap();
- let res = hashMap.hasKey(8);
- expect(res).assertEqual(false);
- });
- it("SR000GGR4B_testHasValue005_1", 0, function () {
- let hashMap = new HashMap();
- hashMap.set(1, "A");
- hashMap.set(2, "B");
- hashMap.set(3, "C");
- hashMap.set(4, "D");
- hashMap.set(5, "E");
- let res = hashMap.hasValue("C");
- expect(res).assertEqual(true);
- let res1 = hashMap.hasValue(8);
- expect(res1).assertEqual(false);
- });
- it("SR000GGR4B_testHasValue005_2", 0, function () {
- let hashMap = new HashMap();
- let res = hashMap.hasValue(8);
- expect(res).assertEqual(false);
- });
- it("SR000GGR4B_testGet006_1", 0, function () {
- let hashMap = new HashMap();
- hashMap.set(1, "A");
- hashMap.set(2, "B");
- hashMap.set(3, "C");
- hashMap.set(4, "D");
- hashMap.set(5, "E");
- let res = hashMap.get(3);
- expect(res).assertEqual("C");
- });
- it("SR000GGR4B_testGet006_2", 0, function () {
- let hashMap = new HashMap();
- try {
- let res = hashMap.get(3);
- } catch (err) {
- expect(err).assertEqual(
- "Error: The removed element does not exist in this container"
- );
- }
- });
- it("SR000GGR4B_testSetAll007_1", 0, function () {
- let hashMap = new HashMap();
- hashMap.set(1, "A");
- hashMap.set(2, "B");
- hashMap.set(3, "C");
- hashMap.set(4, "D");
- hashMap.set(5, "E");
- let hashMap1 = new HashMap();
- hashMap1.set(1, 1);
- hashMap1.set(2, 2);
- hashMap.setAll(hashMap1);
- let arr = [];
- for (let [key, value] of hashMap) {
- arr.push([key, value]);
- }
- arr.sort(function (a, b) {
- return a[0] - b[0];
- });
-
- for (let i = 0; i < arr.length; i++) {
- expect(arr[i][0]).assertEqual(i + 1);
- expect(arr[i][1]).assertEqual(hashMap.get(i + 1));
- }
- });
- it("SR000GGR4B_testSetAll007_2", 0, function () {
- let hashMap = new HashMap();
- let hashMap1 = new HashMap();
- hashMap1.set(1, 1);
- hashMap1.set(2, 2);
- hashMap.setAll(hashMap1);
- let arr = [];
- for (let [key, value] of hashMap) {
- arr.push([key, value]);
- }
- arr.sort(function (a, b) {
- return a[0] - b[0];
- });
- for (let i = 0; i < arr.length; i++) {
- expect(JSON.stringify(arr[i])).assertEqual(
- JSON.stringify([i + 1, hashMap.get(i + 1)])
- );
- }
- });
- it("SR000GGR4B_testRemove008_1", 0, function () {
- let hashMap = new HashMap();
- hashMap.set(1, "A");
- hashMap.set(2, "B");
- hashMap.set(3, "C");
- hashMap.set(4, "D");
- hashMap.set(5, "E");
- let res = hashMap.remove(3);
- expect(res).assertEqual("C");
- let res1 = hashMap.length;
- expect(res1).assertEqual(4);
- });
- it("SR000GGR4B_testRemove008_2", 0, function () {
- let hashMap = new HashMap();
- try {
- let res = hashMap.remove(3);
- } catch (err) {
- expect(err).assertEqual(
- "Error: The removed element does not exist in this container"
- );
- }
- });
- it("SR000GGR4B_testClear009", 0, function () {
- let hashMap = new HashMap();
- hashMap.set(1, "A");
- hashMap.set(2, "B");
- hashMap.set(3, "C");
- hashMap.set(4, "D");
- hashMap.set(5, "E");
- let res = hashMap.length;
- expect(res).assertEqual(5);
- hashMap.clear();
- let res1 = hashMap.length;
- expect(res1).assertEqual(0);
- });
- it("SR000GGR4B_testClear010", 0, function () {
- let hashMap = new HashMap();
- hashMap.clear();
- let res = hashMap.length;
- expect(res).assertEqual(0);
- });
- it("SR000GGR4B_testKeys010", 0, function () {
- let hashMap = new HashMap();
- hashMap.set(1, "A");
- hashMap.set(2, "B");
- hashMap.set(3, "C");
- hashMap.set(4, "D");
- hashMap.set(5, "E");
- let res = hashMap.keys();
- for (let i = 0; i < hashMap.length; i++) {
- console.log(res.next());
- }
- });
- it("SR000GGR4B_testValues011", 0, function () {
- let hashMap = new HashMap();
- hashMap.set(1, "A");
- hashMap.set(2, "B");
- hashMap.set(3, "C");
- hashMap.set(4, "D");
- hashMap.set(5, "E");
- let res = hashMap.values();
- for (let i = 0; i < hashMap.length; i++) {
- let has = hashMap.hasValue(res.next().value);
- expect(has).assertEqual(true);
- }
- });
- it("SR000GGR4B_testReplace012_1", 0, function () {
- let hashMap = new HashMap();
- hashMap.set(1, "A");
- hashMap.set(2, "B");
- hashMap.set(3, "C");
- hashMap.set(4, "D");
- hashMap.set(5, "E");
- let res = hashMap.replace(2, "G");
- expect(res).assertEqual(true);
- expect(hashMap.get(2)).assertEqual("G");
- });
- it("SR000GGR4B_testReplace012_2", 0, function () {
- let hashMap = new HashMap();
- let res = hashMap.replace(2, "G");
- expect(res).assertEqual(false);
- });
- it("SR000GGR4B_testForEach013_1", 0, function () {
- let hashMap = new HashMap();
- hashMap.set(1, "A");
- hashMap.set(2, "B");
- hashMap.set(3, "C");
- hashMap.set(4, "D");
- hashMap.set(5, "E");
- let vals = [];
- let keys = [];
- hashMap.forEach((value, key) => {
- keys.push(key);
- vals.push(value);
- });
- for (let i = 0; i < keys.length; i++) {
- let has = hashMap.hasKey(keys[i]);
- expect(has).assertEqual(true);
- }
- for (let i = 0; i < vals.length; i++) {
- let has = hashMap.hasValue(vals[i]);
- expect(has).assertEqual(true);
- }
- });
- it("SR000GGR4B_testForEach013_2", 0, function () {
- let hashMap = new HashMap();
- let arr = [];
- try {
- hashMap.forEach((item, index) => {
- arr.push(item);
- });
- } catch (err) {
- expect(err).assertEqual("Error:Cannot create new hashMap");
- }
- expect(arr.length).assertEqual(0);
- });
- it("SR000GGR4B_testIterator014_1", 0, function () {
- let hashMap = new HashMap();
- hashMap.set(1, "A");
- hashMap.set(2, "B");
- hashMap.set(3, "C");
- hashMap.set(4, "D");
- hashMap.set(5, "E");
- let arr = [];
- for (let [key, value] of hashMap) {
- arr.push([key, value]);
- }
- arr.sort(function (a, b) {
- return a[0] - b[0];
- });
- for (let i = 0; i < arr.length; i++) {
- expect(arr[i][0]).assertEqual(i + 1);
- expect(arr[i][1]).assertEqual(hashMap.get(i + 1));
- }
- });
- it("SR000GGR4B_testIterator014_2", 0, function () {
- let hashMap = new HashMap();
- let arr = [];
- try {
- for (let item of hashMap) {
- arr.push(item);
- }
- } catch (err) {
- expect(err).assertEqual("Error: Cannot create new HashMap");
- }
- expect(arr.length).assertEqual(0);
- });
- it("SR000GGR4B_testEntries015_1", 0, function () {
- let hashMap = new HashMap();
- hashMap.set(1, "A");
- hashMap.set(2, "B");
- hashMap.set(3, "C");
- hashMap.set(4, "D");
- hashMap.set(5, "E");
- let res = hashMap.entries();
- let arr = [];
- for (let i = 0; i < hashMap.length; i++) {
- let obj = res.next();
- arr.push([obj.value[0], obj.value[1]]);
- }
- arr.sort(function (a, b) {
- return a[0] - b[0];
- });
- for (let i = 0; i < arr.length; i++) {
- expect(arr[i][0]).assertEqual(i + 1);
- expect(arr[i][1]).assertEqual(hashMap.get(i + 1));
- }
- });
- it("SR000GGR4B_testEntries015_2", 0, function () {
- let hashMap = new HashMap();
- let res = hashMap.entries();
- expect(undefined).assertEqual(res.next().value);
- });
- it("SR000GGR4B_testIsEmpty016_1", 0, function () {
- let hashMap = new HashMap();
- hashMap.set(1, "A");
- hashMap.set(2, "B");
- hashMap.set(3, "C");
- hashMap.set(4, "D");
- hashMap.set(5, "E");
- let res = hashMap.length;
- let res1 = hashMap.isEmpty();
- expect(res).assertEqual(5);
- expect(res1).assertEqual(false);
- });
- it("SR000GGR4B_testIsEmpty016_2", 0, function () {
- let hashMap = new HashMap();
- hashMap.set(1, "A");
- hashMap.set(2, "B");
- hashMap.set(3, "C");
- hashMap.set(4, "D");
- hashMap.set(5, "E");
- hashMap.clear();
- let res = hashMap.length;
- let res1 = hashMap.isEmpty();
- expect(res).assertEqual(0);
- expect(res1).assertEqual(true);
- });
- it("SR000GGR4B_testEntries043", 0, function () {
- let hashMap = new HashMap();
- let res = hashMap.entries();
- expect(undefined).assertEqual(res.next().value);
- });
- it("SR000GGR4B_testIterator044", 0, function () {
- let hashMap = new HashMap();
- hashMap.set(1, "A");
- hashMap.set(2, "B");
- hashMap.set(3, "C");
- hashMap.set(4, "D");
- hashMap.set(5, "E");
- let arr = [];
- let res = hashMap[Symbol.iterator]();
- let temp = undefined;
- do {
- temp = res.next().value;
- arr.push(temp);
- } while (temp != undefined);
- arr.sort(function (a, b) {
- return a[0] - b[0];
- });
- let arr1 = ["1,A", "2,B", "3,C", "4,D", "5,E"];
- for (let i = 0; i < arr.length; i++) {
- expect(arr[i]).assertEqual(arr1[i]);
- }
- });
-});
+/*
+ * Copyright (C) 2021 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 'deccjsunit/index';
+import HashMap from "@ohos.util.HashMap";
+
+describe("HashMapTest", function () {
+ it("SR000GGR4B_testConstructor001", 0, function () {
+ try {
+ let hashMap = new HashMap();
+ expect(hashMap != undefined).assertEqual(true);
+ } catch (err) {
+ expect(err).assertEqual("Error: Cannot create new HashMap");
+ }
+ });
+ it("SR000GGR4B_testSet002_1", 0, function () {
+ let hashMap = new HashMap();
+ hashMap.set(1, "A");
+ let res = hashMap.get(1);
+ expect(res).assertEqual("A");
+ });
+ it("SR000GGR4B_testSet002_2", 0, function () {
+ let hashMap = new HashMap();
+ hashMap.set(1, 2);
+ let res = hashMap.get(1);
+ expect(res).assertEqual(2);
+ });
+ it("SR000GGR4B_testSet002_3", 0, function () {
+ let hashMap = new HashMap();
+ let c = [1, 2, 3];
+ hashMap.set(1, c);
+ let res = hashMap.get(1);
+ expect(res).assertEqual(c);
+ });
+ it("SR000GGR4B_testSet002_4", 0, function () {
+ let hashMap = new HashMap();
+ let c = {name: "lili", age: "13"};
+ hashMap.set(1, c);
+ let res = hashMap.get(1);
+ expect(res).assertEqual(c);
+ });
+ it("SR000GGR4B_testSet002_5", 0, function () {
+ let hashMap = new HashMap();
+ hashMap.set("a", "A");
+ let res = hashMap.get("a");
+ expect(res).assertEqual("A");
+ });
+ it("SR000GGR4B_testSet002_6", 0, function () {
+ let hashMap = new HashMap();
+ hashMap.set("", "A");
+ let res = hashMap.get("");
+ expect(res).assertEqual("A");
+ });
+ it("SR000GGR4B_testSet002_7", 0, function () {
+ let hashMap = new HashMap();
+ hashMap.set("$", "A");
+ let res = hashMap.get("$");
+ expect(res).assertEqual("A");
+ });
+ it("SR000GGR4B_testSet002_8", 0, function () {
+ let hashMap = new HashMap();
+ hashMap.set(3.14, "A");
+ let res = hashMap.get(3.14);
+ expect(res).assertEqual("A");
+ });
+ it("SR000GGR4B_testSet002_9", 0, function () {
+ let hashMap = new HashMap();
+ hashMap.set(0.3, "A");
+ let res = hashMap.get(0.3);
+ expect(res).assertEqual("A");
+ });
+ it("SR000GGR4B_testSet002_10", 0, function () {
+ let hashMap = new HashMap();
+ hashMap.set(-1, "A");
+ let res = hashMap.get(-1);
+ expect(res).assertEqual("A");
+ });
+ it("SR000GGR4B_testSet002_11", 0, function () {
+ let hashMap = new HashMap();
+ let a = {};
+ hashMap.set(a, "A");
+ let res = hashMap.get(a);
+ expect(res).assertEqual("A");
+ });
+ it("SR000GGR4B_testSet002_12", 0, function () {
+ let hashMap = new HashMap();
+ hashMap.set(1, undefined);
+ let res = hashMap.get(1);
+ expect(res).assertEqual(undefined);
+ });
+ it("SR000GGR4B_testSet002_13", 0, function () {
+ let hashMap = new HashMap();
+ hashMap.set(1, "$");
+ let res = hashMap.get(1);
+ expect(res).assertEqual("$");
+ });
+ it("SR000GGR4B_testSet002_14", 0, function () {
+ let hashMap = new HashMap();
+ hashMap.set(1, 3.14);
+ let res = hashMap.get(1);
+ expect(res).assertEqual(3.14);
+ });
+ it("SR000GGR4B_testSet002_15", 0, function () {
+ let hashMap = new HashMap();
+ hashMap.set(1, -1);
+ let res = hashMap.get(1);
+ expect(res).assertEqual(-1);
+ });
+ it("SR000GGR4B_testSet002_16", 0, function () {
+ let hashMap = new HashMap();
+ let a = {};
+ hashMap.set(1, a);
+ let res = hashMap.get(1);
+ expect(res).assertEqual(a);
+ });
+ it("SR000GGR4B_testSet002_17", 0, function () {
+ let hashMap = new HashMap();
+ for (let i = 0; i < 100; i++) {
+ hashMap.set(1, i);
+ }
+ let res = hashMap.get(1);
+ let res1 = hashMap.length;
+ expect(res).assertEqual(99);
+ expect(res1).assertEqual(1);
+ });
+ it("SR000GGR4B_testSet002_18", 0, function () {
+ let hashMap = new HashMap();
+ for (let i = 0; i < 100; i++) {
+ hashMap.set(i, 1);
+ let res = hashMap.get(i);
+ expect(res).assertEqual(1);
+ }
+ let res1 = hashMap.length;
+ expect(res1).assertEqual(100);
+ });
+ it("SR000GGR4B_testLength003", 0, function () {
+ let hashMap = new HashMap();
+ hashMap.set(1, "A");
+ hashMap.set(2, "B");
+ hashMap.set(3, "C");
+ hashMap.set(4, "D");
+ hashMap.set(5, "E");
+ let res = hashMap.length;
+ expect(res).assertEqual(5);
+ });
+ it("SR000GGR4B_testHasKey004_1", 0, function () {
+ let hashMap = new HashMap();
+ hashMap.set(1, "A");
+ hashMap.set(2, "B");
+ hashMap.set(3, "C");
+ hashMap.set(4, "D");
+ hashMap.set(5, "E");
+ let res = hashMap.hasKey(3);
+ expect(res).assertEqual(true);
+ let res1 = hashMap.hasKey(8);
+ expect(res1).assertEqual(false);
+ });
+ it("SR000GGR4B_testHasKey004_2", 0, function () {
+ let hashMap = new HashMap();
+ let res = hashMap.hasKey(8);
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR4B_testHasValue005_1", 0, function () {
+ let hashMap = new HashMap();
+ hashMap.set(1, "A");
+ hashMap.set(2, "B");
+ hashMap.set(3, "C");
+ hashMap.set(4, "D");
+ hashMap.set(5, "E");
+ let res = hashMap.hasValue("C");
+ expect(res).assertEqual(true);
+ let res1 = hashMap.hasValue(8);
+ expect(res1).assertEqual(false);
+ });
+ it("SR000GGR4B_testHasValue005_2", 0, function () {
+ let hashMap = new HashMap();
+ let res = hashMap.hasValue(8);
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR4B_testGet006_1", 0, function () {
+ let hashMap = new HashMap();
+ hashMap.set(1, "A");
+ hashMap.set(2, "B");
+ hashMap.set(3, "C");
+ hashMap.set(4, "D");
+ hashMap.set(5, "E");
+ let res = hashMap.get(3);
+ expect(res).assertEqual("C");
+ });
+ it("SR000GGR4B_testGet006_2", 0, function () {
+ let hashMap = new HashMap();
+ try {
+ let res = hashMap.get(3);
+ } catch (err) {
+ expect(err).assertEqual(
+ "Error: The removed element does not exist in this container"
+ );
+ }
+ });
+ it("SR000GGR4B_testSetAll007_1", 0, function () {
+ let hashMap = new HashMap();
+ hashMap.set(1, "A");
+ hashMap.set(2, "B");
+ hashMap.set(3, "C");
+ hashMap.set(4, "D");
+ hashMap.set(5, "E");
+ let hashMap1 = new HashMap();
+ hashMap1.set(1, 1);
+ hashMap1.set(2, 2);
+ hashMap.setAll(hashMap1);
+ let arr = [];
+ for (let [key, value] of hashMap) {
+ arr.push([key, value]);
+ }
+ arr.sort(function (a, b) {
+ return a[0] - b[0];
+ });
+
+ for (let i = 0; i < arr.length; i++) {
+ expect(arr[i][0]).assertEqual(i + 1);
+ expect(arr[i][1]).assertEqual(hashMap.get(i + 1));
+ }
+ });
+ it("SR000GGR4B_testSetAll007_2", 0, function () {
+ let hashMap = new HashMap();
+ let hashMap1 = new HashMap();
+ hashMap1.set(1, 1);
+ hashMap1.set(2, 2);
+ hashMap.setAll(hashMap1);
+ let arr = [];
+ for (let [key, value] of hashMap) {
+ arr.push([key, value]);
+ }
+ arr.sort(function (a, b) {
+ return a[0] - b[0];
+ });
+ for (let i = 0; i < arr.length; i++) {
+ expect(JSON.stringify(arr[i])).assertEqual(
+ JSON.stringify([i + 1, hashMap.get(i + 1)])
+ );
+ }
+ });
+ it("SR000GGR4B_testRemove008_1", 0, function () {
+ let hashMap = new HashMap();
+ hashMap.set(1, "A");
+ hashMap.set(2, "B");
+ hashMap.set(3, "C");
+ hashMap.set(4, "D");
+ hashMap.set(5, "E");
+ let res = hashMap.remove(3);
+ expect(res).assertEqual("C");
+ let res1 = hashMap.length;
+ expect(res1).assertEqual(4);
+ });
+ it("SR000GGR4B_testRemove008_2", 0, function () {
+ let hashMap = new HashMap();
+ try {
+ let res = hashMap.remove(3);
+ } catch (err) {
+ expect(err).assertEqual(
+ "Error: The removed element does not exist in this container"
+ );
+ }
+ });
+ it("SR000GGR4B_testClear009", 0, function () {
+ let hashMap = new HashMap();
+ hashMap.set(1, "A");
+ hashMap.set(2, "B");
+ hashMap.set(3, "C");
+ hashMap.set(4, "D");
+ hashMap.set(5, "E");
+ let res = hashMap.length;
+ expect(res).assertEqual(5);
+ hashMap.clear();
+ let res1 = hashMap.length;
+ expect(res1).assertEqual(0);
+ });
+ it("SR000GGR4B_testClear010", 0, function () {
+ let hashMap = new HashMap();
+ hashMap.clear();
+ let res = hashMap.length;
+ expect(res).assertEqual(0);
+ });
+ it("SR000GGR4B_testKeys010", 0, function () {
+ let hashMap = new HashMap();
+ hashMap.set(1, "A");
+ hashMap.set(2, "B");
+ hashMap.set(3, "C");
+ hashMap.set(4, "D");
+ hashMap.set(5, "E");
+ let res = hashMap.keys();
+ for (let i = 0; i < hashMap.length; i++) {
+ console.log(res.next());
+ }
+ });
+ it("SR000GGR4B_testValues011", 0, function () {
+ let hashMap = new HashMap();
+ hashMap.set(1, "A");
+ hashMap.set(2, "B");
+ hashMap.set(3, "C");
+ hashMap.set(4, "D");
+ hashMap.set(5, "E");
+ let res = hashMap.values();
+ for (let i = 0; i < hashMap.length; i++) {
+ let has = hashMap.hasValue(res.next().value);
+ expect(has).assertEqual(true);
+ }
+ });
+ it("SR000GGR4B_testReplace012_1", 0, function () {
+ let hashMap = new HashMap();
+ hashMap.set(1, "A");
+ hashMap.set(2, "B");
+ hashMap.set(3, "C");
+ hashMap.set(4, "D");
+ hashMap.set(5, "E");
+ let res = hashMap.replace(2, "G");
+ expect(res).assertEqual(true);
+ expect(hashMap.get(2)).assertEqual("G");
+ });
+ it("SR000GGR4B_testReplace012_2", 0, function () {
+ let hashMap = new HashMap();
+ let res = hashMap.replace(2, "G");
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR4B_testForEach013_1", 0, function () {
+ let hashMap = new HashMap();
+ hashMap.set(1, "A");
+ hashMap.set(2, "B");
+ hashMap.set(3, "C");
+ hashMap.set(4, "D");
+ hashMap.set(5, "E");
+ let vals = [];
+ let keys = [];
+ hashMap.forEach((value, key) => {
+ keys.push(key);
+ vals.push(value);
+ });
+ for (let i = 0; i < keys.length; i++) {
+ let has = hashMap.hasKey(keys[i]);
+ expect(has).assertEqual(true);
+ }
+ for (let i = 0; i < vals.length; i++) {
+ let has = hashMap.hasValue(vals[i]);
+ expect(has).assertEqual(true);
+ }
+ });
+ it("SR000GGR4B_testForEach013_2", 0, function () {
+ let hashMap = new HashMap();
+ let arr = [];
+ try {
+ hashMap.forEach((item, index) => {
+ arr.push(item);
+ });
+ } catch (err) {
+ expect(err).assertEqual("Error:Cannot create new hashMap");
+ }
+ expect(arr.length).assertEqual(0);
+ });
+ it("SR000GGR4B_testIterator014_1", 0, function () {
+ let hashMap = new HashMap();
+ hashMap.set(1, "A");
+ hashMap.set(2, "B");
+ hashMap.set(3, "C");
+ hashMap.set(4, "D");
+ hashMap.set(5, "E");
+ let arr = [];
+ for (let [key, value] of hashMap) {
+ arr.push([key, value]);
+ }
+ arr.sort(function (a, b) {
+ return a[0] - b[0];
+ });
+ for (let i = 0; i < arr.length; i++) {
+ expect(arr[i][0]).assertEqual(i + 1);
+ expect(arr[i][1]).assertEqual(hashMap.get(i + 1));
+ }
+ });
+ it("SR000GGR4B_testIterator014_2", 0, function () {
+ let hashMap = new HashMap();
+ let arr = [];
+ try {
+ for (let item of hashMap) {
+ arr.push(item);
+ }
+ } catch (err) {
+ expect(err).assertEqual("Error: Cannot create new HashMap");
+ }
+ expect(arr.length).assertEqual(0);
+ });
+ it("SR000GGR4B_testEntries015_1", 0, function () {
+ let hashMap = new HashMap();
+ hashMap.set(1, "A");
+ hashMap.set(2, "B");
+ hashMap.set(3, "C");
+ hashMap.set(4, "D");
+ hashMap.set(5, "E");
+ let res = hashMap.entries();
+ let arr = [];
+ for (let i = 0; i < hashMap.length; i++) {
+ let obj = res.next();
+ arr.push([obj.value[0], obj.value[1]]);
+ }
+ arr.sort(function (a, b) {
+ return a[0] - b[0];
+ });
+ for (let i = 0; i < arr.length; i++) {
+ expect(arr[i][0]).assertEqual(i + 1);
+ expect(arr[i][1]).assertEqual(hashMap.get(i + 1));
+ }
+ });
+ it("SR000GGR4B_testEntries015_2", 0, function () {
+ let hashMap = new HashMap();
+ let res = hashMap.entries();
+ expect(undefined).assertEqual(res.next().value);
+ });
+ it("SR000GGR4B_testIsEmpty016_1", 0, function () {
+ let hashMap = new HashMap();
+ hashMap.set(1, "A");
+ hashMap.set(2, "B");
+ hashMap.set(3, "C");
+ hashMap.set(4, "D");
+ hashMap.set(5, "E");
+ let res = hashMap.length;
+ let res1 = hashMap.isEmpty();
+ expect(res).assertEqual(5);
+ expect(res1).assertEqual(false);
+ });
+ it("SR000GGR4B_testIsEmpty016_2", 0, function () {
+ let hashMap = new HashMap();
+ hashMap.set(1, "A");
+ hashMap.set(2, "B");
+ hashMap.set(3, "C");
+ hashMap.set(4, "D");
+ hashMap.set(5, "E");
+ hashMap.clear();
+ let res = hashMap.length;
+ let res1 = hashMap.isEmpty();
+ expect(res).assertEqual(0);
+ expect(res1).assertEqual(true);
+ });
+ it("SR000GGR4B_testEntries043", 0, function () {
+ let hashMap = new HashMap();
+ let res = hashMap.entries();
+ expect(undefined).assertEqual(res.next().value);
+ });
+ it("SR000GGR4B_testIterator044", 0, function () {
+ let hashMap = new HashMap();
+ hashMap.set(1, "A");
+ hashMap.set(2, "B");
+ hashMap.set(3, "C");
+ hashMap.set(4, "D");
+ hashMap.set(5, "E");
+ let arr = [];
+ let res = hashMap[Symbol.iterator]();
+ let temp = undefined;
+ do {
+ temp = res.next().value;
+ arr.push(temp);
+ } while (temp != undefined);
+ arr.sort(function (a, b) {
+ return a[0] - b[0];
+ });
+ let arr1 = ["1,A", "2,B", "3,C", "4,D", "5,E"];
+ for (let i = 0; i < arr.length; i++) {
+ expect(arr[i]).assertEqual(arr1[i]);
+ }
+ });
+});
diff --git a/compileruntime/util_lib_standard/src/main/js/test/HashSet.test.js b/compileruntime/containerRelation_lib_standard/src/main/js/test/HashSet.test.js
similarity index 96%
rename from compileruntime/util_lib_standard/src/main/js/test/HashSet.test.js
rename to compileruntime/containerRelation_lib_standard/src/main/js/test/HashSet.test.js
index 7c3d2a131371f84cce7c49ee9cd4fecaeb95e5d5..bd91b7c7b034f3c52f40dc7a375d0a6aa47f8088 100644
--- a/compileruntime/util_lib_standard/src/main/js/test/HashSet.test.js
+++ b/compileruntime/containerRelation_lib_standard/src/main/js/test/HashSet.test.js
@@ -1,342 +1,342 @@
-/*
- * Copyright (C) 2021 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 'deccjsunit/index';
-import HashSet from "@ohos.util.HashSet";
-
-describe("HashSetTest", function () {
- it("SR000GGR3J_testNew001", 0, function () {
- try {
- let hashSet = new HashSet();
- } catch (err) {
- expect(err).assertEqual("Error: Cannot create new HashSet");
- }
- });
- it("SR000GGR3J_testAdd001", 0, function () {
- let hashSet = new HashSet();
- hashSet.add(1);
- let res = hashSet.has(1);
- expect(res).assertEqual(true);
- });
- it("SR000GGR3J_testAdd002", 0, function () {
- let hashSet = new HashSet();
- hashSet.add("b");
- hashSet.add("c");
- hashSet.add("d");
- hashSet.add("a");
- hashSet.add("g");
- let res = hashSet.has("a");
- expect(res).assertEqual(true);
- });
- it("SR000GGR3J_testAdd004", 0, function () {
- let hashSet = new HashSet();
- let c = [1, 2, 3];
- hashSet.add(c);
- let res = hashSet.has(c);
- expect(res).assertEqual(true);
- });
- it("SR000GGR3J_testAdd005", 0, function () {
- let hashSet = new HashSet();
- let c = {name: "lili", age: "13"};
- hashSet.add(c);
- let res = hashSet.has(c);
- expect(res).assertEqual(true);
- });
- it("SR000GGR3J_testLength006", 0, function () {
- let hashSet = new HashSet();
- hashSet.add(1);
- hashSet.add(2);
- hashSet.add(3);
- hashSet.add(4);
- hashSet.add(5);
- let res = hashSet.length;
- expect(res).assertEqual(5);
- });
- it("SR000GGR3J_testHas007", 0, function () {
- let hashSet = new HashSet();
- hashSet.add(4);
- hashSet.add(1);
- hashSet.add(3);
- hashSet.add(2);
- hashSet.add(5);
- let res = hashSet.has(1);
- expect(res).assertEqual(true);
- let res1 = hashSet.has("A");
- expect(res1).assertEqual(false);
- });
- it("SR000GGR3J_testIsEmpty008", 0, function () {
- let hashSet = new HashSet();
- hashSet.add(4);
- hashSet.add(1);
- hashSet.add(3);
- hashSet.add(2);
- hashSet.add(5);
- let res = hashSet.isEmpty();
- expect(res).assertEqual(false);
- });
- it("SR000GGR3J_testRemove009", 0, function () {
- let hashSet = new HashSet();
- hashSet.add(4);
- hashSet.add(1);
- hashSet.add(3);
- hashSet.add(2);
- hashSet.add(5);
- let res = hashSet.remove(1);
- expect(res).assertEqual(true);
- let arr = [];
- hashSet.forEach((value, index) => {
- arr.push(value);
- });
- for (let i = 0; i < arr.length; i++) {
- let has = hashSet.has(arr[i]);
- expect(has).assertEqual(true);
- }
- });
- it("SR000GGR3J_testClear010", 0, function () {
- let hashSet = new HashSet();
- hashSet.add(4);
- hashSet.add(1);
- hashSet.add(3);
- hashSet.add(2);
- hashSet.add(5);
- let res = hashSet.length;
- expect(res).assertEqual(5);
- hashSet.clear();
- let res1 = hashSet.length;
- expect(res1).assertEqual(0);
- });
- it("SR000GGR3J_testValues011", 0, function () {
- let hashSet = new HashSet();
- hashSet.add("A");
- hashSet.add("B");
- hashSet.add("C");
- hashSet.add("D");
- hashSet.add("E");
- let res = hashSet.values();
- for (let i = 0; i < hashSet.length; i++) {
- let has = hashSet.has(res.next().value);
- expect(has).assertEqual(true);
- }
- });
- it("SR000GGR3J_testForEach012", 0, function () {
- let hashSet = new HashSet();
- hashSet.add(1);
- hashSet.add(2);
- hashSet.add(3);
- hashSet.add(4);
- hashSet.add(5);
- let arr = [];
- hashSet.forEach((value, index) => {
- arr.push(value);
- });
- for (let i = 0; i < arr.length; i++) {
- let has = hashSet.has(arr[i]);
- expect(has).assertEqual(true);
- }
- });
- it("SR000GGR3J_testIterator013", 0, function () {
- let hashSet = new HashSet();
- hashSet.add(1);
- hashSet.add(2);
- hashSet.add(3);
- hashSet.add(4);
- hashSet.add(5);
- let arr = [];
- for (let item of hashSet) {
- arr.push(item);
- }
- for (let i = 0; i < arr.length; i++) {
- let has = hashSet.has(arr[i]);
- expect(has).assertEqual(true);
- }
- });
- it("SR000GGR3J_testIterator014", 0, function () {
- let hashSet = new HashSet();
- hashSet.add("A");
- hashSet.add("B");
- hashSet.add("C");
- hashSet.add("D");
- hashSet.add("E");
- let arr = [];
- for (let item of hashSet) {
- arr.push(item);
- }
- for (let i = 0; i < arr.length; i++) {
- let has = hashSet.has(arr[i]);
- expect(has).assertEqual(true);
- }
- });
- it("SR000GGR3J_testEntries015", 0, function () {
- let hashSet = new HashSet();
- hashSet.add(1);
- hashSet.add(2);
- hashSet.add(3);
- hashSet.add(4);
- hashSet.add(5);
- let res = hashSet.entries();
- for (let i = 0; i < hashSet.length; i++) {
- let has = hashSet.has(res.next().value[1]);
- expect(has).assertEqual(true);
- }
- });
- it("SR000GGR3J_testAdd016", 0, function () {
- let hashSet = new HashSet();
- hashSet.add("");
- let res = hashSet.has("");
- expect(res).assertEqual(true);
- });
- it("SR000GGR3J_testAdd017", 0, function () {
- let hashSet = new HashSet();
- hashSet.add("$");
- let res = hashSet.has("$");
- expect(res).assertEqual(true);
- });
- it("SR000GGR3J_testAdd017", 0, function () {
- let hashSet = new HashSet();
- hashSet.add(1.34);
- let res = hashSet.has(1.34);
- expect(res).assertEqual(true);
- });
- it("SR000GGR3J_testAdd018", 0, function () {
- let hashSet = new HashSet();
- hashSet.add(-1);
- let res = hashSet.has(-1);
- expect(res).assertEqual(true);
- });
- it("SR000GGR3J_testAdd019", 0, function () {
- let hashSet = new HashSet();
- let a = {};
- hashSet.add(a);
- let res = hashSet.has(a);
- expect(res).assertEqual(true);
- });
- it("SR000GGR3J_testAdd020", 0, function () {
- let hashSet = new HashSet();
- for (let i = 0; i < 100; i++) {
- hashSet.add(i);
- let res = hashSet.has(i);
- expect(res).assertEqual(true);
- }
- let res1 = hashSet.length;
- expect(res1).assertEqual(100);
- });
- it("SR000GGR3J_testIterator021", 0, function () {
- let hashSet = new HashSet();
- let i = 0;
- for (let item of hashSet) {
- expect(item).assertEqual(i);
- i++;
- }
- });
- it("SR000GGR3J_testForEach022", 0, function () {
- let hashSet = new HashSet();
- let arr = [];
- hashSet.forEach((value, index) => {
- arr.push(value);
- });
- expect(arr.length).assertEqual(0);
- });
- it("SR000GGR3J_testIsEmpty023", 0, function () {
- let hashSet = new HashSet();
- hashSet.add(4);
- hashSet.add(1);
- hashSet.add(3);
- hashSet.add(2);
- hashSet.add(5);
- hashSet.clear();
- let res = hashSet.isEmpty();
- expect(res).assertEqual(true);
- });
- it("SR000GGR3J_testHas024", 0, function () {
- let hashSet = new HashSet();
- let res = hashSet.has(1);
- expect(res).assertEqual(false);
- });
- it("SR000GGR3J_testRemove025", 0, function () {
- let hashSet = new HashSet();
- let res = hashSet.remove(1);
- expect(res).assertEqual(false);
- });
- it("SR000GGR3J_testClear026", 0, function () {
- let hashSet = new HashSet();
- let res = hashSet.clear();
- expect(res).assertEqual(undefined);
- });
- it("SR000GGR3J_testEntries027", 0, function () {
- let hashSet = new HashSet();
- let res = hashSet.entries();
- expect(res.next().value).assertEqual(undefined);
- });
- it("SR000GGR3J_testIterator028", 0, function () {
- let hashSet = new HashSet();
- for (let i = 0; i < 100; i++) {
- let text = hashSet.add(i);
- }
- let arr = [];
- for (let item of hashSet) {
- arr.push(Number.parseInt(item));
- }
- for (let i = 0; i < 100; i++) {
- let a = arr[i];
- let res = hashSet.has(a);
- expect(res).assertEqual(true);
- }
- });
- it("SR000GGR3J_testForEach029", 0, function () {
- let hashSet = new HashSet();
- for (let i = 0; i < 100; i++) {
- hashSet.add(i);
- }
- let arr = [];
- hashSet.forEach((value, index) => {
- arr.push(value);
- });
- for (let i = 0; i < 100; i++) {
- let a = arr[i];
- let res = hashSet.has(a);
- expect(res).assertEqual(true);
- }
- });
- it("SR000GGR3J_testAdd030", 0, function () {
- let hashSet = new HashSet();
- hashSet.add(1);
- hashSet.add(1);
- let has = hashSet.has(1);
- let size = hashSet.length;
- expect(has).assertEqual(true);
- expect(size).assertEqual(1);
- });
- it("SR000GGR3J_testIterator031", 0, function () {
- let hashSet = new HashSet();
- hashSet.add(1);
- hashSet.add(2);
- hashSet.add(3);
- hashSet.add(4);
- hashSet.add(5);
- let res = hashSet[Symbol.iterator]();
- let temp = undefined;
- let arr = [];
- do {
- temp = res.next().value;
- arr.push(temp);
- } while (temp != undefined);
- arr.sort(function (a, b) {
- return a - b;
- });
- let arr1 = [1, 2, 3, 4, 5];
- for (let i = 0; i < arr.length; i++) {
- expect(arr[i]).assertEqual(arr1[i]);
- }
- });
-});
+/*
+ * Copyright (C) 2021 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 'deccjsunit/index';
+import HashSet from "@ohos.util.HashSet";
+
+describe("HashSetTest", function () {
+ it("SR000GGR3J_testNew001", 0, function () {
+ try {
+ let hashSet = new HashSet();
+ } catch (err) {
+ expect(err).assertEqual("Error: Cannot create new HashSet");
+ }
+ });
+ it("SR000GGR3J_testAdd001", 0, function () {
+ let hashSet = new HashSet();
+ hashSet.add(1);
+ let res = hashSet.has(1);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR3J_testAdd002", 0, function () {
+ let hashSet = new HashSet();
+ hashSet.add("b");
+ hashSet.add("c");
+ hashSet.add("d");
+ hashSet.add("a");
+ hashSet.add("g");
+ let res = hashSet.has("a");
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR3J_testAdd004", 0, function () {
+ let hashSet = new HashSet();
+ let c = [1, 2, 3];
+ hashSet.add(c);
+ let res = hashSet.has(c);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR3J_testAdd005", 0, function () {
+ let hashSet = new HashSet();
+ let c = {name: "lili", age: "13"};
+ hashSet.add(c);
+ let res = hashSet.has(c);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR3J_testLength006", 0, function () {
+ let hashSet = new HashSet();
+ hashSet.add(1);
+ hashSet.add(2);
+ hashSet.add(3);
+ hashSet.add(4);
+ hashSet.add(5);
+ let res = hashSet.length;
+ expect(res).assertEqual(5);
+ });
+ it("SR000GGR3J_testHas007", 0, function () {
+ let hashSet = new HashSet();
+ hashSet.add(4);
+ hashSet.add(1);
+ hashSet.add(3);
+ hashSet.add(2);
+ hashSet.add(5);
+ let res = hashSet.has(1);
+ expect(res).assertEqual(true);
+ let res1 = hashSet.has("A");
+ expect(res1).assertEqual(false);
+ });
+ it("SR000GGR3J_testIsEmpty008", 0, function () {
+ let hashSet = new HashSet();
+ hashSet.add(4);
+ hashSet.add(1);
+ hashSet.add(3);
+ hashSet.add(2);
+ hashSet.add(5);
+ let res = hashSet.isEmpty();
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR3J_testRemove009", 0, function () {
+ let hashSet = new HashSet();
+ hashSet.add(4);
+ hashSet.add(1);
+ hashSet.add(3);
+ hashSet.add(2);
+ hashSet.add(5);
+ let res = hashSet.remove(1);
+ expect(res).assertEqual(true);
+ let arr = [];
+ hashSet.forEach((value, index) => {
+ arr.push(value);
+ });
+ for (let i = 0; i < arr.length; i++) {
+ let has = hashSet.has(arr[i]);
+ expect(has).assertEqual(true);
+ }
+ });
+ it("SR000GGR3J_testClear010", 0, function () {
+ let hashSet = new HashSet();
+ hashSet.add(4);
+ hashSet.add(1);
+ hashSet.add(3);
+ hashSet.add(2);
+ hashSet.add(5);
+ let res = hashSet.length;
+ expect(res).assertEqual(5);
+ hashSet.clear();
+ let res1 = hashSet.length;
+ expect(res1).assertEqual(0);
+ });
+ it("SR000GGR3J_testValues011", 0, function () {
+ let hashSet = new HashSet();
+ hashSet.add("A");
+ hashSet.add("B");
+ hashSet.add("C");
+ hashSet.add("D");
+ hashSet.add("E");
+ let res = hashSet.values();
+ for (let i = 0; i < hashSet.length; i++) {
+ let has = hashSet.has(res.next().value);
+ expect(has).assertEqual(true);
+ }
+ });
+ it("SR000GGR3J_testForEach012", 0, function () {
+ let hashSet = new HashSet();
+ hashSet.add(1);
+ hashSet.add(2);
+ hashSet.add(3);
+ hashSet.add(4);
+ hashSet.add(5);
+ let arr = [];
+ hashSet.forEach((value, index) => {
+ arr.push(value);
+ });
+ for (let i = 0; i < arr.length; i++) {
+ let has = hashSet.has(arr[i]);
+ expect(has).assertEqual(true);
+ }
+ });
+ it("SR000GGR3J_testIterator013", 0, function () {
+ let hashSet = new HashSet();
+ hashSet.add(1);
+ hashSet.add(2);
+ hashSet.add(3);
+ hashSet.add(4);
+ hashSet.add(5);
+ let arr = [];
+ for (let item of hashSet) {
+ arr.push(item);
+ }
+ for (let i = 0; i < arr.length; i++) {
+ let has = hashSet.has(arr[i]);
+ expect(has).assertEqual(true);
+ }
+ });
+ it("SR000GGR3J_testIterator014", 0, function () {
+ let hashSet = new HashSet();
+ hashSet.add("A");
+ hashSet.add("B");
+ hashSet.add("C");
+ hashSet.add("D");
+ hashSet.add("E");
+ let arr = [];
+ for (let item of hashSet) {
+ arr.push(item);
+ }
+ for (let i = 0; i < arr.length; i++) {
+ let has = hashSet.has(arr[i]);
+ expect(has).assertEqual(true);
+ }
+ });
+ it("SR000GGR3J_testEntries015", 0, function () {
+ let hashSet = new HashSet();
+ hashSet.add(1);
+ hashSet.add(2);
+ hashSet.add(3);
+ hashSet.add(4);
+ hashSet.add(5);
+ let res = hashSet.entries();
+ for (let i = 0; i < hashSet.length; i++) {
+ let has = hashSet.has(res.next().value[1]);
+ expect(has).assertEqual(true);
+ }
+ });
+ it("SR000GGR3J_testAdd016", 0, function () {
+ let hashSet = new HashSet();
+ hashSet.add("");
+ let res = hashSet.has("");
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR3J_testAdd017", 0, function () {
+ let hashSet = new HashSet();
+ hashSet.add("$");
+ let res = hashSet.has("$");
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR3J_testAdd017", 0, function () {
+ let hashSet = new HashSet();
+ hashSet.add(1.34);
+ let res = hashSet.has(1.34);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR3J_testAdd018", 0, function () {
+ let hashSet = new HashSet();
+ hashSet.add(-1);
+ let res = hashSet.has(-1);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR3J_testAdd019", 0, function () {
+ let hashSet = new HashSet();
+ let a = {};
+ hashSet.add(a);
+ let res = hashSet.has(a);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR3J_testAdd020", 0, function () {
+ let hashSet = new HashSet();
+ for (let i = 0; i < 100; i++) {
+ hashSet.add(i);
+ let res = hashSet.has(i);
+ expect(res).assertEqual(true);
+ }
+ let res1 = hashSet.length;
+ expect(res1).assertEqual(100);
+ });
+ it("SR000GGR3J_testIterator021", 0, function () {
+ let hashSet = new HashSet();
+ let i = 0;
+ for (let item of hashSet) {
+ expect(item).assertEqual(i);
+ i++;
+ }
+ });
+ it("SR000GGR3J_testForEach022", 0, function () {
+ let hashSet = new HashSet();
+ let arr = [];
+ hashSet.forEach((value, index) => {
+ arr.push(value);
+ });
+ expect(arr.length).assertEqual(0);
+ });
+ it("SR000GGR3J_testIsEmpty023", 0, function () {
+ let hashSet = new HashSet();
+ hashSet.add(4);
+ hashSet.add(1);
+ hashSet.add(3);
+ hashSet.add(2);
+ hashSet.add(5);
+ hashSet.clear();
+ let res = hashSet.isEmpty();
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR3J_testHas024", 0, function () {
+ let hashSet = new HashSet();
+ let res = hashSet.has(1);
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR3J_testRemove025", 0, function () {
+ let hashSet = new HashSet();
+ let res = hashSet.remove(1);
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR3J_testClear026", 0, function () {
+ let hashSet = new HashSet();
+ let res = hashSet.clear();
+ expect(res).assertEqual(undefined);
+ });
+ it("SR000GGR3J_testEntries027", 0, function () {
+ let hashSet = new HashSet();
+ let res = hashSet.entries();
+ expect(res.next().value).assertEqual(undefined);
+ });
+ it("SR000GGR3J_testIterator028", 0, function () {
+ let hashSet = new HashSet();
+ for (let i = 0; i < 100; i++) {
+ let text = hashSet.add(i);
+ }
+ let arr = [];
+ for (let item of hashSet) {
+ arr.push(Number.parseInt(item));
+ }
+ for (let i = 0; i < 100; i++) {
+ let a = arr[i];
+ let res = hashSet.has(a);
+ expect(res).assertEqual(true);
+ }
+ });
+ it("SR000GGR3J_testForEach029", 0, function () {
+ let hashSet = new HashSet();
+ for (let i = 0; i < 100; i++) {
+ hashSet.add(i);
+ }
+ let arr = [];
+ hashSet.forEach((value, index) => {
+ arr.push(value);
+ });
+ for (let i = 0; i < 100; i++) {
+ let a = arr[i];
+ let res = hashSet.has(a);
+ expect(res).assertEqual(true);
+ }
+ });
+ it("SR000GGR3J_testAdd030", 0, function () {
+ let hashSet = new HashSet();
+ hashSet.add(1);
+ hashSet.add(1);
+ let has = hashSet.has(1);
+ let size = hashSet.length;
+ expect(has).assertEqual(true);
+ expect(size).assertEqual(1);
+ });
+ it("SR000GGR3J_testIterator031", 0, function () {
+ let hashSet = new HashSet();
+ hashSet.add(1);
+ hashSet.add(2);
+ hashSet.add(3);
+ hashSet.add(4);
+ hashSet.add(5);
+ let res = hashSet[Symbol.iterator]();
+ let temp = undefined;
+ let arr = [];
+ do {
+ temp = res.next().value;
+ arr.push(temp);
+ } while (temp != undefined);
+ arr.sort(function (a, b) {
+ return a - b;
+ });
+ let arr1 = [1, 2, 3, 4, 5];
+ for (let i = 0; i < arr.length; i++) {
+ expect(arr[i]).assertEqual(arr1[i]);
+ }
+ });
+});
diff --git a/compileruntime/util_lib_standard/src/main/js/test/LightWeightMap.test.js b/compileruntime/containerRelation_lib_standard/src/main/js/test/LightWeightMap.test.js
similarity index 97%
rename from compileruntime/util_lib_standard/src/main/js/test/LightWeightMap.test.js
rename to compileruntime/containerRelation_lib_standard/src/main/js/test/LightWeightMap.test.js
index 2bc52db9fe322dcae5eff2749f48370e97ffe36e..7d9d83f79fb6bc203313948b91ce85aba4e4adb5 100644
--- a/compileruntime/util_lib_standard/src/main/js/test/LightWeightMap.test.js
+++ b/compileruntime/containerRelation_lib_standard/src/main/js/test/LightWeightMap.test.js
@@ -1,589 +1,589 @@
-/*
- * Copyright (C) 2021 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 'deccjsunit/index';
-import LightWeightMap from "@ohos.util.LightWeightMap";
-
-describe("LightWeightMapTest", function () {
- it("SR00GGR3L_testConstructor001", 0, function () {
- try {
- let lightWeightMap = new LightWeightMap();
- expect(lightWeightMap != undefined).assertEqual(true);
- } catch (err) {
- expect(err).assertEqual("Error:Cannot create new TreeMap");
- }
- });
- it("SR00GGR3L_testSet002", 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);
- });
- it("SR00GGR3L_testSet003", 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);
- });
- it("SR00GGR3L_testSet004", 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);
- });
- it("SR00GGR3L_testSet005", 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);
- });
- it("SR00GGR3L_testGet006", 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");
- });
- it("SR00GGR3L_testLength007", 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);
- });
- it("SR00GGR3L_testHasAll008", 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);
- });
- it("SR00GGR3L_testHasKey009", 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);
- });
- it("SR00GGR3L_testHasValue010", 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);
- });
- it("SR00GGR3L_testIncreaseCapacityTo011", 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(3);
- expect(res).assertEqual(undefined);
- });
- it("SR00GGR3L_testEntries012", 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"]');
- });
- it("SR00GGR3L_testGetIndexOfKey013", 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);
- });
- it("SR00GGR3L_testGetIndexOfValue014", 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);
- });
- it("SR00GGR3L_testIsEmpty015", 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);
- });
- it("SR00GGR3L_testGetKeyAt016", 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);
- });
- it("SR00GGR3L_testKeys017", 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);
- });
- it("SR00GGR3L_testSetAll018", 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);
- }
- });
- it("SR00GGR3L_testRemove019", 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);
- });
- it("SR00GGR3L_testRemoveAt020", 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);
- });
- it("SR00GGR3L_testClear021", 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);
- });
- it("SR00GGR3L_testSetValueAt022", 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");
- });
- it("SR00GGR3L_testForEach023", 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]);
- }
- });
- it("SR00GGR3L_testToString024", 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");
- });
- it("SR00GGR3L_testValues025", 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");
- });
- it("SR00GGR3L_testGetValueAt026", 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");
- });
- it("SR00GGR3L_testIterator027", 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 = [];
- for (let item of lightWeightMap) {
- arr.push(item);
- }
- let arr1 = ["1,A", "2,B", "3,C", "4,D", "5,E"];
- for (let i = 0; i < arr1.length; i++) {
- expect(arr[i]).assertEqual(arr1[i]);
- }
- });
- it("SR00GGR3L_testSet028", 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);
- });
- it("SR00GGR3L_testSet029", 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);
- });
- it("SR00GGR3L_testSet030", 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);
- });
- it("SR00GGR3L_testSet031", 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);
- });
- it("SR00GGR3L_testHasAll032", 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);
- });
- it("SR00GGR3L_testHasAll033", 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);
- });
- it("SR00GGR3L_testRemove034", 0, function () {
- let lightWeightMap = new LightWeightMap();
- try {
- let res = lightWeightMap.remove(3);
- } catch (err) {
- expect(err).assertEqual("Error: don't find the key in lightweight");
- }
- });
- it("SR00GGR3L_testRemoveAt035", 0, function () {
- let lightWeightMap = new LightWeightMap();
- let res = lightWeightMap.removeAt(1);
- expect(res).assertEqual(false);
- });
- it("SR00GGR3L_testIncreaseCapacityTo036", 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);
- });
- it("SR00GGR3L_testIncreaseCapacityTo037", 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 {
- let res = lightWeightMap.increaseCapacityTo("qwe");
- } catch (err) {
- expect(err).assertEqual("lightWeightMap: index must be int");
- }
- });
- it("SR00GGR3L_testRemoveAt038", 0, function () {
- let lightWeightMap = new LightWeightMap();
- try {
- let res = lightWeightMap.removeAt("123");
- } catch (err) {
- expect(err).assertEqual("lightWeightMap: index must be int");
- }
- });
- it("SR00GGR3L_testGetValueAt039", 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.getValueAt("123");
- } catch (err) {
- expect(err).assertEqual("lightWeightMap: index must be int");
- }
- });
- it("SR00GGR3L_testGetKeyAt040", 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("123");
- } catch (err) {
- expect(err).assertEqual("lightWeightMap: index must be int");
- }
- });
- it("SR00GGR3L_testHasAll041", 0, function () {
- let lightWeightMap = new LightWeightMap();
- let lightWeightMap1 = new LightWeightMap();
- let res = lightWeightMap.hasAll(lightWeightMap1);
- expect(res).assertEqual(true);
- });
- it("SR00GGR3L_testSet042", 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);
- });
- it("SR00GGR3L_testSet043", 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);
- });
- it("SR00GGR3L_testSet044", 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);
- }
- });
- it("SR00GGR3L_testSet045", 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);
- }
- });
- it("SR00GGR3L_testSet046", 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);
- });
- it("SR00GGR3L_testSet047", 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);
- });
- it("SR00GGR3L_testSet048", 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);
- });
- it("SR00GGR3L_testGet049", 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(null);
- });
- it("SR00GGR3L_testHasAll050", 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);
- });
- it("SR00GGR3L_testIterator051", 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 = [];
- let res = lightWeightMap[Symbol.iterator]();
- let temp = undefined;
- do {
- temp = res.next().value;
- arr.push(temp);
- } while (temp != undefined);
- let arr1 = ["1,A", "2,B", "3,C", "4,D", "5,E"];
- for (let i = 0; i < arr.length; i++) {
- expect(arr[i]).assertEqual(arr1[i]);
- }
- });
-});
+/*
+ * Copyright (C) 2021 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 'deccjsunit/index';
+import LightWeightMap from "@ohos.util.LightWeightMap";
+
+describe("LightWeightMapTest", function () {
+ it("SR00GGR3L_testConstructor001", 0, function () {
+ try {
+ let lightWeightMap = new LightWeightMap();
+ expect(lightWeightMap != undefined).assertEqual(true);
+ } catch (err) {
+ expect(err).assertEqual("Error:Cannot create new TreeMap");
+ }
+ });
+ it("SR00GGR3L_testSet002", 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);
+ });
+ it("SR00GGR3L_testSet003", 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);
+ });
+ it("SR00GGR3L_testSet004", 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);
+ });
+ it("SR00GGR3L_testSet005", 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);
+ });
+ it("SR00GGR3L_testGet006", 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");
+ });
+ it("SR00GGR3L_testLength007", 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);
+ });
+ it("SR00GGR3L_testHasAll008", 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);
+ });
+ it("SR00GGR3L_testHasKey009", 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);
+ });
+ it("SR00GGR3L_testHasValue010", 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);
+ });
+ it("SR00GGR3L_testIncreaseCapacityTo011", 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(3);
+ expect(res).assertEqual(undefined);
+ });
+ it("SR00GGR3L_testEntries012", 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"]');
+ });
+ it("SR00GGR3L_testGetIndexOfKey013", 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);
+ });
+ it("SR00GGR3L_testGetIndexOfValue014", 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);
+ });
+ it("SR00GGR3L_testIsEmpty015", 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);
+ });
+ it("SR00GGR3L_testGetKeyAt016", 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);
+ });
+ it("SR00GGR3L_testKeys017", 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);
+ });
+ it("SR00GGR3L_testSetAll018", 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);
+ }
+ });
+ it("SR00GGR3L_testRemove019", 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);
+ });
+ it("SR00GGR3L_testRemoveAt020", 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);
+ });
+ it("SR00GGR3L_testClear021", 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);
+ });
+ it("SR00GGR3L_testSetValueAt022", 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");
+ });
+ it("SR00GGR3L_testForEach023", 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]);
+ }
+ });
+ it("SR00GGR3L_testToString024", 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");
+ });
+ it("SR00GGR3L_testValues025", 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");
+ });
+ it("SR00GGR3L_testGetValueAt026", 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");
+ });
+ it("SR00GGR3L_testIterator027", 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 = [];
+ for (let item of lightWeightMap) {
+ arr.push(item);
+ }
+ let arr1 = ["1,A", "2,B", "3,C", "4,D", "5,E"];
+ for (let i = 0; i < arr1.length; i++) {
+ expect(arr[i]).assertEqual(arr1[i]);
+ }
+ });
+ it("SR00GGR3L_testSet028", 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);
+ });
+ it("SR00GGR3L_testSet029", 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);
+ });
+ it("SR00GGR3L_testSet030", 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);
+ });
+ it("SR00GGR3L_testSet031", 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);
+ });
+ it("SR00GGR3L_testHasAll032", 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);
+ });
+ it("SR00GGR3L_testHasAll033", 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);
+ });
+ it("SR00GGR3L_testRemove034", 0, function () {
+ let lightWeightMap = new LightWeightMap();
+ try {
+ let res = lightWeightMap.remove(3);
+ } catch (err) {
+ expect(err).assertEqual("Error: don't find the key in lightweight");
+ }
+ });
+ it("SR00GGR3L_testRemoveAt035", 0, function () {
+ let lightWeightMap = new LightWeightMap();
+ let res = lightWeightMap.removeAt(1);
+ expect(res).assertEqual(false);
+ });
+ it("SR00GGR3L_testIncreaseCapacityTo036", 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);
+ });
+ it("SR00GGR3L_testIncreaseCapacityTo037", 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 {
+ let res = lightWeightMap.increaseCapacityTo("qwe");
+ } catch (err) {
+ expect(err).assertEqual("lightWeightMap: index must be int");
+ }
+ });
+ it("SR00GGR3L_testRemoveAt038", 0, function () {
+ let lightWeightMap = new LightWeightMap();
+ try {
+ let res = lightWeightMap.removeAt("123");
+ } catch (err) {
+ expect(err).assertEqual("lightWeightMap: index must be int");
+ }
+ });
+ it("SR00GGR3L_testGetValueAt039", 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.getValueAt("123");
+ } catch (err) {
+ expect(err).assertEqual("lightWeightMap: index must be int");
+ }
+ });
+ it("SR00GGR3L_testGetKeyAt040", 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("123");
+ } catch (err) {
+ expect(err).assertEqual("lightWeightMap: index must be int");
+ }
+ });
+ it("SR00GGR3L_testHasAll041", 0, function () {
+ let lightWeightMap = new LightWeightMap();
+ let lightWeightMap1 = new LightWeightMap();
+ let res = lightWeightMap.hasAll(lightWeightMap1);
+ expect(res).assertEqual(true);
+ });
+ it("SR00GGR3L_testSet042", 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);
+ });
+ it("SR00GGR3L_testSet043", 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);
+ });
+ it("SR00GGR3L_testSet044", 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);
+ }
+ });
+ it("SR00GGR3L_testSet045", 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);
+ }
+ });
+ it("SR00GGR3L_testSet046", 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);
+ });
+ it("SR00GGR3L_testSet047", 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);
+ });
+ it("SR00GGR3L_testSet048", 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);
+ });
+ it("SR00GGR3L_testGet049", 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(null);
+ });
+ it("SR00GGR3L_testHasAll050", 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);
+ });
+ it("SR00GGR3L_testIterator051", 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 = [];
+ let res = lightWeightMap[Symbol.iterator]();
+ let temp = undefined;
+ do {
+ temp = res.next().value;
+ arr.push(temp);
+ } while (temp != undefined);
+ let arr1 = ["1,A", "2,B", "3,C", "4,D", "5,E"];
+ for (let i = 0; i < arr.length; i++) {
+ expect(arr[i]).assertEqual(arr1[i]);
+ }
+ });
+});
diff --git a/compileruntime/util_lib_standard/src/main/js/test/LightWeightSet.test.js b/compileruntime/containerRelation_lib_standard/src/main/js/test/LightWeightSet.test.js
similarity index 97%
rename from compileruntime/util_lib_standard/src/main/js/test/LightWeightSet.test.js
rename to compileruntime/containerRelation_lib_standard/src/main/js/test/LightWeightSet.test.js
index 0df664a588ef0087da0e02c9cc0dba65081752c4..e4ce55f4e2ac4653b9fcd2d9fb3607e883656f38 100644
--- a/compileruntime/util_lib_standard/src/main/js/test/LightWeightSet.test.js
+++ b/compileruntime/containerRelation_lib_standard/src/main/js/test/LightWeightSet.test.js
@@ -1,473 +1,473 @@
-/*
- * Copyright (C) 2021 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 'deccjsunit/index';
-import LightWeightSet from "@ohos.util.LightWeightSet";
-
-describe("LightWeightSetTest", function () {
- it("SR000GGR43_testNew001", 0, function () {
- try {
- let lightWeightSet = new LightWeightSet();
- expect(lightWeightSet != undefined).assertEqual(true);
- } catch (err) {
- expect(err).assertEqual("Error:Cannot create new TreeMap");
- }
- });
- it("SR000GGR43_testAdd002", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add(1);
- let res = lightWeightSet.has(1);
- expect(res).assertEqual(true);
- });
- it("SR000GGR43_testAdd003", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add("a");
- let res = lightWeightSet.has("a");
- expect(res).assertEqual(true);
- });
- it("SR000GGR43_testAdd004", 0, function () {
- let lightWeightSet = new LightWeightSet();
- let a = [1, 2, 3, 4];
- lightWeightSet.add(a);
- let res = lightWeightSet.has(a);
- expect(res).assertEqual(true);
- });
- it("SR000GGR43_testAdd005", 0, function () {
- let lightWeightSet = new LightWeightSet();
- let c = {name: "lili", age: "13"};
- lightWeightSet.add(c);
- let res = lightWeightSet.has(c);
- expect(res).assertEqual(true);
- });
- it("SR000GGR43_testAdd006", 0, function () {
- let lightWeightSet = new LightWeightSet();
- let c = false;
- lightWeightSet.add(c);
- let res = lightWeightSet.has(c);
- expect(res).assertEqual(true);
- });
- it("SR000GGR43_testLength007", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add(1);
- lightWeightSet.add(2);
- lightWeightSet.add(3);
- lightWeightSet.add(4);
- lightWeightSet.add(5);
- let res = lightWeightSet.length;
- expect(res).assertEqual(5);
- });
- it("SR000GGR43_testAddAll008", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add(1);
- lightWeightSet.add(2);
- lightWeightSet.add(3);
- lightWeightSet.add(4);
- lightWeightSet.add(5);
- let lightWeightSet1 = new LightWeightSet();
- lightWeightSet1.add(6);
- lightWeightSet1.add(7);
- let res1 = lightWeightSet.addAll(lightWeightSet1);
- for (let item of lightWeightSet) {
- console.log("lightWeightSet-----" + item);
- }
- for (let item of lightWeightSet1) {
- console.log("lightWeightSet1-----" + item);
- }
- for (let i = 1; i < 8; i++) {
- expect(lightWeightSet.has(i)).assertEqual(true);
- }
- expect(res1).assertEqual(true);
- });
- it("SR000GGR43_testHasAll009", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add("a");
- lightWeightSet.add("b");
- lightWeightSet.add("c");
- lightWeightSet.add("d");
- lightWeightSet.add("e");
- let lightWeightSet1 = new LightWeightSet();
- lightWeightSet1.add("a");
- lightWeightSet1.add("d");
- let res = lightWeightSet.hasAll(lightWeightSet1);
- expect(res).assertEqual(true);
- });
- it("SR000GGR43_testHasAllr010", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add("a");
- lightWeightSet.add("b");
- lightWeightSet.add("c");
- lightWeightSet.add("e");
- let lightWeightSet1 = new LightWeightSet();
- lightWeightSet1.add("a");
- lightWeightSet1.add("d");
- let res = lightWeightSet.hasAll(lightWeightSet1);
- expect(res).assertEqual(false);
- });
- it("SR000GGR43_testHas011", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add("a");
- lightWeightSet.add("b");
- lightWeightSet.add("c");
- lightWeightSet.add("d");
- lightWeightSet.add("e");
- let res = lightWeightSet.has("a");
- expect(res).assertEqual(true);
- let res1 = lightWeightSet.has(1);
- expect(res1).assertEqual(false);
- });
- it("SR000GGR43_testEntries012", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add(1);
- lightWeightSet.add(2);
- lightWeightSet.add(3);
- lightWeightSet.add(4);
- lightWeightSet.add(5);
- let res = lightWeightSet.entries();
- expect(JSON.stringify(res.next().value)).assertEqual("[1,1]");
- expect(JSON.stringify(res.next().value)).assertEqual("[2,2]");
- expect(JSON.stringify(res.next().value)).assertEqual("[3,3]");
- expect(JSON.stringify(res.next().value)).assertEqual("[4,4]");
- expect(JSON.stringify(res.next().value)).assertEqual("[5,5]");
- });
- it("SR000GGR43_testGetIndexOf013", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add(1);
- lightWeightSet.add(2);
- lightWeightSet.add(3);
- lightWeightSet.add(4);
- lightWeightSet.add(5);
- let res = lightWeightSet.getIndexOf(2);
- expect(res).assertEqual(1);
- });
- it("SR000GGR43_testIsEmpty014", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add(1);
- lightWeightSet.add(2);
- lightWeightSet.add(3);
- lightWeightSet.add(4);
- lightWeightSet.add(5);
- let res = lightWeightSet.isEmpty();
- expect(res).assertEqual(false);
- });
- it("SR000GGR43_testRemove015", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add(1);
- lightWeightSet.add(2);
- lightWeightSet.add(3);
- lightWeightSet.add(4);
- lightWeightSet.add(5);
- let res = lightWeightSet.remove(1);
- expect(res).assertEqual(1);
- let arr = [];
- lightWeightSet.forEach((value, index) => {
- arr.push(value);
- });
- let arr1 = [2, 3, 4, 5];
- for (let i = 0; i < arr.length; i++) {
- expect(arr1[i]).assertEqual(arr[i]);
- }
- });
- it("SR000GGR43_testRemoveAt016", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add(1);
- lightWeightSet.add(2);
- lightWeightSet.add(3);
- lightWeightSet.add(4);
- lightWeightSet.add(5);
- let res = lightWeightSet.removeAt(1);
- expect(res).assertEqual(true);
- let arr = [];
- lightWeightSet.forEach((value, index) => {
- arr.push(value);
- });
- let arr1 = [1, 3, 4, 5];
- for (let i = 0; i < arr.length; i++) {
- expect(arr1[i]).assertEqual(arr[i]);
- }
- });
- it("SR000GGR43_testClear017", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add(1);
- lightWeightSet.add(2);
- lightWeightSet.add(3);
- lightWeightSet.add(4);
- lightWeightSet.add(5);
- lightWeightSet.clear();
- let res = lightWeightSet.length;
- expect(res).assertEqual(0);
- });
- it("SR000GGR43_testForEach018", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add(1);
- lightWeightSet.add(2);
- lightWeightSet.add(3);
- lightWeightSet.add(4);
- lightWeightSet.add(5);
- let arr = [];
- lightWeightSet.forEach((value, index) => {
- arr.push(value);
- });
- let arr1 = [1, 2, 3, 4, 5];
- for (let i = 0; i < arr1.length; i++) {
- expect(arr[i]).assertEqual(arr1[i]);
- }
- });
- it("SR000GGR43_testToString019", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add(1);
- lightWeightSet.add(2);
- lightWeightSet.add(3);
- let res = lightWeightSet.toString();
- expect(res).assertEqual("1,2,3");
- });
- it("SR000GGR43_testToArray020", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add(1);
- lightWeightSet.add(2);
- lightWeightSet.add(3);
- lightWeightSet.add(4);
- lightWeightSet.add(5);
- let res = lightWeightSet.toArray();
- let arr1 = [1, 2, 3, 4, 5];
- for (let i = 0; i < arr1.length; i++) {
- expect(res[i]).assertEqual(arr1[i]);
- }
- });
- it("SR000GGR43_testGetValueAt021", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add(1);
- lightWeightSet.add(2);
- lightWeightSet.add(3);
- lightWeightSet.add(4);
- lightWeightSet.add(5);
- let res = lightWeightSet.getValueAt(1);
- expect(res).assertEqual(2);
- });
- it("SR000GGR43_testIterator022", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add(1);
- lightWeightSet.add(2);
- lightWeightSet.add(3);
- lightWeightSet.add(4);
- lightWeightSet.add(5);
- let arr = [];
- for (let item of lightWeightSet) {
- let res = arr.push(item);
- }
- let arr1 = [1, 2, 3, 4, 5];
- for (let i = 0; i < arr1.length; i++) {
- expect(arr[i]).assertEqual(arr1[i]);
- }
- });
- it("SR000GGR43_testValues023", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add(1);
- lightWeightSet.add(2);
- lightWeightSet.add(3);
- lightWeightSet.add(4);
- lightWeightSet.add(5);
- let res = lightWeightSet.values();
- 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);
- });
- it("SR000GGR43_testAdd024", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add(null);
- let res = lightWeightSet.has(null);
- expect(res).assertEqual(true);
- });
- it("SR000GGR43_testAdd025", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add(1.23);
- let res1 = lightWeightSet.has(1.23);
- expect(res1).assertEqual(true);
- });
- it("SR000GGR43_testHasAll026", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add(1);
- lightWeightSet.add(2);
- lightWeightSet.add(3);
- lightWeightSet.add(4);
- lightWeightSet.add(5);
- let lightWeightSet1 = new LightWeightSet();
- lightWeightSet1.add("a1");
- lightWeightSet1.add("d1");
- let res = lightWeightSet.hasAll(lightWeightSet1);
- expect(res).assertEqual(false);
- });
- it("SR000GGR43_testHasAll027", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add(1);
- lightWeightSet.add(2);
- lightWeightSet.add(3);
- lightWeightSet.add(4);
- lightWeightSet.add(5);
- let lightWeightSet1 = new LightWeightSet();
- lightWeightSet1.add(1);
- lightWeightSet1.add("d");
- let res = lightWeightSet.hasAll(lightWeightSet1);
- expect(res).assertEqual(false);
- });
- it("SR000GGR43_testRemove028", 0, function () {
- let lightWeightSet = new LightWeightSet();
- try {
- let res = lightWeightSet.remove(3);
- } catch (err) {
- expect(err).assertEqual("Error: don't find the key in lightweight");
- }
- });
- it("SR000GGR43_testRemoveAt029", 0, function () {
- let lightWeightSet = new LightWeightSet();
- let res = lightWeightSet.removeAt(1);
- expect(res).assertEqual(false);
- });
- it("SR000GGR43_testIncreaseCapacityTo030", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add(1);
- lightWeightSet.add(2);
- lightWeightSet.add(3);
- lightWeightSet.add(4);
- lightWeightSet.add(5);
- try {
- let res = lightWeightSet.increaseCapacityTo(3);
- } catch (err) {
- expect(err).assertEqual("Unable to shrink capacity");
- }
- });
- it("SR000GGR43_testIncreaseCapacityTo031", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add(1);
- lightWeightSet.add(2);
- lightWeightSet.add(3);
- lightWeightSet.add(4);
- lightWeightSet.add(5);
- try {
- let res = lightWeightSet.increaseCapacityTo("qwe");
- } catch (err) {
- expect(err).assertEqual("lightWeightSet: index must be int");
- }
- });
- it("SR000GGR43_testRemoveAt032", 0, function () {
- let lightWeightSet = new LightWeightSet();
- try {
- let res = lightWeightSet.removeAt("123");
- } catch (err) {
- expect(err).assertEqual("lightWeightSet: index must be int");
- }
- });
- it("SR000GGR43_testIncreaseCapacityTo033", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add(1);
- lightWeightSet.add(2);
- lightWeightSet.add(3);
- lightWeightSet.add(4);
- lightWeightSet.add(5);
- let res = lightWeightSet.increaseCapacityTo(20);
- expect(res).assertEqual(undefined);
- });
- it("SR000GGR43_testGetValueAt034", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add(1);
- lightWeightSet.add(2);
- lightWeightSet.add(3);
- lightWeightSet.add(4);
- lightWeightSet.add(5);
- try {
- let res = lightWeightSet.getValueAt("123");
- } catch (err) {
- expect(err).assertEqual("lightWeightSet: index must be int");
- }
- });
- it("SR000GGR43_testIsEmpty035", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add(1);
- lightWeightSet.add(2);
- lightWeightSet.add(3);
- lightWeightSet.add(4);
- lightWeightSet.add(5);
- lightWeightSet.clear();
- let res = lightWeightSet.isEmpty();
- expect(res).assertEqual(true);
- });
- it("SR000GGR43_testAdd036", 0, function () {
- let lightWeightSet = new LightWeightSet();
- for (let i = 0; i < 10000; i++) {
- lightWeightSet.add(i);
- }
- let res = lightWeightSet.getValueAt(9999);
- let res1 = lightWeightSet.length;
- expect(res).assertEqual(9999);
- expect(res1).assertEqual(10000);
- });
- it("SR000GGR43_testAdd037", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add("");
- let res = lightWeightSet.has("");
- expect(res).assertEqual(true);
- });
- it("SR000GGR43_testAdd038", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add("$");
- let res = lightWeightSet.has("$");
- expect(res).assertEqual(true);
- });
- it("SR000GGR43_testClear039", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add(1);
- lightWeightSet.add(2);
- lightWeightSet.add(3);
- lightWeightSet.add(4);
- lightWeightSet.add(5);
- let res = lightWeightSet.length;
- lightWeightSet.clear();
- let res1 = lightWeightSet.length;
- expect(res).assertEqual(5);
- expect(res1).assertEqual(0);
- });
- it("SR000GGR43_testRemove040", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add(1);
- lightWeightSet.add(2);
- lightWeightSet.add(3);
- lightWeightSet.add(4);
- lightWeightSet.add(5);
- try {
- let res = lightWeightSet.remove("A");
- } catch (err) {
- expect(err).assertEqual("Error: don't find the key in lightweight");
- }
- });
- it("SR000GGR43_testIterator41", 0, function () {
- let lightWeightSet = new LightWeightSet();
- lightWeightSet.add(1);
- lightWeightSet.add(2);
- lightWeightSet.add(3);
- lightWeightSet.add(4);
- lightWeightSet.add(5);
- let arr = [];
- let res = lightWeightSet[Symbol.iterator]();
- let temp = undefined;
- do {
- temp = res.next().value;
- arr.push(temp);
- } while (temp != undefined);
- let arr1 = [1, 2, 3, 4, 5];
- for (let i = 0; i < arr1.length; i++) {
- expect(arr[i]).assertEqual(arr1[i]);
- }
- });
-});
+/*
+ * Copyright (C) 2021 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 'deccjsunit/index';
+import LightWeightSet from "@ohos.util.LightWeightSet";
+
+describe("LightWeightSetTest", function () {
+ it("SR000GGR43_testNew001", 0, function () {
+ try {
+ let lightWeightSet = new LightWeightSet();
+ expect(lightWeightSet != undefined).assertEqual(true);
+ } catch (err) {
+ expect(err).assertEqual("Error:Cannot create new TreeMap");
+ }
+ });
+ it("SR000GGR43_testAdd002", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add(1);
+ let res = lightWeightSet.has(1);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR43_testAdd003", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add("a");
+ let res = lightWeightSet.has("a");
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR43_testAdd004", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ let a = [1, 2, 3, 4];
+ lightWeightSet.add(a);
+ let res = lightWeightSet.has(a);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR43_testAdd005", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ let c = {name: "lili", age: "13"};
+ lightWeightSet.add(c);
+ let res = lightWeightSet.has(c);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR43_testAdd006", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ let c = false;
+ lightWeightSet.add(c);
+ let res = lightWeightSet.has(c);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR43_testLength007", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add(1);
+ lightWeightSet.add(2);
+ lightWeightSet.add(3);
+ lightWeightSet.add(4);
+ lightWeightSet.add(5);
+ let res = lightWeightSet.length;
+ expect(res).assertEqual(5);
+ });
+ it("SR000GGR43_testAddAll008", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add(1);
+ lightWeightSet.add(2);
+ lightWeightSet.add(3);
+ lightWeightSet.add(4);
+ lightWeightSet.add(5);
+ let lightWeightSet1 = new LightWeightSet();
+ lightWeightSet1.add(6);
+ lightWeightSet1.add(7);
+ let res1 = lightWeightSet.addAll(lightWeightSet1);
+ for (let item of lightWeightSet) {
+ console.log("lightWeightSet-----" + item);
+ }
+ for (let item of lightWeightSet1) {
+ console.log("lightWeightSet1-----" + item);
+ }
+ for (let i = 1; i < 8; i++) {
+ expect(lightWeightSet.has(i)).assertEqual(true);
+ }
+ expect(res1).assertEqual(true);
+ });
+ it("SR000GGR43_testHasAll009", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add("a");
+ lightWeightSet.add("b");
+ lightWeightSet.add("c");
+ lightWeightSet.add("d");
+ lightWeightSet.add("e");
+ let lightWeightSet1 = new LightWeightSet();
+ lightWeightSet1.add("a");
+ lightWeightSet1.add("d");
+ let res = lightWeightSet.hasAll(lightWeightSet1);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR43_testHasAllr010", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add("a");
+ lightWeightSet.add("b");
+ lightWeightSet.add("c");
+ lightWeightSet.add("e");
+ let lightWeightSet1 = new LightWeightSet();
+ lightWeightSet1.add("a");
+ lightWeightSet1.add("d");
+ let res = lightWeightSet.hasAll(lightWeightSet1);
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR43_testHas011", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add("a");
+ lightWeightSet.add("b");
+ lightWeightSet.add("c");
+ lightWeightSet.add("d");
+ lightWeightSet.add("e");
+ let res = lightWeightSet.has("a");
+ expect(res).assertEqual(true);
+ let res1 = lightWeightSet.has(1);
+ expect(res1).assertEqual(false);
+ });
+ it("SR000GGR43_testEntries012", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add(1);
+ lightWeightSet.add(2);
+ lightWeightSet.add(3);
+ lightWeightSet.add(4);
+ lightWeightSet.add(5);
+ let res = lightWeightSet.entries();
+ expect(JSON.stringify(res.next().value)).assertEqual("[1,1]");
+ expect(JSON.stringify(res.next().value)).assertEqual("[2,2]");
+ expect(JSON.stringify(res.next().value)).assertEqual("[3,3]");
+ expect(JSON.stringify(res.next().value)).assertEqual("[4,4]");
+ expect(JSON.stringify(res.next().value)).assertEqual("[5,5]");
+ });
+ it("SR000GGR43_testGetIndexOf013", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add(1);
+ lightWeightSet.add(2);
+ lightWeightSet.add(3);
+ lightWeightSet.add(4);
+ lightWeightSet.add(5);
+ let res = lightWeightSet.getIndexOf(2);
+ expect(res).assertEqual(1);
+ });
+ it("SR000GGR43_testIsEmpty014", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add(1);
+ lightWeightSet.add(2);
+ lightWeightSet.add(3);
+ lightWeightSet.add(4);
+ lightWeightSet.add(5);
+ let res = lightWeightSet.isEmpty();
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR43_testRemove015", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add(1);
+ lightWeightSet.add(2);
+ lightWeightSet.add(3);
+ lightWeightSet.add(4);
+ lightWeightSet.add(5);
+ let res = lightWeightSet.remove(1);
+ expect(res).assertEqual(1);
+ let arr = [];
+ lightWeightSet.forEach((value, index) => {
+ arr.push(value);
+ });
+ let arr1 = [2, 3, 4, 5];
+ for (let i = 0; i < arr.length; i++) {
+ expect(arr1[i]).assertEqual(arr[i]);
+ }
+ });
+ it("SR000GGR43_testRemoveAt016", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add(1);
+ lightWeightSet.add(2);
+ lightWeightSet.add(3);
+ lightWeightSet.add(4);
+ lightWeightSet.add(5);
+ let res = lightWeightSet.removeAt(1);
+ expect(res).assertEqual(true);
+ let arr = [];
+ lightWeightSet.forEach((value, index) => {
+ arr.push(value);
+ });
+ let arr1 = [1, 3, 4, 5];
+ for (let i = 0; i < arr.length; i++) {
+ expect(arr1[i]).assertEqual(arr[i]);
+ }
+ });
+ it("SR000GGR43_testClear017", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add(1);
+ lightWeightSet.add(2);
+ lightWeightSet.add(3);
+ lightWeightSet.add(4);
+ lightWeightSet.add(5);
+ lightWeightSet.clear();
+ let res = lightWeightSet.length;
+ expect(res).assertEqual(0);
+ });
+ it("SR000GGR43_testForEach018", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add(1);
+ lightWeightSet.add(2);
+ lightWeightSet.add(3);
+ lightWeightSet.add(4);
+ lightWeightSet.add(5);
+ let arr = [];
+ lightWeightSet.forEach((value, index) => {
+ arr.push(value);
+ });
+ let arr1 = [1, 2, 3, 4, 5];
+ for (let i = 0; i < arr1.length; i++) {
+ expect(arr[i]).assertEqual(arr1[i]);
+ }
+ });
+ it("SR000GGR43_testToString019", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add(1);
+ lightWeightSet.add(2);
+ lightWeightSet.add(3);
+ let res = lightWeightSet.toString();
+ expect(res).assertEqual("1,2,3");
+ });
+ it("SR000GGR43_testToArray020", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add(1);
+ lightWeightSet.add(2);
+ lightWeightSet.add(3);
+ lightWeightSet.add(4);
+ lightWeightSet.add(5);
+ let res = lightWeightSet.toArray();
+ let arr1 = [1, 2, 3, 4, 5];
+ for (let i = 0; i < arr1.length; i++) {
+ expect(res[i]).assertEqual(arr1[i]);
+ }
+ });
+ it("SR000GGR43_testGetValueAt021", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add(1);
+ lightWeightSet.add(2);
+ lightWeightSet.add(3);
+ lightWeightSet.add(4);
+ lightWeightSet.add(5);
+ let res = lightWeightSet.getValueAt(1);
+ expect(res).assertEqual(2);
+ });
+ it("SR000GGR43_testIterator022", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add(1);
+ lightWeightSet.add(2);
+ lightWeightSet.add(3);
+ lightWeightSet.add(4);
+ lightWeightSet.add(5);
+ let arr = [];
+ for (let item of lightWeightSet) {
+ let res = arr.push(item);
+ }
+ let arr1 = [1, 2, 3, 4, 5];
+ for (let i = 0; i < arr1.length; i++) {
+ expect(arr[i]).assertEqual(arr1[i]);
+ }
+ });
+ it("SR000GGR43_testValues023", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add(1);
+ lightWeightSet.add(2);
+ lightWeightSet.add(3);
+ lightWeightSet.add(4);
+ lightWeightSet.add(5);
+ let res = lightWeightSet.values();
+ 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);
+ });
+ it("SR000GGR43_testAdd024", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add(null);
+ let res = lightWeightSet.has(null);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR43_testAdd025", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add(1.23);
+ let res1 = lightWeightSet.has(1.23);
+ expect(res1).assertEqual(true);
+ });
+ it("SR000GGR43_testHasAll026", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add(1);
+ lightWeightSet.add(2);
+ lightWeightSet.add(3);
+ lightWeightSet.add(4);
+ lightWeightSet.add(5);
+ let lightWeightSet1 = new LightWeightSet();
+ lightWeightSet1.add("a1");
+ lightWeightSet1.add("d1");
+ let res = lightWeightSet.hasAll(lightWeightSet1);
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR43_testHasAll027", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add(1);
+ lightWeightSet.add(2);
+ lightWeightSet.add(3);
+ lightWeightSet.add(4);
+ lightWeightSet.add(5);
+ let lightWeightSet1 = new LightWeightSet();
+ lightWeightSet1.add(1);
+ lightWeightSet1.add("d");
+ let res = lightWeightSet.hasAll(lightWeightSet1);
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR43_testRemove028", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ try {
+ let res = lightWeightSet.remove(3);
+ } catch (err) {
+ expect(err).assertEqual("Error: don't find the key in lightweight");
+ }
+ });
+ it("SR000GGR43_testRemoveAt029", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ let res = lightWeightSet.removeAt(1);
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR43_testIncreaseCapacityTo030", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add(1);
+ lightWeightSet.add(2);
+ lightWeightSet.add(3);
+ lightWeightSet.add(4);
+ lightWeightSet.add(5);
+ try {
+ let res = lightWeightSet.increaseCapacityTo(3);
+ } catch (err) {
+ expect(err).assertEqual("Unable to shrink capacity");
+ }
+ });
+ it("SR000GGR43_testIncreaseCapacityTo031", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add(1);
+ lightWeightSet.add(2);
+ lightWeightSet.add(3);
+ lightWeightSet.add(4);
+ lightWeightSet.add(5);
+ try {
+ let res = lightWeightSet.increaseCapacityTo("qwe");
+ } catch (err) {
+ expect(err).assertEqual("lightWeightSet: index must be int");
+ }
+ });
+ it("SR000GGR43_testRemoveAt032", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ try {
+ let res = lightWeightSet.removeAt("123");
+ } catch (err) {
+ expect(err).assertEqual("lightWeightSet: index must be int");
+ }
+ });
+ it("SR000GGR43_testIncreaseCapacityTo033", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add(1);
+ lightWeightSet.add(2);
+ lightWeightSet.add(3);
+ lightWeightSet.add(4);
+ lightWeightSet.add(5);
+ let res = lightWeightSet.increaseCapacityTo(20);
+ expect(res).assertEqual(undefined);
+ });
+ it("SR000GGR43_testGetValueAt034", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add(1);
+ lightWeightSet.add(2);
+ lightWeightSet.add(3);
+ lightWeightSet.add(4);
+ lightWeightSet.add(5);
+ try {
+ let res = lightWeightSet.getValueAt("123");
+ } catch (err) {
+ expect(err).assertEqual("lightWeightSet: index must be int");
+ }
+ });
+ it("SR000GGR43_testIsEmpty035", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add(1);
+ lightWeightSet.add(2);
+ lightWeightSet.add(3);
+ lightWeightSet.add(4);
+ lightWeightSet.add(5);
+ lightWeightSet.clear();
+ let res = lightWeightSet.isEmpty();
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR43_testAdd036", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ for (let i = 0; i < 10000; i++) {
+ lightWeightSet.add(i);
+ }
+ let res = lightWeightSet.getValueAt(9999);
+ let res1 = lightWeightSet.length;
+ expect(res).assertEqual(9999);
+ expect(res1).assertEqual(10000);
+ });
+ it("SR000GGR43_testAdd037", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add("");
+ let res = lightWeightSet.has("");
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR43_testAdd038", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add("$");
+ let res = lightWeightSet.has("$");
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR43_testClear039", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add(1);
+ lightWeightSet.add(2);
+ lightWeightSet.add(3);
+ lightWeightSet.add(4);
+ lightWeightSet.add(5);
+ let res = lightWeightSet.length;
+ lightWeightSet.clear();
+ let res1 = lightWeightSet.length;
+ expect(res).assertEqual(5);
+ expect(res1).assertEqual(0);
+ });
+ it("SR000GGR43_testRemove040", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add(1);
+ lightWeightSet.add(2);
+ lightWeightSet.add(3);
+ lightWeightSet.add(4);
+ lightWeightSet.add(5);
+ try {
+ let res = lightWeightSet.remove("A");
+ } catch (err) {
+ expect(err).assertEqual("Error: don't find the key in lightweight");
+ }
+ });
+ it("SR000GGR43_testIterator41", 0, function () {
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add(1);
+ lightWeightSet.add(2);
+ lightWeightSet.add(3);
+ lightWeightSet.add(4);
+ lightWeightSet.add(5);
+ let arr = [];
+ let res = lightWeightSet[Symbol.iterator]();
+ let temp = undefined;
+ do {
+ temp = res.next().value;
+ arr.push(temp);
+ } while (temp != undefined);
+ let arr1 = [1, 2, 3, 4, 5];
+ for (let i = 0; i < arr1.length; i++) {
+ expect(arr[i]).assertEqual(arr1[i]);
+ }
+ });
+});
diff --git a/compileruntime/containerRelation_lib_standard/src/main/js/test/Main.test.js b/compileruntime/containerRelation_lib_standard/src/main/js/test/Main.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..2303177e73d8cfd10169e4782c2e4e6af5603002
--- /dev/null
+++ b/compileruntime/containerRelation_lib_standard/src/main/js/test/Main.test.js
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+require('./ExampleJsunit.test.js');
+require('./LightWeightMap.test.js');
+require('./LightWeightSet.test.js');
+require('./HashMap.test.js');
+require('./HashSet.test.js');
+require('./PlainArray.test.js');
+require('./TreeMap.test.js');
+require('./TreeSet.test.js');
diff --git a/compileruntime/util_lib_standard/src/main/js/test/PlainArray.test.js b/compileruntime/containerRelation_lib_standard/src/main/js/test/PlainArray.test.js
similarity index 96%
rename from compileruntime/util_lib_standard/src/main/js/test/PlainArray.test.js
rename to compileruntime/containerRelation_lib_standard/src/main/js/test/PlainArray.test.js
index 3a2e411d67675cdfbb072566f5aafd6ea9f65ff2..b68a9e121f77a9fc58ccf49a17f3cbb652f53a2f 100644
--- a/compileruntime/util_lib_standard/src/main/js/test/PlainArray.test.js
+++ b/compileruntime/containerRelation_lib_standard/src/main/js/test/PlainArray.test.js
@@ -1,540 +1,540 @@
-/*
- * Copyright (C) 2021 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 'deccjsunit/index';
-import PlainArray from "@ohos.util.PlainArray";
-
-describe("PlainArrayTest", function () {
- it("SR000GGR45_testConstructor001", 0, function () {
- try {
- let plainArray = new PlainArray();
- } catch (err) {
- expect(err).assertEqual("Error:Cannot create new PlainArray");
- }
- });
- it("SR000GGR45_testAdd002", 0, function () {
- let plainArray = new PlainArray();
- plainArray.add(1, "A");
- let res = plainArray.get(1);
- expect(res).assertEqual("A");
- });
- it("SR000GGR45_testAdd003", 0, function () {
- let plainArray = new PlainArray();
- let a = [1, 2, 3, 4];
- plainArray.add(2, a);
- let res = plainArray.get(2);
- expect(res).assertEqual(a);
- });
- it("SR000GGR45_testAdd004", 0, function () {
- let plainArray = new PlainArray();
- let c = {name: "lili", age: "13"};
- plainArray.add(1, c);
- let res = plainArray.get(1);
- expect(res).assertEqual(c);
- });
- it("SR000GGR45_testAdd005", 0, function () {
- let plainArray = new PlainArray();
- let c = false;
- plainArray.add(1, c);
- let res = plainArray.get(1);
- expect(res).assertEqual(false);
- });
- it("SR000GGR45_testAdd006", 0, function () {
- let plainArray = new PlainArray();
- plainArray.add(1, 3);
- let res = plainArray.get(1);
- expect(res).assertEqual(3);
- });
- it("SR000GGR45_testGet007", 0, function () {
- let plainArray = new PlainArray();
- plainArray.add(1, "A");
- plainArray.add(2, "B");
- plainArray.add(3, "C");
- plainArray.add(4, "D");
- plainArray.add(5, "E");
- let res = plainArray.get(4);
- expect(res).assertEqual("D");
- try {
- res = plainArray.get(10);
- } catch (err) {
- expect(err).assertEqual("Error: Key error found");
- }
- });
- it("SR000GGR45_testLength008", 0, function () {
- let plainArray = new PlainArray();
- let res = plainArray.length;
- expect(res).assertEqual(0);
- plainArray.add(1, "A");
- plainArray.add(2, "B");
- plainArray.add(3, "C");
- plainArray.add(4, "D");
- plainArray.add(5, "E");
- res = plainArray.length;
- expect(res).assertEqual(5);
- });
- it("SR000GGR45_testClone009", 0, function () {
- let plainArray = new PlainArray();
- let clonePlainarray = plainArray.clone();
- let cloneLength = clonePlainarray.length;
- expect(cloneLength).assertEqual(0);
- plainArray.add(1, "A");
- plainArray.add(2, "B");
- plainArray.add(3, "C");
- plainArray.add(4, "D");
- plainArray.add(5, "E");
- let res = plainArray.clone();
- let arr = [];
- res.forEach((value, index) => {
- arr.push(value);
- });
- let arr1 = ["A", "B", "C", "D", "E"];
- for (let i = 0; i < arr.length; i++) {
- expect(arr[i]).assertEqual(arr1[i]);
- }
- });
- it("SR000GGR45_testClear010", 0, function () {
- let plainArray = new PlainArray();
- plainArray.add(1, "A");
- plainArray.add(2, "B");
- plainArray.add(3, "C");
- plainArray.add(4, "D");
- plainArray.add(5, "E");
- let res = plainArray.length;
- expect(res).assertEqual(5);
- plainArray.clear();
- let res1 = plainArray.length;
- expect(res1).assertEqual(0);
- plainArray.clear();
- let res2 = plainArray.length;
- expect(res2).assertEqual(0);
- });
- it("SR000GGR45_testHas011", 0, function () {
- let plainArray = new PlainArray();
- plainArray.add(1, "A");
- plainArray.add(2, "B");
- plainArray.add(3, "C");
- plainArray.add(4, "D");
- plainArray.add(5, "E");
- let res = plainArray.has("a");
- expect(res).assertEqual(false);
- let res1 = plainArray.has(1);
- expect(res1).assertEqual(true);
- });
- it("SR000GGR45_testGetIndexOfKey012", 0, function () {
- let plainArray = new PlainArray();
- plainArray.add(1, "A");
- plainArray.add(2, "B");
- plainArray.add(3, "C");
- plainArray.add(4, "D");
- plainArray.add(5, "E");
- let res = plainArray.getIndexOfKey(2);
- expect(res).assertEqual(1);
- res = plainArray.getIndexOfKey(12);
- expect(res).assertEqual(-1);
- });
- it("SR000GGR45_testGetIndexOfValue013", 0, function () {
- let plainArray = new PlainArray();
- plainArray.add(1, "A");
- plainArray.add(2, "B");
- plainArray.add(3, "C");
- plainArray.add(4, "D");
- plainArray.add(5, "E");
- let res = plainArray.getIndexOfValue("A");
- expect(res).assertEqual(0);
- res = plainArray.getIndexOfValue("Z");
- expect(res).assertEqual(-1);
- });
- it("SR000GGR45_testIsEmpty014", 0, function () {
- let plainArray = new PlainArray();
- let result = plainArray.length;
- expect(result).assertEqual(0);
- plainArray.add(1, "A");
- plainArray.add(2, "B");
- plainArray.add(3, "C");
- plainArray.add(4, "D");
- plainArray.add(5, "E");
- let res = plainArray.isEmpty();
- expect(res).assertEqual(false);
- });
- it("SR000GGR45_testGetKeyAt015", 0, function () {
- let plainArray = new PlainArray();
- plainArray.add(1, "A");
- plainArray.add(2, "B");
- plainArray.add(3, "C");
- plainArray.add(4, "D");
- plainArray.add(5, "E");
- let res = plainArray.getKeyAt(2);
- expect(res).assertEqual(3);
- res = plainArray.getKeyAt(10);
- expect(res).assertEqual(undefined);
- });
- it("SR000GGR45_testReMove016", 0, function () {
- let plainArray = new PlainArray();
- plainArray.add(1, "A");
- plainArray.add(2, "B");
- plainArray.add(3, "C");
- plainArray.add(4, "D");
- plainArray.add(5, "E");
- let res = plainArray.remove(2);
- expect(res).assertEqual("B");
- try {
- res = plainArray.remove(12);
- } catch (err) {
- expect(err).assertEqual("Error: element not in this plainarray");
- }
- let arr = [];
- for (let item of plainArray) {
- arr.push(item);
- }
- let arr1 = ["1,A", "3,C", "4,D", "5,E"];
- for (let i = 0; i < arr.length; i++) {
- expect(arr[i]).assertEqual(arr1[i]);
- }
- });
- it("SR000GGR45_testReMoveAt017", 0, function () {
- let plainArray = new PlainArray();
- plainArray.add(1, "A");
- plainArray.add(2, "B");
- plainArray.add(3, "C");
- plainArray.add(4, "D");
- plainArray.add(5, "E");
- let res = plainArray.removeAt(2);
- expect(res).assertEqual("C");
- try {
- res = plainArray.removeAt(12);
- } catch (err) {
- expect(err).assertEqual("Error: index not in this plainarray range");
- }
- let arr = [];
- for (let item of plainArray) {
- arr.push(item);
- }
- let arr1 = ["1,A", "2,B", "4,D", "5,E"];
- for (let i = 0; i < arr.length; i++) {
- expect(arr[i]).assertEqual(arr1[i]);
- }
- });
- it("SR000GGR45_testReMoveRangeFrom018", 0, function () {
- let plainArray = new PlainArray();
- plainArray.add(1, "A");
- plainArray.add(2, "B");
- plainArray.add(3, "C");
- plainArray.add(4, "D");
- plainArray.add(5, "E");
- plainArray.removeRangeFrom(2, 2);
- let arr = [];
- for (let item of plainArray) {
- arr.push(item);
- }
- let arr1 = ["1,A", "2,B", "5,E"];
- for (let i = 0; i < arr.length; i++) {
- expect(arr[i]).assertEqual(arr1[i]);
- }
- try {
- plainArray.removeRangeFrom(15, 5);
- } catch (err) {
- expect(err).assertEqual("Error: index not in this plainarray range");
- }
- try {
- plainArray.removeRangeFrom(1, -1);
- } catch (err) {
- expect(err).assertEqual("index not in this plainarray range");
- }
- });
- it("SR000GGR45_testSetValueAt019", 0, function () {
- let plainArray = new PlainArray();
- plainArray.add(1, "A");
- plainArray.add(2, "B");
- plainArray.add(3, "C");
- plainArray.add(4, "D");
- plainArray.add(5, "E");
- plainArray.setValueAt(2, "V");
- let arr = [];
- for (let item of plainArray) {
- arr.push(item);
- }
- let arr1 = ["1,A", "2,B", "3,V", "4,D", "5,E"];
- for (let i = 0; i < arr.length; i++) {
- expect(arr[i]).assertEqual(arr1[i]);
- }
- try {
- plainArray.setValueAt(-1, "X");
- } catch (err) {
- expect(err).assertEqual("Error: index Out Of Bounds");
- }
- });
- it("SR000GGR45_testToString020", 0, function () {
- let plainArray = new PlainArray();
- let res1 = plainArray.toString();
- expect(res1).assertEqual("");
- plainArray.add(1, "A");
- plainArray.add(2, "B");
- plainArray.add(3, "C");
- let res = plainArray.toString();
- expect(res).assertEqual("1:A,2:B,3:C");
- });
- it("SR000GGR45_testForEach021", 0, function () {
- let plainArray = new PlainArray();
- plainArray.add(1, "A");
- plainArray.add(2, "B");
- plainArray.add(3, "C");
- plainArray.add(4, "D");
- plainArray.add(5, "E");
- let arr = [];
- let keyArr = [];
- plainArray.forEach((key, index) => {
- keyArr.push(key);
- });
- plainArray.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]);
- }
- let keyArr1 = [1, 2, 3, 4, 5];
- for (let i = 0; i < keyArr1.length; i++) {
- expect(keyArr[i]).assertEqual(keyArr[i]);
- }
- });
- it("SR000GGR45_testIterator022", 0, function () {
- let plainArray = new PlainArray();
- plainArray.add(1, "A");
- plainArray.add(2, "B");
- plainArray.add(3, "C");
- plainArray.add(4, "D");
- plainArray.add(5, "E");
- let arr = [];
- for (let item of plainArray) {
- arr.push(item);
- }
- let arr1 = ["1,A", "2,B", "3,C", "4,D", "5,E"];
- for (let i = 0; i < arr1.length; i++) {
- expect(arr[i]).assertEqual(arr1[i]);
- }
- });
- it("SR000GGR45_testGetValueAt023", 0, function () {
- let plainArray = new PlainArray();
- plainArray.add(1, "A");
- plainArray.add(2, "B");
- plainArray.add(3, "C");
- plainArray.add(4, "D");
- plainArray.add(5, "E");
- let res = plainArray.getValueAt(2);
- expect(res).assertEqual("C");
- res = plainArray.getValueAt(12);
- expect(res).assertEqual(undefined);
- });
- it("SR000GGR45_testAdd024", 0, function () {
- let plainArray = new PlainArray();
- plainArray.add(1, 3.1);
- let res = plainArray.get(1);
- expect(res).assertEqual(3.1);
- });
- it("SR000GGR45_testAdd024", 0, function () {
- let plainArray = new PlainArray();
- plainArray.add(1, null);
- let res = plainArray.get(1);
- expect(res).assertEqual(null);
- });
- it("SR000GGR45_testAdd025", 0, function () {
- let plainArray = new PlainArray();
- try {
- let res = plainArray.add("123", null);
- } catch (err) {
- expect(err).assertEqual("Error: PlainArray's only number is allowed");
- }
- });
- it("SR000GGR45_testGet026", 0, function () {
- let plainArray = new PlainArray();
- plainArray.add(1, "A");
- plainArray.add(2, "B");
- plainArray.add(3, "C");
- plainArray.add(4, "D");
- plainArray.add(5, "E");
- try {
- let res = plainArray.get(8);
- } catch (err) {
- expect(err).assertEqual("Error: Key error found");
- }
- });
- it("SR000GGR45_testGetIndexOfKey027", 0, function () {
- let plainArray = new PlainArray();
- plainArray.add(1, "A");
- plainArray.add(2, "B");
- plainArray.add(3, "C");
- plainArray.add(4, "D");
- plainArray.add(5, "E");
- let res = plainArray.getIndexOfKey(9);
- expect(res).assertEqual(-1);
- });
- it("SR000GGR45_testGetIndexOfValue028", 0, function () {
- let plainArray = new PlainArray();
- plainArray.add(1, "A");
- plainArray.add(2, "B");
- plainArray.add(3, "C");
- plainArray.add(4, "D");
- plainArray.add(5, "E");
- let res = plainArray.getIndexOfValue("Asad");
- expect(res).assertEqual(-1);
- });
- it("SR000GGR45_testGetKeyAt029", 0, function () {
- let plainArray = new PlainArray();
- plainArray.add(1, "A");
- plainArray.add(2, "B");
- plainArray.add(3, "C");
- plainArray.add(4, "D");
- plainArray.add(5, "E");
- let res = plainArray.getKeyAt(50);
- expect(res).assertEqual(null);
- });
- it("SR000GGR45_testGetValueAt030", 0, function () {
- let plainArray = new PlainArray();
- plainArray.add(1, "A");
- plainArray.add(2, "B");
- plainArray.add(3, "C");
- plainArray.add(4, "D");
- plainArray.add(5, "E");
- let res = plainArray.getValueAt(50);
- expect(res).assertEqual(null);
- });
- it("SR000GGR45_testRemove031", 0, function () {
- let plainArray = new PlainArray();
- try {
- let res = plainArray.remove(2);
- } catch (err) {
- expect(err).assertEqual("Error: element not in this plainarray");
- }
- });
- it("SR000GGR45_testRemoveAt032", 0, function () {
- let plainArray = new PlainArray();
- try {
- let res = plainArray.removeAt(2);
- } catch (err) {
- expect(err).assertEqual("Error: index not in this plainarray range");
- }
- });
- it("SR000GGR45_testReMoveRangeFrom033", 0, function () {
- let plainArray = new PlainArray();
- plainArray.add(1, "A");
- plainArray.add(2, "B");
- plainArray.add(3, "C");
- plainArray.add(4, "D");
- plainArray.add(5, "E");
- plainArray.removeRangeFrom(0, 5);
- let res = plainArray.length;
- expect(res).assertEqual(0);
- });
- it("SR000GGR45_testSetValueAt034", 0, function () {
- let plainArray = new PlainArray();
- plainArray.add(1, "A");
- plainArray.add(2, "B");
- plainArray.add(3, "C");
- plainArray.add(4, "D");
- plainArray.add(5, "E");
- try {
- plainArray.setValueAt(8, "V");
- } catch (err) {
- expect(err).assertEqual("Error: index Out Of Bounds");
- }
- });
- it("SR000GGR45_testAdd035", 0, function () {
- let plainArray = new PlainArray();
- for (let i = 0; i < 100; i++) {
- plainArray.add(i, i + 1);
- }
- let res = plainArray.get(1);
- let res1 = plainArray.length;
- expect(res).assertEqual(2);
- expect(res1).assertEqual(100);
- });
- it("SR000GGR45_testAdd036", 0, function () {
- let plainArray = new PlainArray();
- for (let i = 0; i < 1000; i++) {
- plainArray.add(i, i + 1);
- }
- let res = plainArray.get(99);
- let res1 = plainArray.length;
- expect(res).assertEqual(100);
- expect(res1).assertEqual(1000);
- });
- it("SR000GGR45_testAdd037", 0, function () {
- let plainArray = new PlainArray();
- plainArray.add(3, "a");
- plainArray.add(1, "b");
- plainArray.add(2, "c");
- plainArray.add(5, "d");
- plainArray.add(4, "e");
- let res = plainArray.get(2);
- expect(res).assertEqual("c");
- });
- it("SR000GGR45_testAdd038", 0, function () {
- let plainArray = new PlainArray();
- plainArray.add(1, "ABCd");
- plainArray.add(2, "~!@#$^&*()_+-*/=.?<>:;|{}[]");
- plainArray.add(3, null);
- plainArray.add(4, undefined);
- plainArray.add(5, []);
- plainArray.add(6, {});
- plainArray.add(7, true);
- plainArray.add(8, 1234);
- plainArray.add(9, 1.234);
- plainArray.add(10, -1234);
- let res = plainArray.get(2);
- expect(res).assertEqual("~!@#$^&*()_+-*/=.?<>:;|{}[]");
- });
- it("SR000GGR45_testAdd039", 0, function () {
- let plainArray = new PlainArray();
- plainArray.add(1.23, "a");
- plainArray.add(-2, "b");
- try {
- plainArray.add("a", "c");
- } catch (err) {
- expect(err).assertEqual("Error: PlainArray's only number is allowed");
- }
- let res = plainArray.get(-2);
- expect(res).assertEqual("b");
- });
- it("SR000GGR45_testAdd040", 0, function () {
- let plainArray = new PlainArray();
- plainArray.add(1, 1);
- plainArray.add(2, "b");
- plainArray.add(3, true);
- plainArray.add(4, [1, 2, 3, 4]);
- plainArray.add(5, { name: "lili", age: "13" });
- plainArray.add(6, undefined);
- plainArray.add(7, null);
- let res = plainArray.get(2);
- expect(res).assertEqual("b");
- });
- it("SR000GGR45_testIterator041", 0, function () {
- let plainArray = new PlainArray();
- plainArray.add(1, "A");
- plainArray.add(2, "B");
- plainArray.add(3, "C");
- plainArray.add(4, "D");
- plainArray.add(5, "E");
- let arr = [];
- let res = plainArray[Symbol.iterator]();
- let temp = undefined;
- do {
- temp = res.next().value;
- arr.push(temp);
- } while (temp != undefined);
- let arr1 = ["1,A", "2,B", "3,C", "4,D", "5,E"];
- for (let i = 0; i < arr1.length; i++) {
- expect(arr[i]).assertEqual(arr1[i]);
- }
- });
-});
+/*
+ * Copyright (C) 2021 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 'deccjsunit/index';
+import PlainArray from "@ohos.util.PlainArray";
+
+describe("PlainArrayTest", function () {
+ it("SR000GGR45_testConstructor001", 0, function () {
+ try {
+ let plainArray = new PlainArray();
+ } catch (err) {
+ expect(err).assertEqual("Error:Cannot create new PlainArray");
+ }
+ });
+ it("SR000GGR45_testAdd002", 0, function () {
+ let plainArray = new PlainArray();
+ plainArray.add(1, "A");
+ let res = plainArray.get(1);
+ expect(res).assertEqual("A");
+ });
+ it("SR000GGR45_testAdd003", 0, function () {
+ let plainArray = new PlainArray();
+ let a = [1, 2, 3, 4];
+ plainArray.add(2, a);
+ let res = plainArray.get(2);
+ expect(res).assertEqual(a);
+ });
+ it("SR000GGR45_testAdd004", 0, function () {
+ let plainArray = new PlainArray();
+ let c = {name: "lili", age: "13"};
+ plainArray.add(1, c);
+ let res = plainArray.get(1);
+ expect(res).assertEqual(c);
+ });
+ it("SR000GGR45_testAdd005", 0, function () {
+ let plainArray = new PlainArray();
+ let c = false;
+ plainArray.add(1, c);
+ let res = plainArray.get(1);
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR45_testAdd006", 0, function () {
+ let plainArray = new PlainArray();
+ plainArray.add(1, 3);
+ let res = plainArray.get(1);
+ expect(res).assertEqual(3);
+ });
+ it("SR000GGR45_testGet007", 0, function () {
+ let plainArray = new PlainArray();
+ plainArray.add(1, "A");
+ plainArray.add(2, "B");
+ plainArray.add(3, "C");
+ plainArray.add(4, "D");
+ plainArray.add(5, "E");
+ let res = plainArray.get(4);
+ expect(res).assertEqual("D");
+ try {
+ res = plainArray.get(10);
+ } catch (err) {
+ expect(err).assertEqual("Error: Key error found");
+ }
+ });
+ it("SR000GGR45_testLength008", 0, function () {
+ let plainArray = new PlainArray();
+ let res = plainArray.length;
+ expect(res).assertEqual(0);
+ plainArray.add(1, "A");
+ plainArray.add(2, "B");
+ plainArray.add(3, "C");
+ plainArray.add(4, "D");
+ plainArray.add(5, "E");
+ res = plainArray.length;
+ expect(res).assertEqual(5);
+ });
+ it("SR000GGR45_testClone009", 0, function () {
+ let plainArray = new PlainArray();
+ let clonePlainarray = plainArray.clone();
+ let cloneLength = clonePlainarray.length;
+ expect(cloneLength).assertEqual(0);
+ plainArray.add(1, "A");
+ plainArray.add(2, "B");
+ plainArray.add(3, "C");
+ plainArray.add(4, "D");
+ plainArray.add(5, "E");
+ let res = plainArray.clone();
+ let arr = [];
+ res.forEach((value, index) => {
+ arr.push(value);
+ });
+ let arr1 = ["A", "B", "C", "D", "E"];
+ for (let i = 0; i < arr.length; i++) {
+ expect(arr[i]).assertEqual(arr1[i]);
+ }
+ });
+ it("SR000GGR45_testClear010", 0, function () {
+ let plainArray = new PlainArray();
+ plainArray.add(1, "A");
+ plainArray.add(2, "B");
+ plainArray.add(3, "C");
+ plainArray.add(4, "D");
+ plainArray.add(5, "E");
+ let res = plainArray.length;
+ expect(res).assertEqual(5);
+ plainArray.clear();
+ let res1 = plainArray.length;
+ expect(res1).assertEqual(0);
+ plainArray.clear();
+ let res2 = plainArray.length;
+ expect(res2).assertEqual(0);
+ });
+ it("SR000GGR45_testHas011", 0, function () {
+ let plainArray = new PlainArray();
+ plainArray.add(1, "A");
+ plainArray.add(2, "B");
+ plainArray.add(3, "C");
+ plainArray.add(4, "D");
+ plainArray.add(5, "E");
+ let res = plainArray.has("a");
+ expect(res).assertEqual(false);
+ let res1 = plainArray.has(1);
+ expect(res1).assertEqual(true);
+ });
+ it("SR000GGR45_testGetIndexOfKey012", 0, function () {
+ let plainArray = new PlainArray();
+ plainArray.add(1, "A");
+ plainArray.add(2, "B");
+ plainArray.add(3, "C");
+ plainArray.add(4, "D");
+ plainArray.add(5, "E");
+ let res = plainArray.getIndexOfKey(2);
+ expect(res).assertEqual(1);
+ res = plainArray.getIndexOfKey(12);
+ expect(res).assertEqual(-1);
+ });
+ it("SR000GGR45_testGetIndexOfValue013", 0, function () {
+ let plainArray = new PlainArray();
+ plainArray.add(1, "A");
+ plainArray.add(2, "B");
+ plainArray.add(3, "C");
+ plainArray.add(4, "D");
+ plainArray.add(5, "E");
+ let res = plainArray.getIndexOfValue("A");
+ expect(res).assertEqual(0);
+ res = plainArray.getIndexOfValue("Z");
+ expect(res).assertEqual(-1);
+ });
+ it("SR000GGR45_testIsEmpty014", 0, function () {
+ let plainArray = new PlainArray();
+ let result = plainArray.length;
+ expect(result).assertEqual(0);
+ plainArray.add(1, "A");
+ plainArray.add(2, "B");
+ plainArray.add(3, "C");
+ plainArray.add(4, "D");
+ plainArray.add(5, "E");
+ let res = plainArray.isEmpty();
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR45_testGetKeyAt015", 0, function () {
+ let plainArray = new PlainArray();
+ plainArray.add(1, "A");
+ plainArray.add(2, "B");
+ plainArray.add(3, "C");
+ plainArray.add(4, "D");
+ plainArray.add(5, "E");
+ let res = plainArray.getKeyAt(2);
+ expect(res).assertEqual(3);
+ res = plainArray.getKeyAt(10);
+ expect(res).assertEqual(undefined);
+ });
+ it("SR000GGR45_testReMove016", 0, function () {
+ let plainArray = new PlainArray();
+ plainArray.add(1, "A");
+ plainArray.add(2, "B");
+ plainArray.add(3, "C");
+ plainArray.add(4, "D");
+ plainArray.add(5, "E");
+ let res = plainArray.remove(2);
+ expect(res).assertEqual("B");
+ try {
+ res = plainArray.remove(12);
+ } catch (err) {
+ expect(err).assertEqual("Error: element not in this plainarray");
+ }
+ let arr = [];
+ for (let item of plainArray) {
+ arr.push(item);
+ }
+ let arr1 = ["1,A", "3,C", "4,D", "5,E"];
+ for (let i = 0; i < arr.length; i++) {
+ expect(arr[i]).assertEqual(arr1[i]);
+ }
+ });
+ it("SR000GGR45_testReMoveAt017", 0, function () {
+ let plainArray = new PlainArray();
+ plainArray.add(1, "A");
+ plainArray.add(2, "B");
+ plainArray.add(3, "C");
+ plainArray.add(4, "D");
+ plainArray.add(5, "E");
+ let res = plainArray.removeAt(2);
+ expect(res).assertEqual("C");
+ try {
+ res = plainArray.removeAt(12);
+ } catch (err) {
+ expect(err).assertEqual("Error: index not in this plainarray range");
+ }
+ let arr = [];
+ for (let item of plainArray) {
+ arr.push(item);
+ }
+ let arr1 = ["1,A", "2,B", "4,D", "5,E"];
+ for (let i = 0; i < arr.length; i++) {
+ expect(arr[i]).assertEqual(arr1[i]);
+ }
+ });
+ it("SR000GGR45_testReMoveRangeFrom018", 0, function () {
+ let plainArray = new PlainArray();
+ plainArray.add(1, "A");
+ plainArray.add(2, "B");
+ plainArray.add(3, "C");
+ plainArray.add(4, "D");
+ plainArray.add(5, "E");
+ plainArray.removeRangeFrom(2, 2);
+ let arr = [];
+ for (let item of plainArray) {
+ arr.push(item);
+ }
+ let arr1 = ["1,A", "2,B", "5,E"];
+ for (let i = 0; i < arr.length; i++) {
+ expect(arr[i]).assertEqual(arr1[i]);
+ }
+ try {
+ plainArray.removeRangeFrom(15, 5);
+ } catch (err) {
+ expect(err).assertEqual("Error: index not in this plainarray range");
+ }
+ try {
+ plainArray.removeRangeFrom(1, -1);
+ } catch (err) {
+ expect(err).assertEqual("index not in this plainarray range");
+ }
+ });
+ it("SR000GGR45_testSetValueAt019", 0, function () {
+ let plainArray = new PlainArray();
+ plainArray.add(1, "A");
+ plainArray.add(2, "B");
+ plainArray.add(3, "C");
+ plainArray.add(4, "D");
+ plainArray.add(5, "E");
+ plainArray.setValueAt(2, "V");
+ let arr = [];
+ for (let item of plainArray) {
+ arr.push(item);
+ }
+ let arr1 = ["1,A", "2,B", "3,V", "4,D", "5,E"];
+ for (let i = 0; i < arr.length; i++) {
+ expect(arr[i]).assertEqual(arr1[i]);
+ }
+ try {
+ plainArray.setValueAt(-1, "X");
+ } catch (err) {
+ expect(err).assertEqual("Error: index Out Of Bounds");
+ }
+ });
+ it("SR000GGR45_testToString020", 0, function () {
+ let plainArray = new PlainArray();
+ let res1 = plainArray.toString();
+ expect(res1).assertEqual("");
+ plainArray.add(1, "A");
+ plainArray.add(2, "B");
+ plainArray.add(3, "C");
+ let res = plainArray.toString();
+ expect(res).assertEqual("1:A,2:B,3:C");
+ });
+ it("SR000GGR45_testForEach021", 0, function () {
+ let plainArray = new PlainArray();
+ plainArray.add(1, "A");
+ plainArray.add(2, "B");
+ plainArray.add(3, "C");
+ plainArray.add(4, "D");
+ plainArray.add(5, "E");
+ let arr = [];
+ let keyArr = [];
+ plainArray.forEach((key, index) => {
+ keyArr.push(key);
+ });
+ plainArray.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]);
+ }
+ let keyArr1 = [1, 2, 3, 4, 5];
+ for (let i = 0; i < keyArr1.length; i++) {
+ expect(keyArr[i]).assertEqual(keyArr[i]);
+ }
+ });
+ it("SR000GGR45_testIterator022", 0, function () {
+ let plainArray = new PlainArray();
+ plainArray.add(1, "A");
+ plainArray.add(2, "B");
+ plainArray.add(3, "C");
+ plainArray.add(4, "D");
+ plainArray.add(5, "E");
+ let arr = [];
+ for (let item of plainArray) {
+ arr.push(item);
+ }
+ let arr1 = ["1,A", "2,B", "3,C", "4,D", "5,E"];
+ for (let i = 0; i < arr1.length; i++) {
+ expect(arr[i]).assertEqual(arr1[i]);
+ }
+ });
+ it("SR000GGR45_testGetValueAt023", 0, function () {
+ let plainArray = new PlainArray();
+ plainArray.add(1, "A");
+ plainArray.add(2, "B");
+ plainArray.add(3, "C");
+ plainArray.add(4, "D");
+ plainArray.add(5, "E");
+ let res = plainArray.getValueAt(2);
+ expect(res).assertEqual("C");
+ res = plainArray.getValueAt(12);
+ expect(res).assertEqual(undefined);
+ });
+ it("SR000GGR45_testAdd024", 0, function () {
+ let plainArray = new PlainArray();
+ plainArray.add(1, 3.1);
+ let res = plainArray.get(1);
+ expect(res).assertEqual(3.1);
+ });
+ it("SR000GGR45_testAdd024", 0, function () {
+ let plainArray = new PlainArray();
+ plainArray.add(1, null);
+ let res = plainArray.get(1);
+ expect(res).assertEqual(null);
+ });
+ it("SR000GGR45_testAdd025", 0, function () {
+ let plainArray = new PlainArray();
+ try {
+ let res = plainArray.add("123", null);
+ } catch (err) {
+ expect(err).assertEqual("Error: PlainArray's only number is allowed");
+ }
+ });
+ it("SR000GGR45_testGet026", 0, function () {
+ let plainArray = new PlainArray();
+ plainArray.add(1, "A");
+ plainArray.add(2, "B");
+ plainArray.add(3, "C");
+ plainArray.add(4, "D");
+ plainArray.add(5, "E");
+ try {
+ let res = plainArray.get(8);
+ } catch (err) {
+ expect(err).assertEqual("Error: Key error found");
+ }
+ });
+ it("SR000GGR45_testGetIndexOfKey027", 0, function () {
+ let plainArray = new PlainArray();
+ plainArray.add(1, "A");
+ plainArray.add(2, "B");
+ plainArray.add(3, "C");
+ plainArray.add(4, "D");
+ plainArray.add(5, "E");
+ let res = plainArray.getIndexOfKey(9);
+ expect(res).assertEqual(-1);
+ });
+ it("SR000GGR45_testGetIndexOfValue028", 0, function () {
+ let plainArray = new PlainArray();
+ plainArray.add(1, "A");
+ plainArray.add(2, "B");
+ plainArray.add(3, "C");
+ plainArray.add(4, "D");
+ plainArray.add(5, "E");
+ let res = plainArray.getIndexOfValue("Asad");
+ expect(res).assertEqual(-1);
+ });
+ it("SR000GGR45_testGetKeyAt029", 0, function () {
+ let plainArray = new PlainArray();
+ plainArray.add(1, "A");
+ plainArray.add(2, "B");
+ plainArray.add(3, "C");
+ plainArray.add(4, "D");
+ plainArray.add(5, "E");
+ let res = plainArray.getKeyAt(50);
+ expect(res).assertEqual(null);
+ });
+ it("SR000GGR45_testGetValueAt030", 0, function () {
+ let plainArray = new PlainArray();
+ plainArray.add(1, "A");
+ plainArray.add(2, "B");
+ plainArray.add(3, "C");
+ plainArray.add(4, "D");
+ plainArray.add(5, "E");
+ let res = plainArray.getValueAt(50);
+ expect(res).assertEqual(null);
+ });
+ it("SR000GGR45_testRemove031", 0, function () {
+ let plainArray = new PlainArray();
+ try {
+ let res = plainArray.remove(2);
+ } catch (err) {
+ expect(err).assertEqual("Error: element not in this plainarray");
+ }
+ });
+ it("SR000GGR45_testRemoveAt032", 0, function () {
+ let plainArray = new PlainArray();
+ try {
+ let res = plainArray.removeAt(2);
+ } catch (err) {
+ expect(err).assertEqual("Error: index not in this plainarray range");
+ }
+ });
+ it("SR000GGR45_testReMoveRangeFrom033", 0, function () {
+ let plainArray = new PlainArray();
+ plainArray.add(1, "A");
+ plainArray.add(2, "B");
+ plainArray.add(3, "C");
+ plainArray.add(4, "D");
+ plainArray.add(5, "E");
+ plainArray.removeRangeFrom(0, 5);
+ let res = plainArray.length;
+ expect(res).assertEqual(0);
+ });
+ it("SR000GGR45_testSetValueAt034", 0, function () {
+ let plainArray = new PlainArray();
+ plainArray.add(1, "A");
+ plainArray.add(2, "B");
+ plainArray.add(3, "C");
+ plainArray.add(4, "D");
+ plainArray.add(5, "E");
+ try {
+ plainArray.setValueAt(8, "V");
+ } catch (err) {
+ expect(err).assertEqual("Error: index Out Of Bounds");
+ }
+ });
+ it("SR000GGR45_testAdd035", 0, function () {
+ let plainArray = new PlainArray();
+ for (let i = 0; i < 100; i++) {
+ plainArray.add(i, i + 1);
+ }
+ let res = plainArray.get(1);
+ let res1 = plainArray.length;
+ expect(res).assertEqual(2);
+ expect(res1).assertEqual(100);
+ });
+ it("SR000GGR45_testAdd036", 0, function () {
+ let plainArray = new PlainArray();
+ for (let i = 0; i < 1000; i++) {
+ plainArray.add(i, i + 1);
+ }
+ let res = plainArray.get(99);
+ let res1 = plainArray.length;
+ expect(res).assertEqual(100);
+ expect(res1).assertEqual(1000);
+ });
+ it("SR000GGR45_testAdd037", 0, function () {
+ let plainArray = new PlainArray();
+ plainArray.add(3, "a");
+ plainArray.add(1, "b");
+ plainArray.add(2, "c");
+ plainArray.add(5, "d");
+ plainArray.add(4, "e");
+ let res = plainArray.get(2);
+ expect(res).assertEqual("c");
+ });
+ it("SR000GGR45_testAdd038", 0, function () {
+ let plainArray = new PlainArray();
+ plainArray.add(1, "ABCd");
+ plainArray.add(2, "~!@#$^&*()_+-*/=.?<>:;|{}[]");
+ plainArray.add(3, null);
+ plainArray.add(4, undefined);
+ plainArray.add(5, []);
+ plainArray.add(6, {});
+ plainArray.add(7, true);
+ plainArray.add(8, 1234);
+ plainArray.add(9, 1.234);
+ plainArray.add(10, -1234);
+ let res = plainArray.get(2);
+ expect(res).assertEqual("~!@#$^&*()_+-*/=.?<>:;|{}[]");
+ });
+ it("SR000GGR45_testAdd039", 0, function () {
+ let plainArray = new PlainArray();
+ plainArray.add(1.23, "a");
+ plainArray.add(-2, "b");
+ try {
+ plainArray.add("a", "c");
+ } catch (err) {
+ expect(err).assertEqual("Error: PlainArray's only number is allowed");
+ }
+ let res = plainArray.get(-2);
+ expect(res).assertEqual("b");
+ });
+ it("SR000GGR45_testAdd040", 0, function () {
+ let plainArray = new PlainArray();
+ plainArray.add(1, 1);
+ plainArray.add(2, "b");
+ plainArray.add(3, true);
+ plainArray.add(4, [1, 2, 3, 4]);
+ plainArray.add(5, { name: "lili", age: "13" });
+ plainArray.add(6, undefined);
+ plainArray.add(7, null);
+ let res = plainArray.get(2);
+ expect(res).assertEqual("b");
+ });
+ it("SR000GGR45_testIterator041", 0, function () {
+ let plainArray = new PlainArray();
+ plainArray.add(1, "A");
+ plainArray.add(2, "B");
+ plainArray.add(3, "C");
+ plainArray.add(4, "D");
+ plainArray.add(5, "E");
+ let arr = [];
+ let res = plainArray[Symbol.iterator]();
+ let temp = undefined;
+ do {
+ temp = res.next().value;
+ arr.push(temp);
+ } while (temp != undefined);
+ let arr1 = ["1,A", "2,B", "3,C", "4,D", "5,E"];
+ for (let i = 0; i < arr1.length; i++) {
+ expect(arr[i]).assertEqual(arr1[i]);
+ }
+ });
+});
diff --git a/compileruntime/util_lib_standard/src/main/js/test/TreeMap.test.js b/compileruntime/containerRelation_lib_standard/src/main/js/test/TreeMap.test.js
similarity index 96%
rename from compileruntime/util_lib_standard/src/main/js/test/TreeMap.test.js
rename to compileruntime/containerRelation_lib_standard/src/main/js/test/TreeMap.test.js
index ad32e5e4075931604375f28d9a0cee5e8a7ec31b..79a76b95e53ffc76f55befb5b4abed645ff0bc6f 100644
--- a/compileruntime/util_lib_standard/src/main/js/test/TreeMap.test.js
+++ b/compileruntime/containerRelation_lib_standard/src/main/js/test/TreeMap.test.js
@@ -1,397 +1,397 @@
-/*
- * Copyright (C) 2021 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 'deccjsunit/index';
-import TreeMap from "@ohos.util.TreeMap";
-
-describe("TreeMapTest", function () {
- it("SR000GGR3H_testConstructor001", 0, function () {
- try {
- let treeMap = new TreeMap();
- expect(treeMap != undefined).assertEqual(true);
- } catch (err) {
- expect(err).assertEqual("Error: Cannot create new TreeMap");
- }
- });
- it("SR000GGR3H_testSet002_1", 0, function () {
- let treeMap = new TreeMap();
- treeMap.set(0, "四");
- let res = treeMap.get(0);
- expect(res).assertEqual("四");
- });
- it("SR000GGR3H_testSet002_2", 0, function () {
- let treeMap = new TreeMap();
- treeMap.set(0, 8);
- let res = treeMap.get(0);
- expect(res).assertEqual(8);
- });
- it("SR000GGR3H_testSet002_3", 0, function () {
- let treeMap = new TreeMap();
- let a = [1, 2, 3, 4];
- treeMap.set(0, a);
- let res = treeMap.get(0);
- expect(res).assertEqual(a);
- });
- it("SR000GGR3H_testSet002_4", 0, function () {
- let treeMap = new TreeMap();
- let a = {name: "lala", age: "13"};
- treeMap.set(0, a);
- let res = treeMap.get(0);
- expect(res).assertEqual(a);
- });
- it("SR000GGR3H_testSet002_5", 0, function () {
- let treeMap = new TreeMap();
- treeMap.set(2, "*");
- let res = treeMap.get(2);
- expect(res).assertEqual("*");
- });
- it("SR000GGR3H_testSet002_6", 0, function () {
- let treeMap = new TreeMap();
- treeMap.set(-2, 3.14);
- let res = treeMap.get(-2);
- expect(res).assertEqual(3.14);
- });
- it("SR000GGR3H_testSet002_7", 0, function () {
- let treeMap = new TreeMap();
- treeMap.set(100, true);
- let res = treeMap.get(100);
- expect(res).assertEqual(true);
- });
- it("SR000GGR3H_testSet002_8", 0, function () {
- let treeMap = new TreeMap();
- treeMap.set(100, "");
- let res = treeMap.get(100);
- expect(res).assertEqual("");
- });
- it("SR000GGR3H_testSet002_9", 0, function () {
- let treeMap = new TreeMap();
- treeMap.set("a", "四");
- let res = treeMap.get("a");
- expect(res).assertEqual("四");
- });
- it("SR000GGR3H_testSet002_10", 0, function () {
- let treeMap = new TreeMap();
- for (let i = 0; i < 10000; i++) {
- treeMap.set(0, 8);
- }
- let res = treeMap.get(0);
- expect(res).assertEqual(8);
- expect(treeMap.length).assertEqual(1);
- });
- it("SR000GGR3H_testHasKey003", 0, function () {
- let treeMap = new TreeMap();
- treeMap.set(0, "a");
- treeMap.set(1, "b");
- let res = treeMap.hasKey(1);
- expect(res).assertEqual(true);
- let res1 = treeMap.hasKey(6);
- expect(res1).assertEqual(false);
- });
- it("SR000GGR3H_testHasValue004", 0, function () {
- let treeMap = new TreeMap();
- treeMap.set(0, "a");
- treeMap.set(1, "b");
- treeMap.set(2, "c");
- let res = treeMap.hasValue("a");
- expect(res).assertEqual(true);
- let res1 = treeMap.hasValue("d");
- expect(res1).assertEqual(false);
- });
- it("SR000GGR3H_testGet005_1", 0, function () {
- let treeMap = new TreeMap();
- treeMap.set(0, "a");
- treeMap.set(1, "b");
- treeMap.set(2, "c");
- let res = treeMap.get(1);
- expect(res).assertEqual("b");
- });
- it("SR000GGR3H_testGet005_2", 0, function () {
- let treeMap = new TreeMap();
- try {
- let res = treeMap.get(1);
- expect(res).assertEqual(undefined);
- } catch (err) {
- expect(err).assertEqual("Error: The node of this key does not exist in the tree");
- }
- });
- it("SR000GGR3H_testGet005_3", 0, function () {
- let treeMap = new TreeMap();
- treeMap.set(0, "a");
- treeMap.clear();
- expect(treeMap.length).assertEqual(0);
- try {
- let res = treeMap.get(0);
- expect(res).assertEqual(undefined);
- } catch (err) {
- expect(err).assertEqual("Error: The node of this key does not exist in the tree");
- }
- });
- it("SR000GGR3H_testGetFirstKey006_1", 0, function () {
- let treeMap = new TreeMap();
- treeMap.set(0, "a");
- treeMap.set(1, "b");
- treeMap.set(2, "c");
- let res = treeMap.getFirstKey();
- expect(res).assertEqual(0);
- });
- it("SR000GGR3H_testGetFirstKey006_2", 0, function () {
- let treeMap = new TreeMap();
- try {
- let res = treeMap.getFirstKey();
- } catch (err) {
- expect(err).assertEqual("Error: don't find this key,this tree is empty");
- }
- });
- it("SR000GGR3H_testGetLastKey007_1", 0, function () {
- let treeMap = new TreeMap();
- treeMap.set(0, "a");
- treeMap.set(1, "b");
- treeMap.set(2, "c");
- let res = treeMap.getLastKey();
- expect(res).assertEqual(2);
- });
- it("SR000GGR3H_testGetLastKey007_2", 0, function () {
- let treeMap = new TreeMap();
- try {
- let res = treeMap.getLastKey();
- } catch (err) {
- expect(err).assertEqual("Error: don't find this key,this tree is empty");
- }
- });
- it("SR000GGR3H_testSetAll008", 0, function () {
- let treeMap = new TreeMap();
- treeMap.set(0, "a");
- treeMap.set(1, "b");
- let treeMap1 = new TreeMap();
- treeMap1.set(0, "a");
- treeMap1.set(1, "b");
- treeMap1.set(2, "c");
- treeMap.setAll(treeMap1);
- let res = treeMap.get(0);
- expect(res).assertEqual("a");
- let res1 = treeMap.get(1);
- expect(res1).assertEqual("b");
- let res2 = treeMap.get(2);
- expect(res2).assertEqual("c");
- });
- it("SR000GGR3H_testRemove009_1", 0, function () {
- let treeMap = new TreeMap();
- treeMap.set(0, "a");
- treeMap.set(1, "b");
- treeMap.set(2, "c");
- let res = treeMap.remove(1);
- expect(res).assertEqual("b");
- });
- it("SR000GGR3H_testRemove009_2", 0, function () {
- let treeMap = new TreeMap();
- treeMap.set(0, "a");
- let res = treeMap.remove(1);
- expect(res).assertEqual(null);
- });
- it("SR000GGR3H_testClear010_1", 0, function () {
- let treeMap = new TreeMap();
- treeMap.set(0, "a");
- treeMap.set(1, "b");
- treeMap.set(2, "c");
- treeMap.clear();
- let res = treeMap.length;
- expect(res).assertEqual(0);
- });
- it("SR000GGR3H_testClear010_2", 0, function () {
- let treeMap = new TreeMap();
- treeMap.set(0, "a");
- treeMap.set(1, "b");
- treeMap.set(2, "c");
- treeMap.clear();
- let res = treeMap.length;
- expect(res).assertEqual(0);
- treeMap.set(3, "d");
- let va = treeMap.get(3);
- expect(va).assertEqual("d");
- });
- it("SR000GGR3H_testGetLowerKey011_1", 0, function () {
- let treeMap = new TreeMap();
- treeMap.set(0, "a");
- treeMap.set(1, "b");
- treeMap.set(2, "c");
- treeMap.set(3, "d");
- treeMap.set(4, "g");
- let res = treeMap.getLowerKey(2);
- expect(res).assertEqual(1);
- });
- it("SR000GGR3H_testGetLowerKey011_2", 0, function () {
- let treeMap = new TreeMap();
- try {
- let res = treeMap.getLowerKey(2);
- } catch (err) {
- expect(err).assertEqual("Error: don't find this key,this node is undefine");
- }
- });
- it("SR000GGR3H_testGetHigherKey012_1", 0, function () {
- let treeMap = new TreeMap();
- treeMap.set(0, "a");
- treeMap.set(1, "b");
- treeMap.set(2, "c");
- treeMap.set(3, "d");
- treeMap.set(4, "g");
- let res = treeMap.getHigherKey(2);
- expect(res).assertEqual(3);
- });
- it("SR000GGR3H_testGetHigherKey012_2", 0, function () {
- let treeMap = new TreeMap();
- try {
- let res = treeMap.getHigherKey(2);
- } catch (err) {
- expect(err).assertEqual("Error: don't find this key,this node is undefine");
- }
- });
- it("SR000GGR3H_testKeys013", 0, function () {
- let treeMap = new TreeMap();
- treeMap.set(0, "a");
- treeMap.set(1, "b");
- treeMap.set(2, "c");
- treeMap.set(3, "d");
- treeMap.set(4, "g");
- let res = treeMap.keys();
- expect(res.next().value).assertEqual(0);
- expect(res.next().value).assertEqual(1);
- expect(res.next().value).assertEqual(2);
- expect(res.next().value).assertEqual(3);
- expect(res.next().value).assertEqual(4);
- });
- it("SR000GGR3H_testValues014", 0, function () {
- let treeMap = new TreeMap();
- treeMap.set(0, "a");
- treeMap.set(1, "b");
- treeMap.set(2, "c");
- treeMap.set(3, "d");
- treeMap.set(4, "g");
- let res = treeMap.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("g");
- });
- it("SR000GGR3H_testReplace015_1", 0, function () {
- let treeMap = new TreeMap();
- treeMap.set(0, "a");
- treeMap.set(1, "b");
- treeMap.set(2, "c");
- treeMap.set(3, "d");
- treeMap.set(4, "g");
- let res = treeMap.replace(2, "B");
- let res1 = treeMap.get(2);
- expect(res1).assertEqual("B");
- });
- it("SR000GGR3H_testReplace015_2", 0, function () {
- let treeMap = new TreeMap();
- treeMap.set(0, "a");
- let res = treeMap.replace(2, "B");
- expect(res).assertEqual(false);
- try {
- let res1 = treeMap.get(2);
- expect(res1).assertEqual(undefined);
- } catch (err) {
- expect(err).assertEqual("Error: The node of this key does not exist in the tree");
- }
- });
- it("SR000GGR3H_testLength016_1", 0, function () {
- let treeMap = new TreeMap();
- treeMap.set(0, "a");
- treeMap.set(1, "b");
- treeMap.set(2, "c");
- treeMap.set(3, "d");
- treeMap.set(4, "g");
- let res = treeMap.length;
- expect(res).assertEqual(5);
- });
- it("SR000GGR3H_testLength016_2", 0, function () {
- let treeMap = new TreeMap();
- let res = treeMap.length;
- expect(res).assertEqual(0);
- });
- it("SR000GGR3H_testForEach017", 0, function () {
- let treeMap = new TreeMap();
- treeMap.set(0, "a");
- treeMap.set(1, "b");
- treeMap.set(2, "c");
- treeMap.set(3, "d");
- treeMap.set(4, "g");
- let arr1 = [];
- let arr2 = [];
- treeMap.forEach((value, key) => {
- arr1.push(value);
- });
- treeMap.forEach((value, key) => {
- arr2.push(key);
- });
- let arr = ["a", "b", "c", "d", "g"];
- for (let i = 0; i < arr1.length; i++) {
- expect(arr[i]).assertEqual(arr1[i]);
- }
- let arr3 = [0, 1, 2, 3, 4];
- for (let i = 0; i < arr3.length; i++) {
- expect(arr3[i]).assertEqual(arr2[i]);
- }
- });
- it("SR000GGR3H_testEntries018", 0, function () {
- let treeMap = new TreeMap();
- treeMap.set(0, "a");
- treeMap.set(1, "b");
- treeMap.set(2, "c");
- treeMap.set(3, "d");
- treeMap.set(4, "g");
- let res = treeMap.entries();
- let arr = ["0,a", "1,b", "2,c", "3,d", "4,g"];
- for (let i = 0; i < treeMap.length; i++) {
- expect(arr[i]).assertEqual(res.next().value);
- }
- });
- it("SR000GGR3H_testIterator019", 0, function () {
- let treeMap = new TreeMap();
- treeMap.set(0, "a");
- treeMap.set(1, "b");
- treeMap.set(2, "c");
- treeMap.set(3, "d");
- treeMap.set(4, "g");
- let arr = ["0,a", "1,b", "2,c", "3,d", "4,g"];
- let iterArr = [];
- for (let [key, value] of treeMap) {
- iterArr.push(key + "," + value);
- }
- for (let i = 0; i < arr.length; i++) {
- expect(arr[i]).assertEqual(iterArr[i]);
- }
- });
- it("SR000GGR3H_testIterator020", 0, function () {
- let treeMap = new TreeMap();
- treeMap.set(0, "a");
- treeMap.set(1, "b");
- treeMap.set(2, "c");
- treeMap.set(3, "d");
- treeMap.set(4, "g");
- let arr = [];
- let res = treeMap[Symbol.iterator]();
- let temp = undefined;
- do {
- temp = res.next().value;
- arr.push(temp);
- } while (temp != undefined);
- let arr1 = ["0,a", "1,b", "2,c", "3,d", "4,g"];
- for (let i = 0; i < arr.length; i++) {
- expect(arr[i]).assertEqual(arr1[i]);
- }
- });
-});
+/*
+ * Copyright (C) 2021 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 'deccjsunit/index';
+import TreeMap from "@ohos.util.TreeMap";
+
+describe("TreeMapTest", function () {
+ it("SR000GGR3H_testConstructor001", 0, function () {
+ try {
+ let treeMap = new TreeMap();
+ expect(treeMap != undefined).assertEqual(true);
+ } catch (err) {
+ expect(err).assertEqual("Error: Cannot create new TreeMap");
+ }
+ });
+ it("SR000GGR3H_testSet002_1", 0, function () {
+ let treeMap = new TreeMap();
+ treeMap.set(0, "四");
+ let res = treeMap.get(0);
+ expect(res).assertEqual("四");
+ });
+ it("SR000GGR3H_testSet002_2", 0, function () {
+ let treeMap = new TreeMap();
+ treeMap.set(0, 8);
+ let res = treeMap.get(0);
+ expect(res).assertEqual(8);
+ });
+ it("SR000GGR3H_testSet002_3", 0, function () {
+ let treeMap = new TreeMap();
+ let a = [1, 2, 3, 4];
+ treeMap.set(0, a);
+ let res = treeMap.get(0);
+ expect(res).assertEqual(a);
+ });
+ it("SR000GGR3H_testSet002_4", 0, function () {
+ let treeMap = new TreeMap();
+ let a = {name: "lala", age: "13"};
+ treeMap.set(0, a);
+ let res = treeMap.get(0);
+ expect(res).assertEqual(a);
+ });
+ it("SR000GGR3H_testSet002_5", 0, function () {
+ let treeMap = new TreeMap();
+ treeMap.set(2, "*");
+ let res = treeMap.get(2);
+ expect(res).assertEqual("*");
+ });
+ it("SR000GGR3H_testSet002_6", 0, function () {
+ let treeMap = new TreeMap();
+ treeMap.set(-2, 3.14);
+ let res = treeMap.get(-2);
+ expect(res).assertEqual(3.14);
+ });
+ it("SR000GGR3H_testSet002_7", 0, function () {
+ let treeMap = new TreeMap();
+ treeMap.set(100, true);
+ let res = treeMap.get(100);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR3H_testSet002_8", 0, function () {
+ let treeMap = new TreeMap();
+ treeMap.set(100, "");
+ let res = treeMap.get(100);
+ expect(res).assertEqual("");
+ });
+ it("SR000GGR3H_testSet002_9", 0, function () {
+ let treeMap = new TreeMap();
+ treeMap.set("a", "四");
+ let res = treeMap.get("a");
+ expect(res).assertEqual("四");
+ });
+ it("SR000GGR3H_testSet002_10", 0, function () {
+ let treeMap = new TreeMap();
+ for (let i = 0; i < 10000; i++) {
+ treeMap.set(0, 8);
+ }
+ let res = treeMap.get(0);
+ expect(res).assertEqual(8);
+ expect(treeMap.length).assertEqual(1);
+ });
+ it("SR000GGR3H_testHasKey003", 0, function () {
+ let treeMap = new TreeMap();
+ treeMap.set(0, "a");
+ treeMap.set(1, "b");
+ let res = treeMap.hasKey(1);
+ expect(res).assertEqual(true);
+ let res1 = treeMap.hasKey(6);
+ expect(res1).assertEqual(false);
+ });
+ it("SR000GGR3H_testHasValue004", 0, function () {
+ let treeMap = new TreeMap();
+ treeMap.set(0, "a");
+ treeMap.set(1, "b");
+ treeMap.set(2, "c");
+ let res = treeMap.hasValue("a");
+ expect(res).assertEqual(true);
+ let res1 = treeMap.hasValue("d");
+ expect(res1).assertEqual(false);
+ });
+ it("SR000GGR3H_testGet005_1", 0, function () {
+ let treeMap = new TreeMap();
+ treeMap.set(0, "a");
+ treeMap.set(1, "b");
+ treeMap.set(2, "c");
+ let res = treeMap.get(1);
+ expect(res).assertEqual("b");
+ });
+ it("SR000GGR3H_testGet005_2", 0, function () {
+ let treeMap = new TreeMap();
+ try {
+ let res = treeMap.get(1);
+ expect(res).assertEqual(undefined);
+ } catch (err) {
+ expect(err).assertEqual("Error: The node of this key does not exist in the tree");
+ }
+ });
+ it("SR000GGR3H_testGet005_3", 0, function () {
+ let treeMap = new TreeMap();
+ treeMap.set(0, "a");
+ treeMap.clear();
+ expect(treeMap.length).assertEqual(0);
+ try {
+ let res = treeMap.get(0);
+ expect(res).assertEqual(undefined);
+ } catch (err) {
+ expect(err).assertEqual("Error: The node of this key does not exist in the tree");
+ }
+ });
+ it("SR000GGR3H_testGetFirstKey006_1", 0, function () {
+ let treeMap = new TreeMap();
+ treeMap.set(0, "a");
+ treeMap.set(1, "b");
+ treeMap.set(2, "c");
+ let res = treeMap.getFirstKey();
+ expect(res).assertEqual(0);
+ });
+ it("SR000GGR3H_testGetFirstKey006_2", 0, function () {
+ let treeMap = new TreeMap();
+ try {
+ let res = treeMap.getFirstKey();
+ } catch (err) {
+ expect(err).assertEqual("Error: don't find this key,this tree is empty");
+ }
+ });
+ it("SR000GGR3H_testGetLastKey007_1", 0, function () {
+ let treeMap = new TreeMap();
+ treeMap.set(0, "a");
+ treeMap.set(1, "b");
+ treeMap.set(2, "c");
+ let res = treeMap.getLastKey();
+ expect(res).assertEqual(2);
+ });
+ it("SR000GGR3H_testGetLastKey007_2", 0, function () {
+ let treeMap = new TreeMap();
+ try {
+ let res = treeMap.getLastKey();
+ } catch (err) {
+ expect(err).assertEqual("Error: don't find this key,this tree is empty");
+ }
+ });
+ it("SR000GGR3H_testSetAll008", 0, function () {
+ let treeMap = new TreeMap();
+ treeMap.set(0, "a");
+ treeMap.set(1, "b");
+ let treeMap1 = new TreeMap();
+ treeMap1.set(0, "a");
+ treeMap1.set(1, "b");
+ treeMap1.set(2, "c");
+ treeMap.setAll(treeMap1);
+ let res = treeMap.get(0);
+ expect(res).assertEqual("a");
+ let res1 = treeMap.get(1);
+ expect(res1).assertEqual("b");
+ let res2 = treeMap.get(2);
+ expect(res2).assertEqual("c");
+ });
+ it("SR000GGR3H_testRemove009_1", 0, function () {
+ let treeMap = new TreeMap();
+ treeMap.set(0, "a");
+ treeMap.set(1, "b");
+ treeMap.set(2, "c");
+ let res = treeMap.remove(1);
+ expect(res).assertEqual("b");
+ });
+ it("SR000GGR3H_testRemove009_2", 0, function () {
+ let treeMap = new TreeMap();
+ treeMap.set(0, "a");
+ let res = treeMap.remove(1);
+ expect(res).assertEqual(null);
+ });
+ it("SR000GGR3H_testClear010_1", 0, function () {
+ let treeMap = new TreeMap();
+ treeMap.set(0, "a");
+ treeMap.set(1, "b");
+ treeMap.set(2, "c");
+ treeMap.clear();
+ let res = treeMap.length;
+ expect(res).assertEqual(0);
+ });
+ it("SR000GGR3H_testClear010_2", 0, function () {
+ let treeMap = new TreeMap();
+ treeMap.set(0, "a");
+ treeMap.set(1, "b");
+ treeMap.set(2, "c");
+ treeMap.clear();
+ let res = treeMap.length;
+ expect(res).assertEqual(0);
+ treeMap.set(3, "d");
+ let va = treeMap.get(3);
+ expect(va).assertEqual("d");
+ });
+ it("SR000GGR3H_testGetLowerKey011_1", 0, function () {
+ let treeMap = new TreeMap();
+ treeMap.set(0, "a");
+ treeMap.set(1, "b");
+ treeMap.set(2, "c");
+ treeMap.set(3, "d");
+ treeMap.set(4, "g");
+ let res = treeMap.getLowerKey(2);
+ expect(res).assertEqual(1);
+ });
+ it("SR000GGR3H_testGetLowerKey011_2", 0, function () {
+ let treeMap = new TreeMap();
+ try {
+ let res = treeMap.getLowerKey(2);
+ } catch (err) {
+ expect(err).assertEqual("Error: don't find this key,this node is undefine");
+ }
+ });
+ it("SR000GGR3H_testGetHigherKey012_1", 0, function () {
+ let treeMap = new TreeMap();
+ treeMap.set(0, "a");
+ treeMap.set(1, "b");
+ treeMap.set(2, "c");
+ treeMap.set(3, "d");
+ treeMap.set(4, "g");
+ let res = treeMap.getHigherKey(2);
+ expect(res).assertEqual(3);
+ });
+ it("SR000GGR3H_testGetHigherKey012_2", 0, function () {
+ let treeMap = new TreeMap();
+ try {
+ let res = treeMap.getHigherKey(2);
+ } catch (err) {
+ expect(err).assertEqual("Error: don't find this key,this node is undefine");
+ }
+ });
+ it("SR000GGR3H_testKeys013", 0, function () {
+ let treeMap = new TreeMap();
+ treeMap.set(0, "a");
+ treeMap.set(1, "b");
+ treeMap.set(2, "c");
+ treeMap.set(3, "d");
+ treeMap.set(4, "g");
+ let res = treeMap.keys();
+ expect(res.next().value).assertEqual(0);
+ expect(res.next().value).assertEqual(1);
+ expect(res.next().value).assertEqual(2);
+ expect(res.next().value).assertEqual(3);
+ expect(res.next().value).assertEqual(4);
+ });
+ it("SR000GGR3H_testValues014", 0, function () {
+ let treeMap = new TreeMap();
+ treeMap.set(0, "a");
+ treeMap.set(1, "b");
+ treeMap.set(2, "c");
+ treeMap.set(3, "d");
+ treeMap.set(4, "g");
+ let res = treeMap.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("g");
+ });
+ it("SR000GGR3H_testReplace015_1", 0, function () {
+ let treeMap = new TreeMap();
+ treeMap.set(0, "a");
+ treeMap.set(1, "b");
+ treeMap.set(2, "c");
+ treeMap.set(3, "d");
+ treeMap.set(4, "g");
+ let res = treeMap.replace(2, "B");
+ let res1 = treeMap.get(2);
+ expect(res1).assertEqual("B");
+ });
+ it("SR000GGR3H_testReplace015_2", 0, function () {
+ let treeMap = new TreeMap();
+ treeMap.set(0, "a");
+ let res = treeMap.replace(2, "B");
+ expect(res).assertEqual(false);
+ try {
+ let res1 = treeMap.get(2);
+ expect(res1).assertEqual(undefined);
+ } catch (err) {
+ expect(err).assertEqual("Error: The node of this key does not exist in the tree");
+ }
+ });
+ it("SR000GGR3H_testLength016_1", 0, function () {
+ let treeMap = new TreeMap();
+ treeMap.set(0, "a");
+ treeMap.set(1, "b");
+ treeMap.set(2, "c");
+ treeMap.set(3, "d");
+ treeMap.set(4, "g");
+ let res = treeMap.length;
+ expect(res).assertEqual(5);
+ });
+ it("SR000GGR3H_testLength016_2", 0, function () {
+ let treeMap = new TreeMap();
+ let res = treeMap.length;
+ expect(res).assertEqual(0);
+ });
+ it("SR000GGR3H_testForEach017", 0, function () {
+ let treeMap = new TreeMap();
+ treeMap.set(0, "a");
+ treeMap.set(1, "b");
+ treeMap.set(2, "c");
+ treeMap.set(3, "d");
+ treeMap.set(4, "g");
+ let arr1 = [];
+ let arr2 = [];
+ treeMap.forEach((value, key) => {
+ arr1.push(value);
+ });
+ treeMap.forEach((value, key) => {
+ arr2.push(key);
+ });
+ let arr = ["a", "b", "c", "d", "g"];
+ for (let i = 0; i < arr1.length; i++) {
+ expect(arr[i]).assertEqual(arr1[i]);
+ }
+ let arr3 = [0, 1, 2, 3, 4];
+ for (let i = 0; i < arr3.length; i++) {
+ expect(arr3[i]).assertEqual(arr2[i]);
+ }
+ });
+ it("SR000GGR3H_testEntries018", 0, function () {
+ let treeMap = new TreeMap();
+ treeMap.set(0, "a");
+ treeMap.set(1, "b");
+ treeMap.set(2, "c");
+ treeMap.set(3, "d");
+ treeMap.set(4, "g");
+ let res = treeMap.entries();
+ let arr = ["0,a", "1,b", "2,c", "3,d", "4,g"];
+ for (let i = 0; i < treeMap.length; i++) {
+ expect(arr[i]).assertEqual(res.next().value);
+ }
+ });
+ it("SR000GGR3H_testIterator019", 0, function () {
+ let treeMap = new TreeMap();
+ treeMap.set(0, "a");
+ treeMap.set(1, "b");
+ treeMap.set(2, "c");
+ treeMap.set(3, "d");
+ treeMap.set(4, "g");
+ let arr = ["0,a", "1,b", "2,c", "3,d", "4,g"];
+ let iterArr = [];
+ for (let [key, value] of treeMap) {
+ iterArr.push(key + "," + value);
+ }
+ for (let i = 0; i < arr.length; i++) {
+ expect(arr[i]).assertEqual(iterArr[i]);
+ }
+ });
+ it("SR000GGR3H_testIterator020", 0, function () {
+ let treeMap = new TreeMap();
+ treeMap.set(0, "a");
+ treeMap.set(1, "b");
+ treeMap.set(2, "c");
+ treeMap.set(3, "d");
+ treeMap.set(4, "g");
+ let arr = [];
+ let res = treeMap[Symbol.iterator]();
+ let temp = undefined;
+ do {
+ temp = res.next().value;
+ arr.push(temp);
+ } while (temp != undefined);
+ let arr1 = ["0,a", "1,b", "2,c", "3,d", "4,g"];
+ for (let i = 0; i < arr.length; i++) {
+ expect(arr[i]).assertEqual(arr1[i]);
+ }
+ });
+});
diff --git a/compileruntime/util_lib_standard/src/main/js/test/TreeSet.test.js b/compileruntime/containerRelation_lib_standard/src/main/js/test/TreeSet.test.js
similarity index 96%
rename from compileruntime/util_lib_standard/src/main/js/test/TreeSet.test.js
rename to compileruntime/containerRelation_lib_standard/src/main/js/test/TreeSet.test.js
index 69dddc8dd75ce4e83f0d7b0a188d6c7fd242b5c2..af8f4f06fcd917b5096d1be3b0c18dc5f59a8b60 100644
--- a/compileruntime/util_lib_standard/src/main/js/test/TreeSet.test.js
+++ b/compileruntime/containerRelation_lib_standard/src/main/js/test/TreeSet.test.js
@@ -1,353 +1,353 @@
-/*
- * Copyright (C) 2021 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 'deccjsunit/index';
-import TreeSet from "@ohos.util.TreeSet";
-
-describe("TreeSetTest", function () {
- it("SR000GGR3I_testConstructor001", 0, function () {
- try {
- let treeSet = new TreeSet();
- expect(treeSet != undefined).assertEqual(true);
- } catch (err) {
- expect(err).assertEqual("Error: Cannot create new TreeSet");
- }
- });
- it("SR000GGR3I_testAdd002_1", 0, function () {
- let treeSet = new TreeSet();
- treeSet.add("四");
- let res = treeSet.has("四");
- expect(res).assertEqual(true);
- });
- it("SR000GGR3I_testAdd002_2", 0, function () {
- let treeSet = new TreeSet();
- treeSet.add(8);
- let res = treeSet.has(8);
- expect(res).assertEqual(true);
- });
- it("SR000GGR3I_testAdd002_3", 0, function () {
- let treeSet = new TreeSet();
- let a = [1, 2, 3, 4];
- treeSet.add(a);
- let res = treeSet.has(a);
- expect(res).assertEqual(true);
- });
- it("SR000GGR3I_testAdd002_4", 0, function () {
- let treeSet = new TreeSet();
- treeSet.add("*");
- let res = treeSet.has("*");
- expect(res).assertEqual(true);
- });
- it("SR000GGR3I_testAdd002_5", 0, function () {
- let treeSet = new TreeSet();
- let a = {name: "lala", age: "13岁"};
- treeSet.add(a);
- let res = treeSet.has(a);
- expect(res).assertEqual(true);
- });
- it("SR000GGR3I_testAdd002_6", 0, function () {
- let treeSet = new TreeSet();
- treeSet.add(1.234);
- let res = treeSet.has(1.234);
- expect(res).assertEqual(true);
- });
- it("SR000GGR3I_testAdd002_7", 0, function () {
- let treeSet = new TreeSet();
- treeSet.add(true);
- let res = treeSet.has(true);
- expect(res).assertEqual(true);
- });
- it("SR000GGR3I_testAdd002_8", 0, function () {
- let treeSet = new TreeSet();
- treeSet.add("");
- let res = treeSet.has("");
- expect(res).assertEqual(true);
- });
- it("SR000GGR3I_testAdd002_9", 0, function () {
- let treeSet = new TreeSet();
- for (let i = 0; i < 10000; i++) {
- treeSet.add(i);
- }
- expect(treeSet.length).assertEqual(10000);
- let res = treeSet.has(8888);
- expect(res).assertEqual(true);
- });
- it("SR000GGR3I_testLength003_1", 0, function () {
- let treeSet = new TreeSet();
- treeSet.add(0);
- treeSet.add(1);
- treeSet.add(2);
- let res = treeSet.length;
- expect(res).assertEqual(3);
- });
- it("SR000GGR3I_testLength003_2", 0, function () {
- let treeSet = new TreeSet();
- let res = treeSet.length;
- expect(res).assertEqual(0);
- });
- it("SR000GGR3I_testHas004_1", 0, function () {
- let treeSet = new TreeSet();
- treeSet.add(0);
- treeSet.add(1);
- treeSet.add(2);
- let res = treeSet.has(2);
- expect(res).assertEqual(true);
- });
- it("SR000GGR3I_testHas004_2", 0, function () {
- let treeSet = new TreeSet();
- treeSet.add(0);
- treeSet.add(1);
- treeSet.add(2);
- let res1 = treeSet.has(3);
- expect(res1).assertEqual(false);
- });
- it("SR000GGR3I_testGetFirstValue005_1", 0, function () {
- let treeSet = new TreeSet();
- treeSet.add(0);
- treeSet.add(1);
- treeSet.add(2);
- treeSet.add(3);
- treeSet.add(4);
- let res = treeSet.getFirstValue();
- expect(res).assertEqual(0);
- });
- it("SR000GGR3I_testGetFirstValue005_2", 0, function () {
- let treeSet = new TreeSet();
- try {
- let res = treeSet.getFirstValue();
- } catch (err) {
- expect(err).assertEqual("Error: don't find this key,this tree is empty");
- }
- });
- it("SR000GGR3I_testGetLastValue006_1", 0, function () {
- let treeSet = new TreeSet();
- treeSet.add(0);
- treeSet.add(1);
- treeSet.add(2);
- let res = treeSet.getLastValue();
- expect(res).assertEqual(2);
- });
- it("SR000GGR3I_testGetLastValue006_2", 0, function () {
- let treeSet = new TreeSet();
- try {
- let res = treeSet.getLastValue();
- } catch (err) {
- expect(err).assertEqual("Error: don't find this key,this tree is empty");
- }
- });
- it("SR000GGR3I_testGetLowerValue007_1", 0, function () {
- let treeSet = new TreeSet();
- treeSet.add(0);
- treeSet.add(1);
- treeSet.add(2);
- treeSet.add(3);
- treeSet.add(4);
- let res = treeSet.getLowerValue(2);
- expect(res).assertEqual(1);
- });
- it("SR000GGR3I_testGetLowerValue007_2", 0, function () {
- let treeSet = new TreeSet();
- try {
- let res = treeSet.getLowerValue(2);
- } catch (err) {
- expect(err).assertEqual("Error: don't find this key,this node is undefine");
- }
- });
- it("SR000GGR3I_testGetHigherValue008_1", 0, function () {
- let treeSet = new TreeSet();
- treeSet.add(0);
- treeSet.add(1);
- treeSet.add(2);
- treeSet.add(3);
- treeSet.add(4);
- let res = treeSet.getHigherValue(3);
- expect(res).assertEqual(4);
- });
- it("SR000GGR3I_testGetHigherValue008_2", 0, function () {
- let treeSet = new TreeSet();
- try {
- let res = treeSet.getHigherValue(3);
- } catch (err) {
- expect(err).assertEqual("Error: don't find this key,this node is undefine");
- }
- });
- it("SR000GGR3I_testPopFirst009_1", 0, function () {
- let treeSet = new TreeSet();
- treeSet.add("a");
- treeSet.add("b");
- treeSet.add("c");
- treeSet.add("d");
- treeSet.add("e");
- let res = treeSet.popFirst();
- expect(res).assertEqual("a");
- });
- it("SR000GGR3I_testPopFirst009_2", 0, function () {
- let treeSet = new TreeSet();
- try {
- let res = treeSet.popFirst();
- } catch (err) {
- expect(err).assertEqual("Error: don't find first node,this tree is empty");
- }
- });
- it("SR000GGR3I_testPopLast010_1", 0, function () {
- let treeSet = new TreeSet();
- treeSet.add("a");
- treeSet.add("b");
- treeSet.add("c");
- treeSet.add("d");
- treeSet.add("e");
- let res = treeSet.popLast();
- expect(res).assertEqual("e");
- });
- it("SR000GGR3I_testPopLast010_2", 0, function () {
- let treeSet = new TreeSet();
- try {
- let res = treeSet.popLast();
- } catch (err) {
- expect(err).assertEqual("Error: don't find last node,this tree is empty");
- }
- });
- it("SR000GGR3I_testClear011_1", 0, function () {
- let treeSet = new TreeSet();
- treeSet.add(0);
- treeSet.add(1);
- treeSet.add(2);
- treeSet.clear();
- let res = treeSet.length;
- expect(res).assertEqual(0);
- });
- it("SR000GGR3I_testClear011_2", 0, function () {
- let treeSet = new TreeSet();
- treeSet.add(0);
- treeSet.add(1);
- treeSet.add(2);
- treeSet.clear();
- let res = treeSet.length;
- expect(res).assertEqual(0);
- treeSet.add(3);
- try {
- treeSet.popFirst();
- } catch (err) {
- expect(err).assertEqual("Error: don't find first node,this tree is empty");
- }
- });
- it("SR000GGR3I_testIsEmpty012_1", 0, function () {
- let treeSet = new TreeSet();
- treeSet.add("a");
- let res1 = treeSet.isEmpty();
- expect(res1).assertEqual(false);
- });
- it("SR000GGR3I_testIsEmpty012_2", 0, function () {
- let treeSet = new TreeSet();
- let res2 = treeSet.isEmpty();
- expect(res2).assertEqual(true);
- });
- it("SR000GGR3I_testRemove013_1", 0, function () {
- let treeSet = new TreeSet();
- treeSet.add("a");
- treeSet.add("b");
- treeSet.add("c");
- treeSet.add("c");
- treeSet.add("d");
- treeSet.add("g");
- let res1 = treeSet.remove("c");
- expect(res1).assertEqual(true);
- let res2 = treeSet.has("c");
- expect(res2).assertEqual(false);
- });
- it("SR000GGR3I_testRemove013_2", 0, function () {
- let treeSet = new TreeSet();
- let res = treeSet.remove("c");
- expect(res).assertEqual(false);
- });
- it("SR000GGR3I_testValues014", 0, function () {
- let treeSet = new TreeSet();
- treeSet.add("a");
- treeSet.add("b");
- treeSet.add("c");
- treeSet.add("d");
- treeSet.add("g");
- let res = treeSet.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("g");
- });
- it("SR000GGR3I_testForEach015", 0, function () {
- let treeSet = new TreeSet();
- treeSet.add(0);
- treeSet.add(1);
- treeSet.add(2);
- treeSet.add(3);
- treeSet.add(4);
- let arr1 = [];
- treeSet.forEach((value, key) => {
- arr1.push(value);
- });
- let arr = [0, 1, 2, 3, 4];
- for (let i = 0; i < arr1.length; i++) {
- expect(arr[i]).assertEqual(arr1[i]);
- }
- });
- it("SR000GGR3I_testEntries016", 0, function () {
- let treeSet = new TreeSet();
- treeSet.add("a");
- treeSet.add("b");
- treeSet.add("c");
- treeSet.add("d");
- treeSet.add("g");
- let res = treeSet.entries();
- expect(JSON.stringify(res.next().value)).assertEqual('["a","a"]');
- expect(JSON.stringify(res.next().value)).assertEqual('["b","b"]');
- expect(JSON.stringify(res.next().value)).assertEqual('["c","c"]');
- expect(JSON.stringify(res.next().value)).assertEqual('["d","d"]');
- expect(JSON.stringify(res.next().value)).assertEqual('["g","g"]');
- });
- it("SR000GGR3I_testIterator017", 0, function () {
- let treeSet = new TreeSet();
- treeSet.add(0);
- treeSet.add(1);
- treeSet.add(2);
- treeSet.add(3);
- treeSet.add(4);
- let arr = [];
- for (let item of treeSet) {
- arr.push(item);
- }
- let arr1 = [0, 1, 2, 3, 4];
- for (let i = 0; i < arr1.length; i++) {
- expect(arr[i]).assertEqual(arr1[i]);
- }
- });
- it("SR000GGR3I_testIterator018", 0, function () {
- let treeSet = new TreeSet();
- treeSet.add(0);
- treeSet.add(1);
- treeSet.add(2);
- treeSet.add(3);
- treeSet.add(4);
- let arr = [];
- let res = treeSet[Symbol.iterator]();
- let temp = undefined;
- do {
- temp = res.next().value;
- arr.push(temp);
- } while (temp != undefined);
- let arr1 = [0, 1, 2, 3, 4];
- for (let i = 0; i < arr1.length; i++) {
- expect(arr[i]).assertEqual(arr1[i]);
- }
- });
-});
+/*
+ * Copyright (C) 2021 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 'deccjsunit/index';
+import TreeSet from "@ohos.util.TreeSet";
+
+describe("TreeSetTest", function () {
+ it("SR000GGR3I_testConstructor001", 0, function () {
+ try {
+ let treeSet = new TreeSet();
+ expect(treeSet != undefined).assertEqual(true);
+ } catch (err) {
+ expect(err).assertEqual("Error: Cannot create new TreeSet");
+ }
+ });
+ it("SR000GGR3I_testAdd002_1", 0, function () {
+ let treeSet = new TreeSet();
+ treeSet.add("四");
+ let res = treeSet.has("四");
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR3I_testAdd002_2", 0, function () {
+ let treeSet = new TreeSet();
+ treeSet.add(8);
+ let res = treeSet.has(8);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR3I_testAdd002_3", 0, function () {
+ let treeSet = new TreeSet();
+ let a = [1, 2, 3, 4];
+ treeSet.add(a);
+ let res = treeSet.has(a);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR3I_testAdd002_4", 0, function () {
+ let treeSet = new TreeSet();
+ treeSet.add("*");
+ let res = treeSet.has("*");
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR3I_testAdd002_5", 0, function () {
+ let treeSet = new TreeSet();
+ let a = {name: "lala", age: "13岁"};
+ treeSet.add(a);
+ let res = treeSet.has(a);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR3I_testAdd002_6", 0, function () {
+ let treeSet = new TreeSet();
+ treeSet.add(1.234);
+ let res = treeSet.has(1.234);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR3I_testAdd002_7", 0, function () {
+ let treeSet = new TreeSet();
+ treeSet.add(true);
+ let res = treeSet.has(true);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR3I_testAdd002_8", 0, function () {
+ let treeSet = new TreeSet();
+ treeSet.add("");
+ let res = treeSet.has("");
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR3I_testAdd002_9", 0, function () {
+ let treeSet = new TreeSet();
+ for (let i = 0; i < 10000; i++) {
+ treeSet.add(i);
+ }
+ expect(treeSet.length).assertEqual(10000);
+ let res = treeSet.has(8888);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR3I_testLength003_1", 0, function () {
+ let treeSet = new TreeSet();
+ treeSet.add(0);
+ treeSet.add(1);
+ treeSet.add(2);
+ let res = treeSet.length;
+ expect(res).assertEqual(3);
+ });
+ it("SR000GGR3I_testLength003_2", 0, function () {
+ let treeSet = new TreeSet();
+ let res = treeSet.length;
+ expect(res).assertEqual(0);
+ });
+ it("SR000GGR3I_testHas004_1", 0, function () {
+ let treeSet = new TreeSet();
+ treeSet.add(0);
+ treeSet.add(1);
+ treeSet.add(2);
+ let res = treeSet.has(2);
+ expect(res).assertEqual(true);
+ });
+ it("SR000GGR3I_testHas004_2", 0, function () {
+ let treeSet = new TreeSet();
+ treeSet.add(0);
+ treeSet.add(1);
+ treeSet.add(2);
+ let res1 = treeSet.has(3);
+ expect(res1).assertEqual(false);
+ });
+ it("SR000GGR3I_testGetFirstValue005_1", 0, function () {
+ let treeSet = new TreeSet();
+ treeSet.add(0);
+ treeSet.add(1);
+ treeSet.add(2);
+ treeSet.add(3);
+ treeSet.add(4);
+ let res = treeSet.getFirstValue();
+ expect(res).assertEqual(0);
+ });
+ it("SR000GGR3I_testGetFirstValue005_2", 0, function () {
+ let treeSet = new TreeSet();
+ try {
+ let res = treeSet.getFirstValue();
+ } catch (err) {
+ expect(err).assertEqual("Error: don't find this key,this tree is empty");
+ }
+ });
+ it("SR000GGR3I_testGetLastValue006_1", 0, function () {
+ let treeSet = new TreeSet();
+ treeSet.add(0);
+ treeSet.add(1);
+ treeSet.add(2);
+ let res = treeSet.getLastValue();
+ expect(res).assertEqual(2);
+ });
+ it("SR000GGR3I_testGetLastValue006_2", 0, function () {
+ let treeSet = new TreeSet();
+ try {
+ let res = treeSet.getLastValue();
+ } catch (err) {
+ expect(err).assertEqual("Error: don't find this key,this tree is empty");
+ }
+ });
+ it("SR000GGR3I_testGetLowerValue007_1", 0, function () {
+ let treeSet = new TreeSet();
+ treeSet.add(0);
+ treeSet.add(1);
+ treeSet.add(2);
+ treeSet.add(3);
+ treeSet.add(4);
+ let res = treeSet.getLowerValue(2);
+ expect(res).assertEqual(1);
+ });
+ it("SR000GGR3I_testGetLowerValue007_2", 0, function () {
+ let treeSet = new TreeSet();
+ try {
+ let res = treeSet.getLowerValue(2);
+ } catch (err) {
+ expect(err).assertEqual("Error: don't find this key,this node is undefine");
+ }
+ });
+ it("SR000GGR3I_testGetHigherValue008_1", 0, function () {
+ let treeSet = new TreeSet();
+ treeSet.add(0);
+ treeSet.add(1);
+ treeSet.add(2);
+ treeSet.add(3);
+ treeSet.add(4);
+ let res = treeSet.getHigherValue(3);
+ expect(res).assertEqual(4);
+ });
+ it("SR000GGR3I_testGetHigherValue008_2", 0, function () {
+ let treeSet = new TreeSet();
+ try {
+ let res = treeSet.getHigherValue(3);
+ } catch (err) {
+ expect(err).assertEqual("Error: don't find this key,this node is undefine");
+ }
+ });
+ it("SR000GGR3I_testPopFirst009_1", 0, function () {
+ let treeSet = new TreeSet();
+ treeSet.add("a");
+ treeSet.add("b");
+ treeSet.add("c");
+ treeSet.add("d");
+ treeSet.add("e");
+ let res = treeSet.popFirst();
+ expect(res).assertEqual("a");
+ });
+ it("SR000GGR3I_testPopFirst009_2", 0, function () {
+ let treeSet = new TreeSet();
+ try {
+ let res = treeSet.popFirst();
+ } catch (err) {
+ expect(err).assertEqual("Error: don't find first node,this tree is empty");
+ }
+ });
+ it("SR000GGR3I_testPopLast010_1", 0, function () {
+ let treeSet = new TreeSet();
+ treeSet.add("a");
+ treeSet.add("b");
+ treeSet.add("c");
+ treeSet.add("d");
+ treeSet.add("e");
+ let res = treeSet.popLast();
+ expect(res).assertEqual("e");
+ });
+ it("SR000GGR3I_testPopLast010_2", 0, function () {
+ let treeSet = new TreeSet();
+ try {
+ let res = treeSet.popLast();
+ } catch (err) {
+ expect(err).assertEqual("Error: don't find last node,this tree is empty");
+ }
+ });
+ it("SR000GGR3I_testClear011_1", 0, function () {
+ let treeSet = new TreeSet();
+ treeSet.add(0);
+ treeSet.add(1);
+ treeSet.add(2);
+ treeSet.clear();
+ let res = treeSet.length;
+ expect(res).assertEqual(0);
+ });
+ it("SR000GGR3I_testClear011_2", 0, function () {
+ let treeSet = new TreeSet();
+ treeSet.add(0);
+ treeSet.add(1);
+ treeSet.add(2);
+ treeSet.clear();
+ let res = treeSet.length;
+ expect(res).assertEqual(0);
+ treeSet.add(3);
+ try {
+ treeSet.popFirst();
+ } catch (err) {
+ expect(err).assertEqual("Error: don't find first node,this tree is empty");
+ }
+ });
+ it("SR000GGR3I_testIsEmpty012_1", 0, function () {
+ let treeSet = new TreeSet();
+ treeSet.add("a");
+ let res1 = treeSet.isEmpty();
+ expect(res1).assertEqual(false);
+ });
+ it("SR000GGR3I_testIsEmpty012_2", 0, function () {
+ let treeSet = new TreeSet();
+ let res2 = treeSet.isEmpty();
+ expect(res2).assertEqual(true);
+ });
+ it("SR000GGR3I_testRemove013_1", 0, function () {
+ let treeSet = new TreeSet();
+ treeSet.add("a");
+ treeSet.add("b");
+ treeSet.add("c");
+ treeSet.add("c");
+ treeSet.add("d");
+ treeSet.add("g");
+ let res1 = treeSet.remove("c");
+ expect(res1).assertEqual(true);
+ let res2 = treeSet.has("c");
+ expect(res2).assertEqual(false);
+ });
+ it("SR000GGR3I_testRemove013_2", 0, function () {
+ let treeSet = new TreeSet();
+ let res = treeSet.remove("c");
+ expect(res).assertEqual(false);
+ });
+ it("SR000GGR3I_testValues014", 0, function () {
+ let treeSet = new TreeSet();
+ treeSet.add("a");
+ treeSet.add("b");
+ treeSet.add("c");
+ treeSet.add("d");
+ treeSet.add("g");
+ let res = treeSet.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("g");
+ });
+ it("SR000GGR3I_testForEach015", 0, function () {
+ let treeSet = new TreeSet();
+ treeSet.add(0);
+ treeSet.add(1);
+ treeSet.add(2);
+ treeSet.add(3);
+ treeSet.add(4);
+ let arr1 = [];
+ treeSet.forEach((value, key) => {
+ arr1.push(value);
+ });
+ let arr = [0, 1, 2, 3, 4];
+ for (let i = 0; i < arr1.length; i++) {
+ expect(arr[i]).assertEqual(arr1[i]);
+ }
+ });
+ it("SR000GGR3I_testEntries016", 0, function () {
+ let treeSet = new TreeSet();
+ treeSet.add("a");
+ treeSet.add("b");
+ treeSet.add("c");
+ treeSet.add("d");
+ treeSet.add("g");
+ let res = treeSet.entries();
+ expect(JSON.stringify(res.next().value)).assertEqual('["a","a"]');
+ expect(JSON.stringify(res.next().value)).assertEqual('["b","b"]');
+ expect(JSON.stringify(res.next().value)).assertEqual('["c","c"]');
+ expect(JSON.stringify(res.next().value)).assertEqual('["d","d"]');
+ expect(JSON.stringify(res.next().value)).assertEqual('["g","g"]');
+ });
+ it("SR000GGR3I_testIterator017", 0, function () {
+ let treeSet = new TreeSet();
+ treeSet.add(0);
+ treeSet.add(1);
+ treeSet.add(2);
+ treeSet.add(3);
+ treeSet.add(4);
+ let arr = [];
+ for (let item of treeSet) {
+ arr.push(item);
+ }
+ let arr1 = [0, 1, 2, 3, 4];
+ for (let i = 0; i < arr1.length; i++) {
+ expect(arr[i]).assertEqual(arr1[i]);
+ }
+ });
+ it("SR000GGR3I_testIterator018", 0, function () {
+ let treeSet = new TreeSet();
+ treeSet.add(0);
+ treeSet.add(1);
+ treeSet.add(2);
+ treeSet.add(3);
+ treeSet.add(4);
+ let arr = [];
+ let res = treeSet[Symbol.iterator]();
+ let temp = undefined;
+ do {
+ temp = res.next().value;
+ arr.push(temp);
+ } while (temp != undefined);
+ let arr1 = [0, 1, 2, 3, 4];
+ for (let i = 0; i < arr1.length; i++) {
+ expect(arr[i]).assertEqual(arr1[i]);
+ }
+ });
+});
diff --git a/compileruntime/containerRelation_lib_standard/src/main/resources/base/element/string.json b/compileruntime/containerRelation_lib_standard/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..0bae6bd40f7360d5d818998221b199d3ec0f69c0
--- /dev/null
+++ b/compileruntime/containerRelation_lib_standard/src/main/resources/base/element/string.json
@@ -0,0 +1,12 @@
+{
+ "string": [
+ {
+ "name": "entry_MainAbility",
+ "value": "entry_MainAbility"
+ },
+ {
+ "name": "mainability_description",
+ "value": "JS_Empty Ability"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/compileruntime/containerRelation_lib_standard/src/main/resources/base/media/icon.png b/compileruntime/containerRelation_lib_standard/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/compileruntime/containerRelation_lib_standard/src/main/resources/base/media/icon.png differ