未验证 提交 256ead9a 编写于 作者: O openharmony_ci 提交者: Gitee

!3637 Delete number sensitive information

Merge pull request !3637 from wangyong/six_XTS
......@@ -16,7 +16,13 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
import ArrayList from "@ohos.util.ArrayList";
describe("ArraylistTest", function () {
it("SR000GGR44_testConstructor001", 0, function () {
/**
* @tc.name: testConstructor001
* @tc.desc: Create an ArrayList instance. For example: let arrayList = new ArrayList().
* @tc.author: wangyong
*/
it("testConstructor001", 0, function () {
try {
let arrayList = new ArrayList();
expect(arrayList != undefined).assertEqual(true);
......@@ -25,40 +31,79 @@ describe("ArraylistTest", function () {
expect(err.message).assertEqual("Cannot create new arrayList");
}
});
it("SR000GGR44_testAdd002", 0, function () {
/**
* @tc.name: testAdd002
* @tc.desc: Add a string type element to the end of the ArrayList instance. For example: arrayList.add("四").
* @tc.author: wangyong
*/
it("testAdd002", 0, function () {
let arrayList = new ArrayList();
arrayList.add("");
let res = arrayList.has("");
expect(res).assertEqual(true);
});
it("SR000GGR44_testAdd003", 0, function () {
/**
* @tc.name: testAdd003
* @tc.desc: Add a number type element to the end of the ArrayList instance. For example: arrayList.add(8).
* @tc.author: wangyong
*/
it("testAdd003", 0, function () {
let arrayList = new ArrayList();
arrayList.add(8);
let res = arrayList.has(8);
expect(res).assertEqual(true);
});
it("SR000GGR44_testAdd004 ", 0, function () {
/**
* @tc.name: testAdd004
* @tc.desc: Add a object type element to the end of the ArrayList instance.
* For example: let a = {name: "lala", age: "13岁"}; arrayList.add(a).
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testAdd005
* @tc.desc: Add a array type element to the end of the ArrayList instance.
* For example: let a = [1, 2, 3, 4]; arrayList.add(a).
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testAdd006
* @tc.desc: Add a boolean type element to the end of the ArrayList instance.
* For example: let a = true; arrayList.add(a).
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testInsert007
* @tc.desc: Insert an element into the middle of the ArrayList instance. For example: arrayList.insert(8, 2).
* @tc.author: wangyong
*/
it("testInsert007", 0, function () {
let arrayList = new ArrayList();
arrayList.add("");
arrayList.add("");
......@@ -74,7 +119,13 @@ describe("ArraylistTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR44_testLength008", 0, function () {
/**
* @tc.name: testLength008
* @tc.desc: Get the number of elements contained in the ArrayList instance. For example: arrayList.length.
* @tc.author: wangyong
*/
it("testLength008", 0, function () {
let arrayList = new ArrayList();
arrayList.add("");
arrayList.add("");
......@@ -84,7 +135,13 @@ describe("ArraylistTest", function () {
let res = arrayList.length;
expect(res).assertEqual(5);
});
it("SR000GGR44_testHas009", 0, function () {
/**
* @tc.name: testHas009
* @tc.desc: Check whether the ArrayList contains a specified element. For example: arrayList.has(8).
* @tc.author: wangyong
*/
it("testHas009", 0, function () {
let arrayList = new ArrayList();
arrayList.add("");
arrayList.add("");
......@@ -94,7 +151,14 @@ describe("ArraylistTest", function () {
let res = arrayList.has(8);
expect(res).assertEqual(true);
});
it("SR000GGR44_testGetIndexOf010", 0, function () {
/**
* @tc.name: testGetIndexOf010
* @tc.desc: In the ArrayList instance, find the index of a specified element from front to back,
* and return the index found for the first time. If not found, return -1. For example: arrayList.getIndexOf(1).
* @tc.author: wangyong
*/
it("testGetIndexOf010", 0, function () {
let arrayList = new ArrayList();
arrayList.add(1);
arrayList.add("");
......@@ -104,7 +168,14 @@ describe("ArraylistTest", function () {
let res1 = arrayList.getIndexOf(1);
expect(res1).assertEqual(0);
});
it("SR000GGR44_testRemoveByIndex011", 0, function () {
/**
* @tc.name: testRemoveByIndex011
* @tc.desc: In the ArrayList instance, delete the element based on its index.
* For example: arrayList.removeByIndex(2).
* @tc.author: wangyong
*/
it("testRemoveByIndex011", 0, function () {
let arrayList = new ArrayList();
arrayList.add("");
arrayList.add("");
......@@ -120,7 +191,13 @@ describe("ArraylistTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR44_testRemove012", 0, function () {
/**
* @tc.name: testRemove012
* @tc.desc: Delete the specified element . For example: arrayList.remove("三").
* @tc.author: wangyong
*/
it("testRemove012", 0, function () {
let arrayList = new ArrayList();
arrayList.add("");
arrayList.add("");
......@@ -130,7 +207,14 @@ describe("ArraylistTest", function () {
let res = arrayList.has("");
expect(res).assertEqual(false);
});
it("SR000GGR44_testGetLastIndexOf013", 0, function () {
/**
* @tc.name: testGetLastIndexOf013
* @tc.desc: In the ArrayList instance, find the index of a specified element from brack to front,
* and return the index found for the first time. If not found, return -1. For example: arrayList.add("四").
* @tc.author: wangyong
*/
it("testGetLastIndexOf013", 0, function () {
let arrayList = new ArrayList();
arrayList.add("");
arrayList.add("");
......@@ -141,7 +225,14 @@ describe("ArraylistTest", function () {
let res = arrayList.getLastIndexOf(1);
expect(res).assertEqual(4);
});
it("SR000GGR44_testRemoveByRange014", 0, function () {
/**
* @tc.name: testRemoveByRange014
* @tc.desc: Deletes elements from a specified range, including elements at the start position and
* elements at the end position. For example: arrayList.removeByRange(1, 3).
* @tc.author: wangyong
*/
it("testRemoveByRange014", 0, function () {
let arrayList = new ArrayList();
arrayList.add("");
arrayList.add("");
......@@ -161,7 +252,14 @@ describe("ArraylistTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR44_testReplaceAllElements015", 0, function () {
/**
* @tc.name: testReplaceAllElements015
* @tc.desc: Perform some operation on the elements in the ArrayList instance and return the ArrayList instance
* after the operation. For example: arrayList.replaceAllElements((item, index) => {return (item = 2 * item);}).
* @tc.author: wangyong
*/
it("testReplaceAllElements015", 0, function () {
let arrayList = new ArrayList();
arrayList.add(4);
arrayList.add(3);
......@@ -180,7 +278,14 @@ describe("ArraylistTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR44_testForEach016", 0, function () {
/**
* @tc.name: testForEach016
* @tc.desc: Traversing elements in an ArrayList instance.
* For example: arrayList.forEach((item, index) => {arr.push(item);}).
* @tc.author: wangyong
*/
it("testForEach016", 0, function () {
let arrayList = new ArrayList();
arrayList.add(4);
arrayList.add(3);
......@@ -196,7 +301,14 @@ describe("ArraylistTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR44_testSubArrayList017", 0, function () {
/**
* @tc.name: testSubArrayList017
* @tc.desc: Intercepts an element within the specified range, including the element with the
* starting index but not the element with the ending index. For example: arrayList.subArrayList(2, 4).
* @tc.author: wangyong
*/
it("testSubArrayList017", 0, function () {
let arrayList = new ArrayList();
arrayList.add(4);
arrayList.add(3);
......@@ -213,7 +325,13 @@ describe("ArraylistTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR44_testClear018", 0, function () {
/**
* @tc.name: testClear018
* @tc.desc: Clear all elements in the ArrayList instance. For example: arrayList.clear().
* @tc.author: wangyong
*/
it("testClear018", 0, function () {
let arrayList = new ArrayList();
arrayList.add(4);
arrayList.add(3);
......@@ -224,7 +342,13 @@ describe("ArraylistTest", function () {
let res = arrayList.length;
expect(res).assertEqual(0);
});
it("SR000GGR44_testConvertToArray19", 0, function () {
/**
* @tc.name: testConvertToArray19
* @tc.desc: Convert an ArrayList instance to an array. For example: arrayList.convertToArray().
* @tc.author: wangyong
*/
it("testConvertToArray19", 0, function () {
let arrayList = new ArrayList();
arrayList.add(4);
arrayList.add(3);
......@@ -237,7 +361,13 @@ describe("ArraylistTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR44_testClone020", 0, function () {
/**
* @tc.name: testClone020
* @tc.desc: Clone an ArrayList instance. For example: arrayList.clone().
* @tc.author: wangyong
*/
it("testClone020", 0, function () {
let arrayList = new ArrayList();
arrayList.add(4);
arrayList.add(3);
......@@ -254,7 +384,13 @@ describe("ArraylistTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR44_testGetCapacity021", 0, function () {
/**
* @tc.name: testGetCapacity021
* @tc.desc: Get the capacity of ArrayList instance. For example: arrayList.getCapacity().
* @tc.author: wangyong
*/
it("testGetCapacity021", 0, function () {
let arrayList = new ArrayList();
arrayList.add(4);
arrayList.add(3);
......@@ -264,7 +400,14 @@ describe("ArraylistTest", function () {
let res = arrayList.getCapacity();
expect(res).assertEqual(10);
});
it("SR000GGR44_testGetCapacity022", 0, function () {
/**
* @tc.name: testGetCapacity022
* @tc.desc: Get the capacity of the ArrayList instance after capacity expansion.
* For example: arrayList.getCapacity().
* @tc.author: wangyong
*/
it("testGetCapacity022", 0, function () {
let arrayList = new ArrayList();
arrayList.add(4);
arrayList.add(3);
......@@ -281,7 +424,14 @@ describe("ArraylistTest", function () {
let res = arrayList.getCapacity();
expect(res).assertEqual(15);
});
it("SR000GGR44_testIncreaseCapacityTo023", 0, function () {
/**
* @tc.name: testIncreaseCapacityTo023
* @tc.desc: Expand the ArrayList instance capacity to the specified value.
* For example: arrayList.increaseCapacityTo(8).
* @tc.author: wangyong
*/
it("testIncreaseCapacityTo023", 0, function () {
let arrayList = new ArrayList();
arrayList.add(4);
arrayList.add(3);
......@@ -292,7 +442,14 @@ describe("ArraylistTest", function () {
let res = arrayList.getCapacity();
expect(res).assertEqual(8);
});
it("SR000GGR44_testTrimToCurrentLength024", 0, function () {
/**
* @tc.name: testTrimToCurrentLength024
* @tc.desc: Limit the ArrayList instance capacity to the length of the ArrayList instance.
* For example: arrayList.trimToCurrentLength().
* @tc.author: wangyong
*/
it("testTrimToCurrentLength024", 0, function () {
let arrayList = new ArrayList();
arrayList.add(4);
arrayList.add(3);
......@@ -303,7 +460,14 @@ describe("ArraylistTest", function () {
let res = arrayList.getCapacity();
expect(res).assertEqual(5);
});
it("SR000GGR44_testIterator025", 0, function () {
/**
* @tc.name: testIterator025
* @tc.desc: Iterates over all elements in an ArrayList instance.
* For example: for (let item of arrayList) {arr.push(item);}.
* @tc.author: wangyong
*/
it("testIterator025", 0, function () {
let arrayList = new ArrayList();
arrayList.add(8);
arrayList.add("");
......@@ -323,7 +487,14 @@ describe("ArraylistTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR44_testSort026", 0, function () {
/**
* @tc.name: testSort026
* @tc.desc: Arrange the elements in the ArrayList instance in descending order.
* For example: arrayList.sort((a, b) => a - b).
* @tc.author: wangyong
*/
it("testSort026", 0, function () {
let arrayList = new ArrayList();
arrayList.add(4);
arrayList.add(3);
......@@ -340,7 +511,14 @@ describe("ArraylistTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR44_testInsert0027", 0, function () {
/**
* @tc.name: testInsert0027
* @tc.desc: Inserting an element with an index less than 0 will throw an exception.
* For example: arrayList.insert(8, -1).
* @tc.author: wangyong
*/
it("testInsert0027", 0, function () {
let arrayList = new ArrayList();
arrayList.add("");
arrayList.add("");
......@@ -357,7 +535,14 @@ describe("ArraylistTest", function () {
}
}
});
it("SR000GGR44_testInsert0028", 0, function () {
/**
* @tc.name: testInsert028
* @tc.desc: Inserting an element with an index greater than or equal to the length of
* the ArrayList instance will throw an exception. For example: arrayList.insert(8, 10).
* @tc.author: wangyong
*/
it("testInsert028", 0, function () {
let arrayList = new ArrayList();
arrayList.add("");
arrayList.add("");
......@@ -374,7 +559,14 @@ describe("ArraylistTest", function () {
}
}
});
it("SR000GGR44_testInsert029", 0, function () {
/**
* @tc.name: testInsert029
* @tc.desc: Inserting an element with an index greater than or equal to the length of
* the ArrayList instance will throw an exception. For example: arrayList.insert(8, 11).
* @tc.author: wangyong
*/
it("testInsert029", 0, function () {
let arrayList = new ArrayList();
arrayList.add("");
arrayList.add("");
......@@ -391,7 +583,13 @@ describe("ArraylistTest", function () {
}
}
});
it("SR000GGR44_testisEmpty030", 0, function () {
/**
* @tc.name: testIsEmpty030
* @tc.desc: Determine whether the ArrayList instance is empty. For example: arrayList.isEmpty().
* @tc.author: wangyong
*/
it("testIsEmpty030", 0, function () {
let arrayList = new ArrayList();
arrayList.add(4);
arrayList.add(3);
......@@ -402,7 +600,13 @@ describe("ArraylistTest", function () {
let res = arrayList.isEmpty();
expect(res).assertEqual(true);
});
it("SR000GGR44_testisEmpty031", 0, function () {
/**
* @tc.name: testIsEmpty031
* @tc.desc: Determine whether the ArrayList instance is empty. For example: arrayList.isEmpty().
* @tc.author: wangyong
*/
it("testIsEmpty031", 0, function () {
let arrayList = new ArrayList();
arrayList.add(4);
arrayList.add(3);
......@@ -412,7 +616,13 @@ describe("ArraylistTest", function () {
let res = arrayList.isEmpty();
expect(res).assertEqual(false);
});
it("SR000GGR44_testHas032", 0, function () {
/**
* @tc.name: testHas032
* @tc.desc: Check whether the ArrayList contains a specified element. For example: arrayList.has("二").
* @tc.author: wangyong
*/
it("testHas032", 0, function () {
let arrayList = new ArrayList();
arrayList.add("");
arrayList.add("");
......@@ -422,7 +632,14 @@ describe("ArraylistTest", function () {
let res = arrayList.has("");
expect(res).assertEqual(false);
});
it("SR000GGR44_testGetIndexOf033", 0, function () {
/**
* @tc.name: testGetIndexOf033
* @tc.desc: In the ArrayList instance, find the index of a specified element from front to back,
* and return the index found for the first time. If not found, return -1. For example: arrayList.getIndexOf("A").
* @tc.author: wangyong
*/
it("testGetIndexOf033", 0, function () {
let arrayList = new ArrayList();
arrayList.add(1);
arrayList.add("");
......@@ -432,7 +649,13 @@ describe("ArraylistTest", function () {
let res = arrayList.getIndexOf("A");
expect(res).assertEqual(-1);
});
it("SR000GGR44_testRemove034", 0, function () {
/**
* @tc.name: testRemove034
* @tc.desc: Delete the specified element.For example: arrayList.remove("A").
* @tc.author: wangyong
*/
it("testRemove034", 0, function () {
let arrayList = new ArrayList();
arrayList.add("");
arrayList.add("");
......@@ -441,7 +664,14 @@ describe("ArraylistTest", function () {
let res = arrayList.remove("A");
expect(res).assertEqual(false);
});
it("SR000GGR44_testRemoveByIndex035", 0, function () {
/**
* @tc.name: testRemove035
* @tc.desc: Delete the specified element.
* For example: arrayList.forEach((item, index) => {if (item == 1) {arrayList.remove(item);}}).
* @tc.author: wangyong
*/
it("testRemove035", 0, function () {
let arrayList = new ArrayList();
arrayList.add(0);
arrayList.add(1);
......@@ -463,7 +693,14 @@ describe("ArraylistTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR44_testRemoveByIndex036", 0, function () {
/**
* @tc.name: testRemoveByIndex036
* @tc.desc: In the ArrayList instance, delete the element based on its index index.
* For example: arrayList.removeByIndex(5).
* @tc.author: wangyong
*/
it("testRemoveByIndex036", 0, function () {
let arrayList = new ArrayList();
arrayList.add("a");
arrayList.add("b");
......@@ -481,7 +718,13 @@ describe("ArraylistTest", function () {
}
}
});
it("SR000GGR44_testRemoveByRange037", 0, function () {
/**
* @tc.name: testRemoveByRange037
* @tc.desc: Add a string element to the end of the ArrayList instance. For example: arrayList.add("四").
* @tc.author: wangyong
*/
it("testRemoveByRange037", 0, function () {
let arrayList = new ArrayList();
arrayList.add("");
arrayList.add("");
......@@ -502,7 +745,14 @@ describe("ArraylistTest", function () {
}
}
});
it("SR000GGR44_testRemoveByRange038", 0, function () {
/**
* @tc.name: testRemoveByRange038
* @tc.desc: Deletes elements from a specified range, including elements at the start position and
* elements at the end position. For example: removeByRange(6, 8).
* @tc.author: wangyong
*/
it("testRemoveByRange038", 0, function () {
let arrayList = new ArrayList();
arrayList.add("");
arrayList.add("");
......@@ -520,7 +770,14 @@ describe("ArraylistTest", function () {
}
}
});
it("SR000GGR44_testRemoveByRange039", 0, function () {
/**
* @tc.name: testRemoveByRange039
* @tc.desc: Deletes elements from a specified range, including elements at the start position and
* elements at the end position. For example: removeByRange(0, 9).
* @tc.author: wangyong
*/
it("testRemoveByRange039", 0, function () {
let arrayList = new ArrayList();
arrayList.add("");
arrayList.add("");
......@@ -536,7 +793,14 @@ describe("ArraylistTest", function () {
expect(res).assertEqual(0);
expect(res1).assertEqual(-1);
});
it("SR000GGR44_testSubArrayList040", 0, function () {
/**
* @tc.name: testSubArrayList040
* @tc.desc: Intercepts an element within the specified range, including the element with the
* starting index but not the element with the ending index. For example: arrayList.subArrayList(4, 2).
* @tc.author: wangyong
*/
it("testSubArrayList040", 0, function () {
let arrayList = new ArrayList();
arrayList.add(4);
arrayList.add(3);
......@@ -554,7 +818,14 @@ describe("ArraylistTest", function () {
}
}
});
it("SR000GGR44_testSubArrayList041", 0, function () {
/**
* @tc.name: testSubArrayList041
* @tc.desc: Intercepts an element within the specified range, including the element with the
* starting index but not the element with the ending index. For example: arrayList.subArrayList(0 ,6).
* @tc.author: wangyong
*/
it("testSubArrayList041", 0, function () {
let arrayList = new ArrayList();
arrayList.add(4);
arrayList.add(3);
......@@ -571,7 +842,14 @@ describe("ArraylistTest", function () {
expect(a[i]).assertEqual(arr[i]);
}
});
it("SR000GGR44_testSubArrayList042", 0, function () {
/**
* @tc.name: testSubArrayList042
* @tc.desc: Intercepts an element within the specified range, including the element with the
* starting index but not the element with the ending index. For example: arrayList.subArrayList(6, 9).
* @tc.author: wangyong
*/
it("testSubArrayList042", 0, function () {
let arrayList = new ArrayList();
arrayList.add(4);
arrayList.add(3);
......@@ -589,7 +867,14 @@ describe("ArraylistTest", function () {
}
}
});
it("SR000GGR44_testIncreaseCapacityTo043", 0, function () {
/**
* @tc.name: testIncreaseCapacityTo043
* @tc.desc: Expand the ArrayList instance capacity to the specified value.
* For example: arrayList.increaseCapacityTo(-1).
* @tc.author: wangyong
*/
it("testIncreaseCapacityTo043", 0, function () {
let arrayList = new ArrayList();
arrayList.add(4);
arrayList.add(3);
......@@ -600,7 +885,14 @@ describe("ArraylistTest", function () {
let res = arrayList.getCapacity();
expect(res).assertEqual(10);
});
it("SR000GGR44_testIncreaseCapacityTo044", 0, function () {
/**
* @tc.name: testIncreaseCapacityTo044
* @tc.desc: Expand the ArrayList instance capacity to the specified value.
* For example: arrayList.increaseCapacityTo().
* @tc.author: wangyong
*/
it("testIncreaseCapacityTo044", 0, function () {
let arrayList = new ArrayList();
arrayList.add(4);
arrayList.add(3);
......@@ -618,7 +910,14 @@ describe("ArraylistTest", function () {
}
}
});
it("SR000GGR44_testAdd045", 0, function () {
/**
* @tc.name: testAdd045
* @tc.desc: Add a string element to the end of the ArrayList instance.
* For example: for (let i = 0; i < 100; i++) {arrayList.add(i);}.
* @tc.author: wangyong
*/
it("testAdd045", 0, function () {
let arrayList = new ArrayList();
for (let i = 0; i < 100; i++) {
arrayList.add(i);
......@@ -628,28 +927,55 @@ describe("ArraylistTest", function () {
expect(res).assertEqual(99);
expect(res1).assertEqual(100);
});
it("SR000GGR44_testAdd046", 0, function () {
/**
* @tc.name: testAdd046
* @tc.desc: Add a symbol type element to the end of the ArrayList instance.
* For example: let a = "*";arrayList.add(a).
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testAdd047
* @tc.desc: Add a decimal type to the end of the ArrayList instance. For example: let a = "3.14";arrayList.add(a).
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testAdd048
* @tc.desc: Add a null character element to the end of the ArrayList instance.
* For example: let a = "";arrayList.add(a).
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testSort049
* @tc.desc: Arrange the elements in the ArrayList instance in descending order.
* For example: arrayList.sort((a, b) => a - b).
* @tc.author: wangyong
*/
it("testSort049", 0, function () {
let arrayList = new ArrayList();
arrayList.add("");
arrayList.add("张三");
......@@ -666,7 +992,14 @@ describe("ArraylistTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR44_testSort050", 0, function () {
/**
* @tc.name: testSort050
* @tc.desc: Arrange the elements in the ArrayList instance in descending order.
* For example: arrayList.sort((a, b) => a - b).
* @tc.author: wangyong
*/
it("testSort050", 0, function () {
let arrayList = new ArrayList();
arrayList.add("c");
arrayList.add("a");
......@@ -683,7 +1016,13 @@ describe("ArraylistTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR44_testIterator051", 0, function () {
/**
* @tc.name: testIterator051
* @tc.desc: Iterates over all elements in an ArrayList instance. For example: arrayList[Symbol.iterator]().
* @tc.author: wangyong
*/
it("testIterator051", 0, function () {
let arrayList = new ArrayList();
arrayList.add("");
arrayList.add("张三");
......@@ -702,7 +1041,14 @@ describe("ArraylistTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR44_testRemoveByRange052", 0, function () {
/**
* @tc.name: testRemoveByRange052
* @tc.desc: Deletes elements from a specified range, including elements at the start position and
* elements at the end position. For example: removeByRange(0, 8).
* @tc.author: wangyong
*/
it("testRemoveByRange052", 0, function () {
let arrayList = new ArrayList();
arrayList.add("");
arrayList.add("");
......
......@@ -16,7 +16,13 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
import Deque from "@ohos.util.Deque";
describe("DequeTest", function () {
it("SR000GGR3K_testConstructor001", 0, function () {
/**
* @tc.name: testConstructor001
* @tc.desc: Create an Deque instance. For example: let deque = new Deque().
* @tc.author: wangyong
*/
it("testConstructor001", 0, function () {
try {
let deque = new Deque();
} catch (err) {
......@@ -24,86 +30,165 @@ describe("DequeTest", function () {
expect(err.message).assertEqual("Cannot create new deque");
}
});
it("SR000GGR3K_testInsertFront001", 0, function () {
/**
* @tc.name: testInsertFront002
* @tc.desc: Add element to deque instance header. For example: deque.insertFront("一").
* @tc.author: wangyong
*/
it("testInsertFront002", 0, function () {
let deque = new Deque();
deque.insertFront("");
let res = deque.getFirst();
expect(res).assertEqual("");
});
it("SR000GGR3K_testInsertFront002", 0, function () {
/**
* @tc.name: testInsertFront003
* @tc.desc: Add element to deque instance header. For example: deque.insertFront(8).
* @tc.author: wangyong
*/
it("testInsertFront003", 0, function () {
let deque = new Deque();
deque.insertFront(8);
let res = deque.getFirst();
expect(res).assertEqual(8);
});
it("SR000GGR3K_testInsertFront003", 0, function () {
/**
* @tc.name: testInsertFront004
* @tc.desc: Add element to deque instance header.
* For example: let a = {name: "lala", age: "15"}; deque.insertFront(a).
* @tc.author: wangyong
*/
it("testInsertFront004", 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 () {
/**
* @tc.name: testInsertFront005
* @tc.desc: Add element to deque instance header. For example: let a = [1, 2, 3, 4]; deque.insertFront(a).
* @tc.author: wangyong
*/
it("testInsertFront005", 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 () {
/**
* @tc.name: testInsertEnd006
* @tc.desc: Add element to deque instance end. For example: deque.insertEnd(8).
* @tc.author: wangyong
*/
it("testInsertEnd006", 0, function () {
let deque = new Deque();
deque.insertEnd(8);
let res = deque.getLast();
expect(res).assertEqual(8);
});
it("SR000GGR3K_testInsertEnd006", 0, function () {
/**
* @tc.name: testInsertEnd007
* @tc.desc: Add element to deque instance end. For example: let a = ["a", "b", "c"];deque.insertEnd(a).
* @tc.author: wangyong
*/
it("testInsertEnd007", 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 () {
/**
* @tc.name: testInsertEnd008
* @tc.desc: Add element to deque instance end. For example: let a = {class: "6班", say: "we"};deque.insertEnd(a).
* @tc.author: wangyong
*/
it("testInsertEnd008", 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 () {
/**
* @tc.name: testGetFirst009
* @tc.desc: Get the header element of the deque instance. For example: deque.getFirst().
* @tc.author: wangyong
*/
it("testGetFirst009", 0, function () {
let deque = new Deque();
deque.insertEnd("");
deque.insertEnd("");
let res = deque.getFirst();
expect(res).assertEqual("");
});
it("SR000GGR3K_testGetLast008", 0, function () {
/**
* @tc.name: testGetLast010
* @tc.desc: Get the end element of the deque instance. For example: deque.getLast().
* @tc.author: wangyong
*/
it("testGetLast010", 0, function () {
let deque = new Deque();
deque.insertEnd(8);
deque.insertEnd("");
let res = deque.getLast();
expect(res).assertEqual("");
});
it("SR000GGR3K_testHas009", 0, function () {
/**
* @tc.name: testHas011
* @tc.desc: Determine whether the deque instance contains the specified element. For example: deque.has(6).
* @tc.author: wangyong
*/
it("testHas011", 0, function () {
let deque = new Deque();
deque.insertEnd(6);
let res = deque.has(6);
expect(res).assertEqual(true);
});
it("SR000GGR3K_testHas010", 0, function () {
/**
* @tc.name: testHas012
* @tc.desc: Determine whether the deque instance contains the specified element. For example: deque.has(6).
* @tc.author: wangyong
*/
it("testHas012", 0, function () {
let deque = new Deque();
deque.insertEnd(8);
let res = deque.has(6);
expect(res).assertEqual(false);
});
it("SR000GGR3K_testPopFirst011", 0, function () {
/**
* @tc.name: testPopFirst013
* @tc.desc: Delete the header element of a deque instance. For example: deque.popFirst().
* @tc.author: wangyong
*/
it("testPopFirst013", 0, function () {
let deque = new Deque();
deque.insertEnd(8);
deque.insertFront("");
let res = deque.popFirst();
expect(res).assertEqual("");
});
it("SR000GGR3K_testPopLast012", 0, function () {
/**
* @tc.name: testPopLast014
* @tc.desc: Delete the end element of a deque instance. For example: deque.popLast().
* @tc.author: wangyong
*/
it("testPopLast014", 0, function () {
let deque = new Deque();
deque.insertEnd(8);
deque.insertFront("");
......@@ -111,7 +196,13 @@ describe("DequeTest", function () {
let res = deque.popLast();
expect(res).assertEqual(8);
});
it("SR000GGR3K_testForEach013", 0, function () {
/**
* @tc.name: testForEach015
* @tc.desc: Traversing elements in deque instances. For example: deque.forEach((item, index) => {arr.push(item);}).
* @tc.author: wangyong
*/
it("testForEach015", 0, function () {
let deque = new Deque();
deque.insertEnd(8);
deque.insertFront("");
......@@ -133,7 +224,13 @@ describe("DequeTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR3K_testIterator014", 0, function () {
/**
* @tc.name: testIterator016
* @tc.desc: Iterate over all elements in the deque instance. For example: for (let item of deque) { arr.push(item);}.
* @tc.author: wangyong
*/
it("testIterator016", 0, function () {
let deque = new Deque();
deque.insertEnd(8);
deque.insertFront("");
......@@ -151,31 +248,61 @@ describe("DequeTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR3K_testInsertFront015", 0, function () {
/**
* @tc.name: testInsertFront017
* @tc.desc: Add element to deque instance header. For example: deque.insertFront("$").
* @tc.author: wangyong
*/
it("testInsertFront017", 0, function () {
let deque = new Deque();
deque.insertFront("$");
let res = deque.getFirst();
expect(res).assertEqual("$");
});
it("SR000GGR3K_testInsertFront016", 0, function () {
/**
* @tc.name: testInsertFront018
* @tc.desc: Add element to deque instance header. For example: deque.insertFront(" ").
* @tc.author: wangyong
*/
it("testInsertFront018", 0, function () {
let deque = new Deque();
deque.insertFront(" ");
let res = deque.getFirst();
expect(res).assertEqual(" ");
});
it("SR000GGR3K_testInsertFront017", 0, function () {
/**
* @tc.name: testInsertFront019
* @tc.desc: Add element to deque instance header. For example: deque.insertFront(null).
* @tc.author: wangyong
*/
it("testInsertFront019", 0, function () {
let deque = new Deque();
deque.insertFront(null);
let res = deque.getFirst();
expect(res).assertEqual(null);
});
it("SR000GGR3K_testInsertFront018", 0, function () {
/**
* @tc.name: testInsertFront020
* @tc.desc: Add element to deque instance header. For example: deque.insertFront(undefined).
* @tc.author: wangyong
*/
it("testInsertFront020", 0, function () {
let deque = new Deque();
deque.insertFront(undefined);
let res = deque.getFirst();
expect(res).assertEqual(undefined);
});
it("SR000GGR3K_testInsertFront019", 0, function () {
/**
* @tc.name: testInsertFront021
* @tc.desc: Add element to deque instance header. For example: for (let i = 0; i < 100; i++) {deque.insertFront(i)}.
* @tc.author: wangyong
*/
it("testInsertFront021", 0, function () {
let deque = new Deque();
for (let i = 0; i < 100; i++) {
deque.insertFront(i);
......@@ -185,31 +312,61 @@ describe("DequeTest", function () {
let res1 = deque.length;
expect(res1).assertEqual(100);
});
it("SR000GGR3K_testInsertEnd020", 0, function () {
/**
* @tc.name: testInsertEnd022
* @tc.desc: Add element to deque instance end. For example: deque.insertEnd("$").
* @tc.author: wangyong
*/
it("testInsertEnd022", 0, function () {
let deque = new Deque();
deque.insertEnd("$");
let res = deque.getLast();
expect(res).assertEqual("$");
});
it("SR000GGR3K_testInsertEnd021", 0, function () {
/**
* @tc.name: testInsertEnd023
* @tc.desc: Add element to deque instance end. For example: deque.insertEnd(" ").
* @tc.author: wangyong
*/
it("testInsertEnd023", 0, function () {
let deque = new Deque();
deque.insertEnd(" ");
let res = deque.getLast();
expect(res).assertEqual(" ");
});
it("SR000GGR3K_testInsertEnd022", 0, function () {
/**
* @tc.name: testInsertEnd024
* @tc.desc: Add element to deque instance end. For example: deque.insertEnd(null).
* @tc.author: wangyong
*/
it("testInsertEnd024", 0, function () {
let deque = new Deque();
deque.insertEnd(null);
let res = deque.getLast();
expect(res).assertEqual(null);
});
it("SR000GGR3K_testInsertEnd023", 0, function () {
/**
* @tc.name: testInsertEnd025
* @tc.desc: Add element to deque instance end. For example: deque.insertEnd(undefined).
* @tc.author: wangyong
*/
it("testInsertEnd025", 0, function () {
let deque = new Deque();
deque.insertEnd(undefined);
let res = deque.getLast();
expect(res).assertEqual(undefined);
});
it("SR000GGR3K_testInsertFront024", 0, function () {
/**
* @tc.name: testInsertFront026
* @tc.desc: Add element to deque instance end. For example: for (let i = 0; i < 100; i++) {deque.insertEnd(i);}.
* @tc.author: wangyong
*/
it("testInsertFront026", 0, function () {
let deque = new Deque();
for (let i = 0; i < 100; i++) {
deque.insertEnd(i);
......@@ -219,32 +376,68 @@ describe("DequeTest", function () {
let res1 = deque.length;
expect(res1).assertEqual(100);
});
it("SR000GGR3K_testHas025", 0, function () {
/**
* @tc.name: testHas027
* @tc.desc: Determine whether the deque instance contains the specified element. For example: deque.has(6).
* @tc.author: wangyong
*/
it("testHas027", 0, function () {
let deque = new Deque();
let res = deque.has(6);
expect(res).assertEqual(false);
});
it("SR000GGR3K_testPopFirst026", 0, function () {
/**
* @tc.name: testPopFirst028
* @tc.desc: Delete the header element of a deque instance. For example: deque.popFirst().
* @tc.author: wangyong
*/
it("testPopFirst028", 0, function () {
let deque = new Deque();
let res = deque.popFirst();
expect(res).assertEqual(undefined);
});
it("SR000GGR3K_testGetFirst027", 0, function () {
/**
* @tc.name: testGetFirst029
* @tc.desc: Get the header element of the deque instance. For example: deque.getFirst().
* @tc.author: wangyong
*/
it("testGetFirst029", 0, function () {
let deque = new Deque();
let res = deque.getFirst();
expect(res).assertEqual(undefined);
});
it("SR000GGR3K_testPopLast028", 0, function () {
/**
* @tc.name: testPopLast030
* @tc.desc: Delete the end element of a deque instance. For example: deque.popLast().
* @tc.author: wangyong
*/
it("testPopLast030", 0, function () {
let deque = new Deque();
let res = deque.popLast();
expect(res).assertEqual(undefined);
});
it("SR000GGR3K_testGetLast029", 0, function () {
/**
* @tc.name: testGetLast031
* @tc.desc: Get the end element of the deque instance. For example: deque.getLast().
* @tc.author: wangyong
*/
it("testGetLast031", 0, function () {
let deque = new Deque();
let res = deque.getLast();
expect(res).assertEqual(undefined);
});
it("SR000GGR3K_testForEach030", 0, function () {
/**
* @tc.name: testForEach032
* @tc.desc: Traversing elements in deque instances. For example: deque.forEach((item, index) => {arr.push(item);}).
* @tc.author: wangyong
*/
it("testForEach032", 0, function () {
let deque = new Deque();
deque.insertEnd(8);
deque.insertEnd(1);
......@@ -267,7 +460,13 @@ describe("DequeTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR3K_testIterator031", 0, function () {
/**
* @tc.name: testIterator033
* @tc.desc: Iterate over all elements in the deque instance. For example: for (let item of deque) { arr.push(item);}.
* @tc.author: wangyong
*/
it("testIterator033", 0, function () {
let deque = new Deque();
deque.insertEnd(8);
deque.insertFront("");
......@@ -289,7 +488,13 @@ describe("DequeTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR3K_testIterator032", 0, function () {
/**
* @tc.name: testIterator034
* @tc.desc: Iterate over all elements in the deque instance. For example: deque[Symbol.iterator]().
* @tc.author: wangyong
*/
it("testIterator034", 0, function () {
let deque = new Deque();
deque.insertEnd(8);
deque.insertFront("a");
......@@ -313,7 +518,13 @@ describe("DequeTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR3K_testLength033", 0, function () {
/**
* @tc.name: testLength035
* @tc.desc: Get the number of elements in the deque instance. For example: deque.length.
* @tc.author: wangyong
*/
it("testLength035", 0, function () {
let deque = new Deque();
deque.insertEnd(8);
deque.insertFront("a");
......
......@@ -16,7 +16,13 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
import LinkedList from "@ohos.util.LinkedList";
describe("LinkedListTest", function () {
it("SR000GGR46_testConstructor001", 0, function () {
/**
* @tc.name: testConstructor001
* @tc.desc: Create an LinkedList instance. For example: let linkedList = new LinkedList().
* @tc.author: wangyong
*/
it("testConstructor001", 0, function () {
try {
let linkedList = new LinkedList();
} catch (err) {
......@@ -24,61 +30,117 @@ describe("LinkedListTest", function () {
expect(err.message).assertEqual("Cannot create new linkedList");
}
});
it("SR000GGR46_testAdd002", 0, function () {
/**
* @tc.name: testAdd002
* @tc.desc: Add a element to the end of the LinkedList instance. For example: linkedList.add("四").
* @tc.author: wangyong
*/
it("testAdd002", 0, function () {
let linkedList = new LinkedList();
linkedList.add("");
let res = linkedList.get(0);
expect(res).assertEqual("");
});
it("SR000GGR46_testAdd003", 0, function () {
/**
* @tc.name: testAdd003
* @tc.desc: Add a element to the end of the LinkedList instance. For example: linkedList.add(8).
* @tc.author: wangyong
*/
it("testAdd003", 0, function () {
let linkedList = new LinkedList();
linkedList.add(8);
let res = linkedList.get(0);
expect(res).assertEqual(8);
});
it("SR000GGR46_testAdd004", 0, function () {
/**
* @tc.name: testAdd004
* @tc.desc: Add a element to the end of the LinkedList instance.
* For example: let a = [1, 2, 3, 4];linkedList.add(a).
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testAdd005
* @tc.desc: Add a element to the end of the LinkedList instance.
* For example: let a = {name: "lala", age: "13"};linkedList.add(a).
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testAdd006
* @tc.desc: Add a element to the end of the LinkedList instance. For example: let a = ".";linkedList.add(a).
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testAdd007
* @tc.desc: Add a element to the end of the LinkedList instance. For example: let a = "*";linkedList.add(a).
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testAdd008
* @tc.desc: Add a element to the end of the LinkedList instance. For example: let a = "/";linkedList.add(a).
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testAdd009
* @tc.desc: Add a element to the end of the LinkedList instance. For example: let a = "";linkedList.add(a).
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testAdd010
* @tc.desc: Add a element to the end of the LinkedList instance. For example: let a = "a";linkedList.add(a).
* @tc.author: wangyong
*/
it("testAdd010", 0, function () {
let linkedList = new LinkedList();
let a = "a";
linkedList.add(a);
......@@ -88,7 +150,13 @@ describe("LinkedListTest", function () {
let res1 = linkedList.get(1);
expect(res1).assertEqual(a);
});
it("SR000GGR46_testHas011", 0, function () {
/**
* @tc.name: testHas011
* @tc.desc: Check whether the LinkedList contains a specified element. For example: linkedList.has("a").
* @tc.author: wangyong
*/
it("testHas011", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
......@@ -98,17 +166,23 @@ describe("LinkedListTest", function () {
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();
/**
* @tc.name: testClone012
* @tc.desc: Clone an LinkedList instance. For example: linkedList.clone().
* @tc.author: wangyong
*/
it("testClone012", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
let linkedList1 = linkedList.clone();
linkedList1.addFirst("e");
let res = linkedList1.removeLast();
expect(res).assertEqual("c");
let arr = [];
list1.forEach((item, index) => {
linkedList1.forEach((item, index) => {
arr.push(item);
});
let a = ["e", "a", "b"];
......@@ -116,7 +190,13 @@ describe("LinkedListTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR46_testAddFirst013", 0, function () {
/**
* @tc.name: testAddFirst013
* @tc.desc: Add element to LinkedList instance header. For example: linkedList.addFirst("e").
* @tc.author: wangyong
*/
it("testAddFirst013", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
......@@ -125,7 +205,13 @@ describe("LinkedListTest", function () {
let res = linkedList.get(0);
expect(res).assertEqual("e");
});
it("SR000GGR46_testRemoveFirst014", 0, function () {
/**
* @tc.name: testRemoveFirst014
* @tc.desc: Delete the header element of a LinkedList instance. For example: linkedList.removeFirst().
* @tc.author: wangyong
*/
it("testRemoveFirst014", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
......@@ -141,60 +227,99 @@ describe("LinkedListTest", function () {
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");
/**
* @tc.name: testGetLastIndexOf015
* @tc.desc: In the LinkedList instance, find the index of a specified element from brack to front,
* and return the index found for the first time. If not found, return -1.
* For example: linkedList.getLastIndexOf("a").
* @tc.author: wangyong
*/
it("testGetLastIndexOf015", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
linkedList.add("b");
let res = linkedList.getLastIndexOf("a");
expect(res).assertEqual(3);
});
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");
/**
* @tc.name: testGetLastIndexOf016
* @tc.desc: In the LinkedList instance, find the index of a specified element from brack to front,
* and return the index found for the first time. If not found, return -1.
* For example: linkedList.getLastIndexOf("f").
* @tc.author: wangyong
*/
it("testGetLastIndexOf016", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
linkedList.add("b");
let res = linkedList.getLastIndexOf("f");
expect(res).assertEqual(-1);
});
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");
/**
* @tc.name: testGetIndexOf017
* @tc.desc: In the LinkedList instance, find the index of a specified element from front to back,
* and return the index found for the first time. If not found, return -1.
* For example: linkedList.getIndexOf("b").
* @tc.author: wangyong
*/
it("testGetIndexOf017", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
linkedList.add("b");
let res = linkedList.getIndexOf("b");
expect(res).assertEqual(1);
});
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");
let res = list.getIndexOf("f");
/**
* @tc.name: testGetIndexOf018
* @tc.desc: In the LinkedList instance, find the index of a specified element from front to back,
* and return the index found for the first time. If not found, return -1.
* For example: linkedList.getIndexOf("f").
* @tc.author: wangyong
*/
it("testGetIndexOf018", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
linkedList.add("b");
let res = linkedList.getIndexOf("f");
expect(res).assertEqual(-1);
});
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);
/**
* @tc.name: testRemoveByIndex019
* @tc.desc: In the linkedList instance, delete the element based on its index.
* For example: linkedList.removeByIndex(2).
* @tc.author: wangyong
*/
it("testRemoveByIndex019", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.removeByIndex(2);
let arr = [];
list.forEach((item, index) => {
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["a", "b", "a", "b"];
......@@ -202,30 +327,43 @@ describe("LinkedListTest", function () {
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");
/**
* @tc.name: testRemoveByIndex020
* @tc.desc: In the linkedList instance, delete the element based on its subscript index.
* For example: linkedList.removeByIndex(10).
* @tc.author: wangyong
*/
it("testRemoveByIndex020", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
try {
let res = list.removeByIndex(10);
let res = linkedList.removeByIndex(10);
} catch (err) {
expect(err.name).assertEqual("RangeError");
expect(err.message).assertEqual("the index 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");
/**
* @tc.name: testRemove021
* @tc.desc: Delete the specified element. For example: linkedList.remove("a").
* @tc.author: wangyong
*/
it("testRemove021", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.remove("a");
let arr = [];
list.forEach((item, index) => {
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["b", "c", "a", "b"];
......@@ -233,31 +371,49 @@ describe("LinkedListTest", function () {
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");
/**
* @tc.name: testRemove022
* @tc.desc: Delete the specified element. For example: linkedList.remove("d").
* @tc.author: wangyong
*/
it("testRemove022", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.remove("d");
expect(res).assertEqual(false);
});
it("SR000GGR46_testRemove023", 0, function () {
let list = new LinkedList();
let res = list.remove("d");
/**
* @tc.name: testRemove023
* @tc.desc: Delete the specified element. For example: linkedList.remove("d").
* @tc.author: wangyong
*/
it("testRemove023", 0, function () {
let linkedList = new LinkedList();
let res = linkedList.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");
/**
* @tc.name: testRemoveFirstFound024
* @tc.desc: Delete the specified element found for the first time. For example: linkedList.removeFirstFound("b").
* @tc.author: wangyong
*/
it("testRemoveFirstFound024", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.removeFirstFound("b");
let arr = [];
list.forEach((item, index) => {
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["a", "c", "a", "b"];
......@@ -265,16 +421,22 @@ describe("LinkedListTest", function () {
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");
/**
* @tc.name: testRemoveLastFound025
* @tc.desc: Delete the specified element found for the last time. For example: linkedList.removeLastFound("b").
* @tc.author: wangyong
*/
it("testRemoveLastFound025", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.removeLastFound("b");
let arr = [];
list.forEach((item, index) => {
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["a", "b", "c", "a"];
......@@ -282,36 +444,54 @@ describe("LinkedListTest", function () {
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();
/**
* @tc.name: testGetFirst026
* @tc.desc: Get the header element of the linkedList instance. For example: linkedList.getFirst().
* @tc.author: wangyong
*/
it("testGetFirst026", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.getFirst();
expect(res).assertEqual("a");
});
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();
/**
* @tc.name: testGetLast027
* @tc.desc: Get the end element of the linkedList instance. For example: linkedList.getLast().
* @tc.author: wangyong
*/
it("testGetLast027", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.getLast();
expect(res).assertEqual("b");
});
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");
/**
* @tc.name: testInsert028
* @tc.desc: Insert an element into the middle of the LinkedList instance. For example: linkedList.insert(3, "d").
* @tc.author: wangyong
*/
it("testInsert028", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.insert(3, "d");
let arr = [];
list.forEach((item, index) => {
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["a", "b", "c", "d", "a", "b"];
......@@ -319,16 +499,22 @@ describe("LinkedListTest", function () {
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");
/**
* @tc.name: testInsert029
* @tc.desc: Insert an element into the middle of the LinkedList instance. For example: linkedList.insert(0, "d").
* @tc.author: wangyong
*/
it("testInsert029", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.insert(0, "d");
let arr = [];
list.forEach((item, index) => {
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["d", "a", "b", "c", "a", "b"];
......@@ -336,16 +522,22 @@ describe("LinkedListTest", function () {
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");
/**
* @tc.name: testInsert030
* @tc.desc: Insert an element into the middle of the LinkedList instance. For example: linkedList.insert(5, "d").
* @tc.author: wangyong
*/
it("testInsert030", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.insert(5, "d");
let arr = [];
list.forEach((item, index) => {
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["a", "b", "c", "a", "b", "d"];
......@@ -353,98 +545,141 @@ describe("LinkedListTest", function () {
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");
/**
* @tc.name: testInsert031
* @tc.desc: Insert an element into the middle of the LinkedList instance. For example: linkedList.insert(9, "d").
* @tc.author: wangyong
*/
it("testInsert031", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
try {
let res = list.insert(8, "d");
let res = linkedList.insert(8, "d");
} catch (err) {
expect(err.name).assertEqual("RangeError");
expect(err.message).assertEqual("the index is out-of-bounds");
}
});
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);
/**
* @tc.name: testSet032
* @tc.desc: Modify the element corresponding to the specified index. For example: linkedList.set(2, "d").
* @tc.author: wangyong
*/
it("testSet032", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
let res = linkedList.set(2, "d");
let res1 = linkedList.get(2);
expect(res1).assertEqual("d");
});
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();
/**
* @tc.name: testConvertToArray033
* @tc.desc: Convert an LinkedList instance to an array. For example: linkedList.convertToArray().
* @tc.author: wangyong
*/
it("testConvertToArray033", 0, function () {
let linkedList = new LinkedList();
linkedList.add(4);
linkedList.add(3);
linkedList.add(1);
linkedList.add(2);
linkedList.add(14);
let res = linkedList.convertToArray();
let a = [4, 3, 1, 2, 14];
for (let i = 0; i < a.length; i++) {
expect(res[i]).assertEqual(a[i]);
}
});
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;
/**
* @tc.name: testLength034
* @tc.desc: Get the number of elements in the LinkedList instance. For example: linkedList.length.
* @tc.author: wangyong
*/
it("testLength034", 0, function () {
let linkedList = new LinkedList();
linkedList.add(4);
linkedList.add(3);
linkedList.add(1);
linkedList.add(2);
linkedList.add(14);
let res = linkedList.length;
expect(res).assertEqual(5);
});
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;
/**
* @tc.name: testClear035
* @tc.desc: Clear all elements in the linkedList instance. For example: linkedList.clear().
* @tc.author: wangyong
*/
it("testClear035", 0, function () {
let linkedList = new LinkedList();
linkedList.add(4);
linkedList.add(3);
linkedList.add(1);
linkedList.add(2);
linkedList.add(14);
linkedList.clear();
let res = linkedList.length;
expect(res).assertEqual(0);
});
it("SR000GGR46_testIterator036", 0, function () {
let list = new LinkedList();
list.add(8);
list.add("");
list.add("");
list.add(5);
/**
* @tc.name: testIterator036
* @tc.desc: Iterates over all elements in an LinkedList instance.
* For example: for (let item of linkedList) {arr.push(item);}.
* @tc.author: wangyong
*/
it("testIterator036", 0, function () {
let linkedList = new LinkedList();
linkedList.add(8);
linkedList.add("");
linkedList.add("");
linkedList.add(5);
let c = [1, 2, 3, 4];
list.add(c);
list.add(6);
list.add("");
list.add("");
linkedList.add(c);
linkedList.add(6);
linkedList.add("");
linkedList.add("");
let arr = [];
let a = [8, "", "", 5, c, 6, "", ""];
for (let item of list) {
for (let item of linkedList) {
arr.push(item);
}
for (let index = 0; index < list.length; index++) {
for (let index = 0; index < linkedList.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);
/**
* @tc.name: testForEach037
* @tc.desc: Traversing elements in an LinkedList instance.
* For example: linkedList.forEach((item, index) => {arr.push(item);}).
* @tc.author: wangyong
*/
it("testForEach037", 0, function () {
let linkedList = new LinkedList();
linkedList.add(8);
linkedList.add("");
linkedList.add("");
linkedList.add(5);
let c = [1, 2, 3, 4];
list.add(c);
list.add(6);
list.add("");
list.add("");
linkedList.add(c);
linkedList.add(6);
linkedList.add("");
linkedList.add("");
let arr = [];
list.forEach((item, index) => {
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = [8, "", "", 5, c, 6, "", ""];
......@@ -452,16 +687,22 @@ describe("LinkedListTest", function () {
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();
/**
* @tc.name: testRemoveLast038
* @tc.desc: Delete the end element of a LinkedList instance. linkedList.removeLast().
* @tc.author: wangyong
*/
it("testRemoveLast038", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.addFirst("e");
let res = linkedList.removeLast();
expect(res).assertEqual("c");
let arr = [];
list.forEach((item, index) => {
linkedList.forEach((item, index) => {
arr.push(item);
});
let a = ["e", "a", "b"];
......@@ -469,54 +710,85 @@ describe("LinkedListTest", function () {
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);
/**
* @tc.name: testGet039
* @tc.desc: Gets the element corresponding to the specified index. For example: linkedList.get(1).
* @tc.author: wangyong
*/
it("testGet039", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.get(1);
expect(res).assertEqual("b");
});
it("SR000GGR46_testGet040", 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(10);
/**
* @tc.name: testGet040
* @tc.desc: Gets the element corresponding to the specified index. For example: linkedList.get(10).
* @tc.author: wangyong
*/
it("testGet040", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList.get(10);
expect(res).assertEqual(undefined);
});
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) => {
/**
* @tc.name: testListGet041
* @tc.desc: Gets the element corresponding to the specified index. For example: linkedList[1].
* @tc.author: wangyong
*/
it("testListGet041", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
let res = linkedList[1];
linkedList.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) => {
/**
* @tc.name: testListSet042
* @tc.desc: Modify the element corresponding to the specified index. For example: linkedList[1] = "f".
* @tc.author: wangyong
*/
it("testListSet042", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.add("a");
linkedList.add("b");
linkedList[1] = "f";
let res = linkedList[1];
linkedList.forEach((item, index) => {
console.log(item);
});
expect(res).assertEqual("f");
});
it("SR000GGR46_testAdd043", 0, function () {
/**
* @tc.name: testAdd043
* @tc.desc: Add a element to the end of the LinkedList instance.
* For example: for (let i = 0; i < 100; i++) {linkedList.add(i);}.
* @tc.author: wangyong
*/
it("testAdd043", 0, function () {
let linkedList = new LinkedList();
for (let i = 0; i < 100; i++) {
linkedList.add(i);
......@@ -524,7 +796,14 @@ describe("LinkedListTest", function () {
let res = linkedList.get(99);
expect(res).assertEqual(99);
});
it("SR000GGR46_testRemoveByIndex044", 0, function () {
/**
* @tc.name: testRemoveByIndex044
* @tc.desc: In the linkedList instance, delete the element based on its subscript index.
* For example: linkedList.removeByIndex(1).
* @tc.author: wangyong
*/
it("testRemoveByIndex044", 0, function () {
let linkedList = new LinkedList();
try {
let res = linkedList.removeByIndex(1);
......@@ -533,23 +812,43 @@ describe("LinkedListTest", function () {
expect(err.message).assertEqual("the index is out-of-bounds");
}
});
it("SR000GGR46_testClone045", 0, function () {
/**
* @tc.name: testClone045
* @tc.desc: Clone an LinkedList instance. For example: linkedList.clone().
* @tc.author: wangyong
*/
it("testClone045", 0, function () {
let linkedList = new LinkedList();
let newlist = linkedList.clone();
let newlinkedList = linkedList.clone();
let res = true
for (let i = 0; i < linkedList.length; i++) {
if (linkedList[i] !== newlist[i]) {
if (linkedList[i] !== newlinkedList[i]) {
res = false
}
}
expect(res).assertEqual(true);
});
it("SR000GGR46_testGetIndexOf046", 0, function () {
/**
* @tc.name: testGetIndexOf046
* @tc.desc: In the LinkedList instance, find the index of a specified element from front to back,
* and return the index found for the first time. If not found, return -1. For example: linkedList.getIndexOf(1).
* @tc.author: wangyong
*/
it("testGetIndexOf046", 0, function () {
let linkedList = new LinkedList();
let res = linkedList.getIndexOf(1);
expect(res).assertEqual(-1);
});
it("SR000GGR46_testForEach047", 0, function () {
/**
* @tc.name: testForEach047
* @tc.desc: Traversing elements in an LinkedList instance.
* For example: linkedList.forEach((item, index) => { num++; }).
* @tc.author: wangyong
*/
it("testForEach047", 0, function () {
let linkedList = new LinkedList();
let num = 0;
linkedList.forEach((item, index) => {
......@@ -557,67 +856,127 @@ describe("LinkedListTest", function () {
});
expect(num).assertEqual(0);
});
it("SR000GGR46_testHas048", 0, function () {
/**
* @tc.name: testHas048
* @tc.desc: Check whether the LinkedList contains a specified element. For example: linkedList.has(1).
* @tc.author: wangyong
*/
it("testHas048", 0, function () {
let linkedList = new LinkedList();
let res = linkedList.has(1);
expect(res).assertEqual(false);
});
it("SR000GGR46_testGet050", 0, function () {
/**
* @tc.name: testGet050
* @tc.desc: Gets the element corresponding to the specified index. For example: linkedList.get(1).
* @tc.author: wangyong
*/
it("testGet050", 0, function () {
let linkedList = new LinkedList();
let res = linkedList.get(1);
expect(res).assertEqual(undefined);
});
it("SR000GGR46_testClear051", 0, function () {
/**
* @tc.name: testClear051
* @tc.desc: Clear all elements in the LinkedList instance. For example: linkedList.clear().
* @tc.author: wangyong
*/
it("testClear051", 0, function () {
let linkedList = new LinkedList();
linkedList.clear();
const len = linkedList.length;
expect(len).assertEqual(0);
});
it("SR000GGR46_testGetLast052", 0, function () {
/**
* @tc.name: testGetLast052
* @tc.desc: Get the end element of the linkedList instance. For example: linkedList.getLast().
* @tc.author: wangyong
*/
it("testGetLast052", 0, function () {
let linkedList = new LinkedList();
let res = linkedList.getLast();
expect(res).assertEqual(undefined);
});
it("SR000GGR46_testGetFirst053", 0, function () {
/**
* @tc.name: testGetFirst053
* @tc.desc: Get the header element of the linkedList instance. For example: linkedList.getFirst().
* @tc.author: wangyong
*/
it("testGetFirst053", 0, function () {
let linkedList = new LinkedList();
let res = linkedList.getFirst();
expect(res).assertEqual(undefined);
});
it("SR000GGR46_testAdd054", 0, function () {
/**
* @tc.name: testAdd054
* @tc.desc: Add a element to the end of the LinkedList instance. For example: linkedList.add(null).
* @tc.author: wangyong
*/
it("testAdd054", 0, function () {
let linkedList = new LinkedList();
linkedList.add(null);
let res = linkedList.get(0);
expect(res).assertEqual(null);
});
it("SR000GGR46_testAdd055", 0, function () {
/**
* @tc.name: testAdd055
* @tc.desc: Add a element to the end of the LinkedList instance. For example: linkedList.add(0.1).
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testAdd056
* @tc.desc: Add a element to the end of the LinkedList instance. For example: linkedList.add(-1).
* @tc.author: wangyong
*/
it("testAdd056", 0, function () {
let linkedList = new LinkedList();
linkedList.add(-1);
let res = linkedList.get(0);
expect(res).assertEqual(-1);
});
it("SR000GGR46_testAdd057", 0, function () {
/**
* @tc.name: testAdd057
* @tc.desc: Add a element to the end of the LinkedList instance. For example: const obj = {}; linkedList.add(obj).
* @tc.author: wangyong
*/
it("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();
/**
* @tc.name: testIterator058
* @tc.desc: Iterates over all elements in an LinkedList instance. For example: linkedList[Symbol.iterator]().
* @tc.author: wangyong
*/
it("testIterator058", 0, function () {
let linkedList = new LinkedList();
linkedList.add("a");
linkedList.add("b");
linkedList.add("c");
linkedList.addFirst("e");
let res = linkedList.removeLast();
expect(res).assertEqual("c");
let arr = [];
let itr = list[Symbol.iterator]();
let itr = linkedList[Symbol.iterator]();
let tmp = undefined;
do {
tmp = itr.next().value;
......
......@@ -16,7 +16,13 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
import List from "@ohos.util.List";
describe("ListTest", function () {
it("SR000GGR4A_testConstructor001", 0, function () {
/**
* @tc.name: testConstructor001
* @tc.desc: Create an List instance. For example: let list = new List().
* @tc.author: wangyong
*/
it("testConstructor001", 0, function () {
try {
let list = new List();
expect(list != undefined).assertEqual(true);
......@@ -25,33 +31,65 @@ describe("ListTest", function () {
expect(err.message).assertEqual("cannot create new list");
}
});
it("SR000GGR4A_testGet002", 0, function () {
/**
* @tc.name: testGet002
* @tc.desc: Gets the element corresponding to the specified index. For example: list.get(0).
* @tc.author: wangyong
*/
it("testGet002", 0, function () {
let list = new List();
list.add("");
let res = list.get(0);
expect(res).assertEqual("");
});
it("SR000GGR4A_testAdd002", 0, function () {
/**
* @tc.name: testAdd003
* @tc.desc: Add a element to the end of the List instance. For example: list.add(8).
* @tc.author: wangyong
*/
it("testAdd003", 0, function () {
let list = new List();
list.add(8);
let res = list.get(0);
expect(res).assertEqual(8);
});
it("SR000GGR4A_testAdd003", 0, function () {
/**
* @tc.name: testAdd004
* @tc.desc: Add a element to the end of the List instance.
* For example: let a = [1, 2, 3, 4]; list.add(a).
* @tc.author: wangyong
*/
it("testAdd004", 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 () {
/**
* @tc.name: testAdd005
* @tc.desc: Add a element to the end of the List instance.
* For example: let a = {name: "lala", age: "13"}; list.add(a).
* @tc.author: wangyong
*/
it("testAdd005", 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 () {
/**
* @tc.name: testHas006
* @tc.desc: Check whether the List contains a specified element. For example: list.has("a").
* @tc.author: wangyong
*/
it("testHas006", 0, function () {
let list = new List();
list.add("a");
list.add("b");
......@@ -59,7 +97,13 @@ describe("ListTest", function () {
let res = list.has("a");
expect(res).assertEqual(true);
});
it("SR000GGR4A_testHas006", 0, function () {
/**
* @tc.name: testHas007
* @tc.desc: Check whether the List contains a specified element. For example: list.has("d").
* @tc.author: wangyong
*/
it("testHas007", 0, function () {
let list = new List();
list.add("a");
list.add("b");
......@@ -67,7 +111,13 @@ describe("ListTest", function () {
let res = list.has("d");
expect(res).assertEqual(false);
});
it("SR000GGR4A_testEqual007", 0, function () {
/**
* @tc.name: testEqual008
* @tc.desc: Judge whether two List instances are equal. For example: let res = list.equal(list1).
* @tc.author: wangyong
*/
it("testEqual008", 0, function () {
let list = new List();
let list1 = new List();
list.add("a");
......@@ -79,7 +129,13 @@ describe("ListTest", function () {
let res = list.equal(list1);
expect(res).assertEqual(false);
});
it("SR000GGR4A_testEqual008", 0, function () {
/**
* @tc.name: testEqual009
* @tc.desc: Judge whether two List instances are equal. For example: let res = list.equal(list1).
* @tc.author: wangyong
*/
it("testEqual009", 0, function () {
let list = new List();
let list1 = new List();
list.add("a");
......@@ -91,7 +147,13 @@ describe("ListTest", function () {
let res = list.equal(list1);
expect(res).assertEqual(true);
});
it("SR000GGR4A_testEqual009", 0, function () {
/**
* @tc.name: testEqual010
* @tc.desc: Judge whether two List instances are equal. For example: let res = list.equal(list1).
* @tc.author: wangyong
*/
it("testEqual010", 0, function () {
let list = new List();
let list1 = new List();
list.add("a");
......@@ -102,7 +164,13 @@ describe("ListTest", function () {
let res = list.equal(list1);
expect(res).assertEqual(false);
});
it("SR000GGR4A_testGet010", 0, function () {
/**
* @tc.name: testGet011
* @tc.desc: Gets the element corresponding to the specified index. For example: list.get(2).
* @tc.author: wangyong
*/
it("testGet010", 0, function () {
let list = new List();
list.add("a");
list.add("b");
......@@ -113,7 +181,14 @@ describe("ListTest", function () {
let res = list.get(2);
expect(res).assertEqual("c");
});
it("SR000GGR4A_testGetLastIndexOf011", 0, function () {
/**
* @tc.name: testGetLastIndexOf012
* @tc.desc: In the List instance, find the index of a specified element from brack to front,
* and return the index found for the first time. If not found, return -1. For example: list.getLastIndexOf("a").
* @tc.author: wangyong
*/
it("testGetLastIndexOf012", 0, function () {
let list = new List();
list.add("a");
list.add("b");
......@@ -124,7 +199,14 @@ describe("ListTest", function () {
let res = list.getLastIndexOf("a");
expect(res).assertEqual(3);
});
it("SR000GGR4A_testGetIndexOf012", 0, function () {
/**
* @tc.name: testGetIndexOf013
* @tc.desc: In the List instance, find the index of a specified element from front to back,
* and return the index found for the first time. If not found, return -1. For example: list.getIndexOf("b").
* @tc.author: wangyong
*/
it("testGetIndexOf013", 0, function () {
let list = new List();
list.add("a");
list.add("b");
......@@ -135,7 +217,13 @@ describe("ListTest", function () {
let res = list.getIndexOf("b");
expect(res).assertEqual(1);
});
it("SR000GGR4A_testRemoveByIndex013", 0, function () {
/**
* @tc.name: testRemoveByIndex014
* @tc.desc: In the List instance, delete the element based on its index. For example: list.removeByIndex(2).
* @tc.author: wangyong
*/
it("testRemoveByIndex014", 0, function () {
let list = new List();
list.add("a");
list.add("b");
......@@ -152,7 +240,13 @@ describe("ListTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR4A_testRemove014", 0, function () {
/**
* @tc.name: testRemove015
* @tc.desc: Delete the specified element. For example: list.remove("a").
* @tc.author: wangyong
*/
it("testRemove015", 0, function () {
let list = new List();
list.add("a");
list.add("b");
......@@ -169,7 +263,14 @@ describe("ListTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR4A_testConstructor015", 0, function () {
/**
* @tc.name: testReplaceAllElements016
* @tc.desc: Perform some operation on the elements in the List instance and return the List instance
* after the operation. For example: list.replaceAllElements((item, index) => {return (item = 2 * item);}).
* @tc.author: wangyong
*/
it("testReplaceAllElements016", 0, function () {
let list = new List();
list.add(1);
list.add(2);
......@@ -187,7 +288,13 @@ describe("ListTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR4A_testGetFirst016", 0, function () {
/**
* @tc.name: testGetFirst017
* @tc.desc: Get the header element of the List instance. For example: list.getFirst().
* @tc.author: wangyong
*/
it("testGetFirst017", 0, function () {
let list = new List();
list.add("a");
list.add("b");
......@@ -197,7 +304,13 @@ describe("ListTest", function () {
let res = list.getFirst();
expect(res).assertEqual("a");
});
it("SR000GGR4A_testGetLast017", 0, function () {
/**
* @tc.name: testGetLast018
* @tc.desc: Get the end element of the List instance. For example: list.getLast().
* @tc.author: wangyong
*/
it("testGetLast018", 0, function () {
let list = new List();
list.add("a");
list.add("b");
......@@ -207,7 +320,13 @@ describe("ListTest", function () {
let res = list.getLast();
expect(res).assertEqual("b");
});
it("SR000GGR4A_testInsert018", 0, function () {
/**
* @tc.name: testInsert019
* @tc.desc: Insert an element into the middle of the List instance. For example: list.insert("d", 3).
* @tc.author: wangyong
*/
it("testInsert019", 0, function () {
let list = new List();
list.add("a");
list.add("b");
......@@ -224,7 +343,13 @@ describe("ListTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR4A_testSet019", 0, function () {
/**
* @tc.name: testSet020
* @tc.desc: Modify the element corresponding to the specified index. For example: list.set(2, "d").
* @tc.author: wangyong
*/
it("testSet020", 0, function () {
let list = new List();
list.add("a");
list.add("b");
......@@ -234,7 +359,13 @@ describe("ListTest", function () {
let res1 = list.get(2);
expect(res1).assertEqual("d");
});
it("SR000GGR4A_testSort020", 0, function () {
/**
* @tc.name: testSort021
* @tc.desc: Arrange the elements in the List instance in descending order. For example: list.sort((a, b) => a - b).
* @tc.author: wangyong
*/
it("testSort021", 0, function () {
let list = new List();
list.add(4);
list.add(3);
......@@ -251,7 +382,14 @@ describe("ListTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR4A_testGetSubList021", 0, function () {
/**
* @tc.name: testGetSubList022
* @tc.desc: Intercepts an element within the specified range, including the element with the
* starting index but not the element with the ending index. For example: list.getSubList(2, 4).
* @tc.author: wangyong
*/
it("testGetSubList022", 0, function () {
let list = new List();
list.add(4);
list.add(3);
......@@ -268,7 +406,13 @@ describe("ListTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR4A_testConvertToArray022", 0, function () {
/**
* @tc.name: testConvertToArray023
* @tc.desc: Convert an List instance to an array. For example: list.convertToArray().
* @tc.author: wangyong
*/
it("testConvertToArray023", 0, function () {
let list = new List();
list.add(4);
list.add(3);
......@@ -282,7 +426,13 @@ describe("ListTest", function () {
expect(res[i]).assertEqual(a[i]);
}
});
it("SR000GGR4A_testLength023", 0, function () {
/**
* @tc.name: testLength024
* @tc.desc: Get the number of elements contained in the List instance. For example: list.length.
* @tc.author: wangyong
*/
it("testLength024", 0, function () {
let list = new List();
list.add(4);
list.add(3);
......@@ -292,7 +442,13 @@ describe("ListTest", function () {
let res = list.length;
expect(res).assertEqual(5);
});
it("SR000GGR4A_testConstructor024", 0, function () {
/**
* @tc.name: testIterator025
* @tc.desc: Iterates over all elements in an List instance. For example: for (let item of list) {arr.push(item);}.
* @tc.author: wangyong
*/
it("testIterator025", 0, function () {
let list = new List();
list.add(8);
list.add("");
......@@ -312,7 +468,13 @@ describe("ListTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR4A_testForEach025", 0, function () {
/**
* @tc.name: testForEach026
* @tc.desc: Traversing elements in an List instance. For example: list.forEach((item, index) => {arr.push(item);}).
* @tc.author: wangyong
*/
it("testForEach026", 0, function () {
let list = new List();
list.add(8);
list.add("");
......@@ -332,7 +494,13 @@ describe("ListTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR4A_testIsEmpty026", 0, function () {
/**
* @tc.name: testIsEmpty027
* @tc.desc: Determine whether the List instance is empty. For example: list.isEmpty().
* @tc.author: wangyong
*/
it("testIsEmpty027", 0, function () {
let list = new List();
list.add(8);
list.add("");
......@@ -346,7 +514,13 @@ describe("ListTest", function () {
let res = list.isEmpty();
expect(res).assertEqual(false);
});
it("SR000GGR4A_testClear027", 0, function () {
/**
* @tc.name: testClear028
* @tc.desc: Clear all elements in the List instance. For example: list.clear().
* @tc.author: wangyong
*/
it("testClear028", 0, function () {
let list = new List();
list.add("a");
list.add("b");
......@@ -356,7 +530,13 @@ describe("ListTest", function () {
let res = list.length;
expect(res).assertEqual(0);
});
it("SR000GGR4A_testGet028", 0, function () {
/**
* @tc.name: testGet029
* @tc.desc: Gets the element corresponding to the specified index. For example: list.get(6).
* @tc.author: wangyong
*/
it("testGet029", 0, function () {
let list = new List();
list.add("a");
list.add("b");
......@@ -367,7 +547,14 @@ describe("ListTest", function () {
let res = list.get(6);
expect(res).assertEqual(undefined);
});
it("SR000GGR4A_testGetLastIndexOf029", 0, function () {
/**
* @tc.name: testGetLastIndexOf030
* @tc.desc: In the List instance, find the index of a specified element from brack to front,
* and return the index found for the first time. If not found, return -1. For example: list.getLastIndexOf("F").
* @tc.author: wangyong
*/
it("testGetLastIndexOf030", 0, function () {
let list = new List();
list.add("a");
list.add("b");
......@@ -378,7 +565,13 @@ describe("ListTest", function () {
let res = list.getLastIndexOf("F");
expect(res).assertEqual(-1);
});
it("SR000GGR4A_testRemoveByIndex030", 0, function () {
/**
* @tc.name: testRemoveByIndex031
* @tc.desc: In the List instance, delete the element based on its index. For example: list.removeByIndex(5).
* @tc.author: wangyong
*/
it("testRemoveByIndex031", 0, function () {
let list = new List();
list.add("a");
list.add("b");
......@@ -392,13 +585,25 @@ describe("ListTest", function () {
expect(err.message).assertEqual("the index is out-of-bounds");
}
});
it("SR000GGR4A_testRemove031", 0, function () {
/**
* @tc.name: testRemove032
* @tc.desc: Delete the specified element. For example: list.remove().
* @tc.author: wangyong
*/
it("testRemove032", 0, function () {
let list = new List();
list.add();
let res = list.remove();
expect(res).assertEqual(true);
});
it("SR000GGR4A_testInsert032", 0, function () {
/**
* @tc.name: testInsert033
* @tc.desc: Insert an element into the middle of the List instance. For example: list.insert("d", 8).
* @tc.author: wangyong
*/
it("testInsert033", 0, function () {
let list = new List();
list.add("a");
list.add("b");
......@@ -412,7 +617,13 @@ describe("ListTest", function () {
expect(err.message).assertEqual("the index is out-of-bounds");
}
});
it("SR000GGR4A_testSort033", 0, function () {
/**
* @tc.name: testSort034
* @tc.desc: Arrange the elements in the List instance in descending order. For example: list.sort((a, b) => a - b).
* @tc.author: wangyong
*/
it("testSort034", 0, function () {
let list = new List();
list.add(";");
list.add("");
......@@ -430,7 +641,14 @@ describe("ListTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR4A_testGetSubList034", 0, function () {
/**
* @tc.name: testGetSubList035
* @tc.desc: Intercepts an element within the specified range, including the element with the
* starting index but not the element with the ending index. For example: list.getSubList(2, 8).
* @tc.author: wangyong
*/
it("testGetSubList035", 0, function () {
let list = new List();
list.add("4");
list.add("3");
......@@ -444,7 +662,14 @@ describe("ListTest", function () {
expect(err.message).assertEqual("the fromIndex or the toIndex is out-of-bounds");
}
});
it("SR000GGR4A_testGetSubList035", 0, function () {
/**
* @tc.name: testGetSubList036
* @tc.desc: Intercepts an element within the specified range, including the element with the
* starting index but not the element with the ending index. For example: list.getSubList(6, 8).
* @tc.author: wangyong
*/
it("testGetSubList036", 0, function () {
let list = new List();
list.add("4");
list.add("3");
......@@ -458,7 +683,14 @@ describe("ListTest", function () {
expect(err.message).assertEqual("the fromIndex or the toIndex is out-of-bounds");
}
});
it("SR000GGR4A_testGetSubList036", 0, function () {
/**
* @tc.name: testGetSubList037
* @tc.desc: Intercepts an element within the specified range, including the element with the
* starting index but not the element with the ending index. For example: list.getSubList(6, 2).
* @tc.author: wangyong
*/
it("testGetSubList037", 0, function () {
let list = new List();
list.add("4");
list.add("3");
......@@ -472,7 +704,13 @@ describe("ListTest", function () {
expect(err.message).assertEqual("the toIndex cannot be less than or equal to fromIndex");
}
});
it("SR000GGR4A_testAdd037", 0, function () {
/**
* @tc.name: testAdd038
* @tc.desc: Add a element to the end of the List instance. For example: list.add("*").
* @tc.author: wangyong
*/
it("testAdd038", 0, function () {
let list = new List();
list.add(".");
list.add("*");
......@@ -480,7 +718,13 @@ describe("ListTest", function () {
let res = list.get(0);
expect(res).assertEqual(".");
});
it("SR000GGR4A_testAdd038", 0, function () {
/**
* @tc.name: testAdd039
* @tc.desc: Add a element to the end of the List instance. For example: list.add("*").
* @tc.author: wangyong
*/
it("testAdd039", 0, function () {
let list = new List();
list.add(".");
list.add("*");
......@@ -494,13 +738,25 @@ describe("ListTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR4A_testAdd039", 0, function () {
/**
* @tc.name: testAdd040
* @tc.desc: Add a element to the end of the List instance. For example: list.add(" ").
* @tc.author: wangyong
*/
it("testAdd040", 0, function () {
let list = new List();
list.add(" ");
let res = list.get(0);
expect(res).assertEqual(" ");
});
it("SR000GGR4A_testAdd040", 0, function () {
/**
* @tc.name: testAdd041
* @tc.desc: Add a element to the end of the List instance. For example: list.add("a").
* @tc.author: wangyong
*/
it("testAdd041", 0, function () {
let list = new List();
list.add("a");
list.add("a");
......@@ -509,14 +765,26 @@ describe("ListTest", function () {
expect(res).assertEqual("a");
expect(res1).assertEqual("a");
});
it("SR000GGR4A_testListGet041", 0, function () {
/**
* @tc.name: testListGet042
* @tc.desc: Gets the element corresponding to the specified index. For example: list[0].
* @tc.author: wangyong
*/
it("testListGet042", 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 () {
/**
* @tc.name: testListSet043
* @tc.desc: Modify the element corresponding to the specified index. For example: list[1] = "c".
* @tc.author: wangyong
*/
it("testListSet043", 0, function () {
let list = new List();
list.add("a");
list.add("b");
......@@ -527,7 +795,13 @@ describe("ListTest", function () {
console.log(item);
});
});
it("SR000GGR4A_testAdd043", 0, function () {
/**
* @tc.name: testAdd044
* @tc.desc: Add a element to the end of the List instance. For example: for (let i = 0; i < 100; i++) {list.add(i);}.
* @tc.author: wangyong
*/
it("testAdd044", 0, function () {
let list = new List();
for (let i = 0; i < 100; i++) {
list.add(i);
......@@ -537,38 +811,74 @@ describe("ListTest", function () {
expect(res).assertEqual(99);
expect(res1).assertEqual(100);
});
it("SR000GGR4A_testAdd044", 0, function () {
/**
* @tc.name: testAdd045
* @tc.desc: Add a element to the end of the List instance. For example: list.add(null).
* @tc.author: wangyong
*/
it("testAdd045", 0, function () {
let list = new List();
list.add(null);
let res = list.get(0);
expect(res).assertEqual(null);
});
it("SR000GGR4A_testAdd045", 0, function () {
/**
* @tc.name: testAdd046
* @tc.desc: Add a element to the end of the List instance. For example: list.add(0.1111).
* @tc.author: wangyong
*/
it("testAdd046", 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 () {
/**
* @tc.name: testAdd047
* @tc.desc: Add a element to the end of the List instance. For example: list.add(-1).
* @tc.author: wangyong
*/
it("testAdd047", 0, function () {
let list = new List();
list.add(-1);
let res = list.get(0);
expect(res).assertEqual(-1);
});
it("SR000GGR4A_testAdd047", 0, function () {
/**
* @tc.name: testAdd048
* @tc.desc: Add a element to the end of the List instance. For example: const obj = {}; list.add(obj).
* @tc.author: wangyong
*/
it("testAdd048", 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 () {
/**
* @tc.name: testSort049
* @tc.desc: Arrange the elements in the List instance in descending order. For example: list.sort((a, b) => a - b).
* @tc.author: wangyong
*/
it("testSort049", 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 () {
/**
* @tc.name: testRemoveByIndex050
* @tc.desc: In the List instance, delete the element based on its index. For example: list.removeByIndex(1).
* @tc.author: wangyong
*/
it("testRemoveByIndex050", 0, function () {
let list = new List();
try {
let res = list.removeByIndex(1);
......@@ -577,18 +887,37 @@ describe("ListTest", function () {
expect(err.message).assertEqual("the index is out-of-bounds");
}
});
it("SR000GGR4A_testEqual050", 0, function () {
/**
* @tc.name: testEqual051
* @tc.desc: Judge whether two List instances are equal. For example: let res = list.equal(list1).
* @tc.author: wangyong
*/
it("testEqual051", 0, function () {
let list = new List();
let list1 = new List();
let res = list.equal(list1);
expect(res).assertEqual(true);
});
it("SR000GGR4A_testGetIndexOf051", 0, function () {
/**
* @tc.name: testGetIndexOf052
* @tc.desc: In the List instance, find the index of a specified element from front to back,
* and return the index found for the first time. If not found, return -1. For example: list.getIndexOf("b").
* @tc.author: wangyong
*/
it("testGetIndexOf052", 0, function () {
let list = new List();
let res = list.getIndexOf(1);
expect(res).assertEqual(-1);
});
it("SR000GGR4A_testForEach052", 0, function () {
/**
* @tc.name: testForEach053
* @tc.desc: Traversing elements in an List instance. For example: list.forEach((item, index) => {num++;}).
* @tc.author: wangyong
*/
it("testForEach053", 0, function () {
let list = new List();
let num = 0;
list.forEach((item, index) => {
......@@ -596,33 +925,70 @@ describe("ListTest", function () {
});
expect(num).assertEqual(0);
});
it("SR000GGR4A_testIsEmpty053", 0, function () {
/**
* @tc.name: testIsEmpty054
* @tc.desc: Determine whether the List instance is empty. For example: list.isEmpty().
* @tc.author: wangyong
*/
it("testIsEmpty054", 0, function () {
let list = new List();
let res = list.isEmpty();
expect(res).assertEqual(true);
});
it("SR000GGR4A_testHas054", 0, function () {
/**
* @tc.name: testHas055
* @tc.desc: Check whether the List contains a specified element. For example: list.has(1).
* @tc.author: wangyong
*/
it("testHas055", 0, function () {
let list = new List();
let res = list.has(1);
expect(res).assertEqual(false);
});
it("SR000GGR4A_testGet055", 0, function () {
/**
* @tc.name: testGet056
* @tc.desc: Gets the element corresponding to the specified index. For example: list.get(1).
* @tc.author: wangyong
*/
it("testGet056", 0, function () {
let list = new List();
let res = list.get(1);
expect(res).assertEqual(undefined);
});
it("SR000GGR4A_testClear056", 0, function () {
/**
* @tc.name: testClear057
* @tc.desc: Clear all elements in the List instance. For example: list.clear().
* @tc.author: wangyong
*/
it("testClear057", 0, function () {
let list = new List();
list.clear();
let res1 = list.length;
expect(res1).assertEqual(0);
});
it("SR000GGR4A_testGetLast057", 0, function () {
/**
* @tc.name: testGetLast058
* @tc.desc: Get the end element of the List instance. For example: list.getLast().
* @tc.author: wangyong
*/
it("testGetLast058", 0, function () {
let list = new List();
let res = list.getLast();
expect(res).assertEqual(undefined);
});
it("SR000GGR4A_testReplaceAllElements058", 0, function () {
/**
* @tc.name: testReplaceAllElements059"
* @tc.desc: Perform some operation on the elements in the List instance and return the List instance
* after the operation. For example: list.replaceAllElements((item, index) => {num++;}).
* @tc.author: wangyong
*/
it("testReplaceAllElements059", 0, function () {
let list = new List();
let num = 0;
list.replaceAllElements((item, index) => {
......@@ -630,17 +996,35 @@ describe("ListTest", function () {
});
expect(num).assertEqual(0);
});
it("SR000GGR4A_testConvertToArray059", 0, function () {
/**
* @tc.name: testConvertToArray060
* @tc.desc: Convert an List instance to an array. For example: list.convertToArray().
* @tc.author: wangyong
*/
it("testConvertToArray060", 0, function () {
let list = new List();
const res = list.convertToArray();
expect(res.length).assertEqual(0);
});
it("SR000GGR4A_testConvertToArray060", 0, function () {
/**
* @tc.name: testConvertToArray061
* @tc.desc: Convert an List instance to an array. For example: list.convertToArray().
* @tc.author: wangyong
*/
it("testConvertToArray061", 0, function () {
let list = new List();
const res = list.convertToArray();
expect(res.length).assertEqual(0);
});
it("SR000GGR4A_testlterator061", 0, function () {
/**
* @tc.name: testlterator062
* @tc.desc: Iterates over all elements in an List instance. For example: for (const iterator of list) { num++;}.
* @tc.author: wangyong
*/
it("testlterator062", 0, function () {
let list = new List();
for (let index = 0; index < 10; index++) {
list.add(index);
......@@ -651,12 +1035,24 @@ describe("ListTest", function () {
num++;
}
});
it("SR000GGR4A_testGetFirst062", 0, function () {
/**
* @tc.name: testlterator063
* @tc.desc: Get the header element of the List instance. For example: list.getFirst().
* @tc.author: wangyong
*/
it("testGetFirst063", 0, function () {
let list = new List();
let res = list.getFirst();
expect(res).assertEqual(undefined);
});
it("SR000GGR4A_testIterator063", 0, function () {
/**
* @tc.name: testIterator064
* @tc.desc: Iterates over all elements in an List instance. For example: List[Symbol.iterator]().
* @tc.author: wangyong
*/
it("testIterator064", 0, function () {
let list = new List();
list.add("a");
list.add("b");
......
......@@ -16,7 +16,13 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
import Queue from "@ohos.util.Queue";
describe("QueueTest", function () {
it("SR000GGR48_testConstructor001", 0, function () {
/**
* @tc.name: testConstructor001
* @tc.desc: Create an Queue instance. For example: let queue = new Queue().
* @tc.author: wangyong
*/
it("testConstructor001", 0, function () {
try {
let queue = new Queue();
} catch (err) {
......@@ -24,33 +30,63 @@ describe("QueueTest", function () {
expect(err.message).assertEqual("Cannot create new queue");
}
});
it("SR000GGR48_testAdd002", 0, function () {
/**
* @tc.name: testAdd002
* @tc.desc: Add element to Queue instance end. For example: queue.add("四").
* @tc.author: wangyong
*/
it("testAdd002", 0, function () {
let queue = new Queue();
queue.add("");
let res = queue.getFirst();
expect(res).assertEqual("");
});
it("SR000GGR48_testAdd003", 0, function () {
/**
* @tc.name: testAdd003
* @tc.desc: Add element to Queue instance end. For example: queue.add(8).
* @tc.author: wangyong
*/
it("testAdd003", 0, function () {
let queue = new Queue();
queue.add(8);
let res = queue.getFirst();
expect(res).assertEqual(8);
});
it("SR000GGR48_testAdd004", 0, function () {
/**
* @tc.name: testAdd004
* @tc.desc: Add element to Queue instance end. For example: queue.add(8).
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testGetFirst005
* @tc.desc: Get the header element of the queue instance. For example: queue.getFirst().
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testPop006
* @tc.desc: Delete the header element of a queue instance. For example: queue.pop().
* @tc.author: wangyong
*/
it("testPop006", 0, function () {
let queue = new Queue();
queue.add(6);
queue.add("");
......@@ -59,7 +95,13 @@ describe("QueueTest", function () {
expect(res).assertEqual(6);
expect(res1).assertEqual("");
});
it("SR000GGR48_testForEach007", 0, function () {
/**
* @tc.name: testForEach007
* @tc.desc: Traversing elements in queue instances. For example: queue.forEach((item, index) => {arr.push(item);}).
* @tc.author: wangyong
*/
it("testForEach007", 0, function () {
let queue = new Queue();
queue.add(8);
queue.add("");
......@@ -81,7 +123,13 @@ describe("QueueTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR48_testIterator008", 0, function () {
/**
* @tc.name: testIterator008
* @tc.desc: Iterate over all elements in the queue instance. For example: for (let item of queue) { arr.push(item);}.
* @tc.author: wangyong
*/
it("testIterator008", 0, function () {
let queue = new Queue();
queue.add(8);
queue.add("");
......@@ -99,7 +147,13 @@ describe("QueueTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR48_testLength009", 0, function () {
/**
* @tc.name: testLength009
* @tc.desc: Get the number of elements in the queue instance. For example: queue.length.
* @tc.author: wangyong
*/
it("testLength009", 0, function () {
let queue = new Queue();
queue.add(8);
queue.add("");
......@@ -113,31 +167,61 @@ describe("QueueTest", function () {
let res = queue.length;
expect(9).assertEqual(res);
});
it("SR000GGR48_testAdd010", 0, function () {
/**
* @tc.name: testAdd010
* @tc.desc: Add element to Queue instance end. For example: queue.add("$").
* @tc.author: wangyong
*/
it("testAdd010", 0, function () {
let queue = new Queue();
queue.add("$");
let res = queue.getFirst();
expect(res).assertEqual("$");
});
it("SR000GGR48_testAdd011", 0, function () {
/**
* @tc.name: testAdd011
* @tc.desc: Add element to Queue instance end. For example: queue.add(" ").
* @tc.author: wangyong
*/
it("testAdd011", 0, function () {
let queue = new Queue();
queue.add(" ");
let res = queue.getFirst();
expect(res).assertEqual(" ");
});
it("SR000GGR48_testAdd012", 0, function () {
/**
* @tc.name: testAdd012
* @tc.desc: Add element to Queue instance end. For example: queue.add(null).
* @tc.author: wangyong
*/
it("testAdd012", 0, function () {
let queue = new Queue();
queue.add(null);
let res = queue.getFirst();
expect(res).assertEqual(null);
});
it("SR000GGR48_testAdd013", 0, function () {
/**
* @tc.name: testAdd013
* @tc.desc: Add element to Queue instance end. For example: queue.add(undefined).
* @tc.author: wangyong
*/
it("testAdd013", 0, function () {
let queue = new Queue();
queue.add(undefined);
let res = queue.getFirst();
expect(res).assertEqual(undefined);
});
it("SR000GGR48_testAdd014", 0, function () {
/**
* @tc.name: testAdd014
* @tc.desc: Add element to Queue instance end. For example: for (let i = 0; i < 100; i++) { queue.add(i);}.
* @tc.author: wangyong
*/
it("testAdd014", 0, function () {
let queue = new Queue();
for (let i = 0; i < 100; i++) {
queue.add(i);
......@@ -145,17 +229,35 @@ describe("QueueTest", function () {
let res = queue.length;
expect(res).assertEqual(100);
});
it("SR000GGR48_testGetFirst015", 0, function () {
/**
* @tc.name: testGetFirst015
* @tc.desc: Get the header element of the queue instance. For example: queue.getFirst().
* @tc.author: wangyong
*/
it("testGetFirst015", 0, function () {
let queue = new Queue();
let res = queue.getFirst();
expect(res).assertEqual(undefined);
});
it("SR000GGR48_testPop016", 0, function () {
/**
* @tc.name: testPop016
* @tc.desc: Delete the header element of a queue instance. For example: queue.pop().
* @tc.author: wangyong
*/
it("testPop016", 0, function () {
let queue = new Queue();
let res = queue.pop();
expect(res).assertEqual(undefined);
});
it("SR000GGR48_testForEach017", 0, function () {
/**
* @tc.name: testForEach017
* @tc.desc: Traversing elements in queue instances. For example: queue.forEach((item, index) => {arr.push(item);}).
* @tc.author: wangyong
*/
it("testForEach017", 0, function () {
let queue = new Queue();
let arr = [];
queue.forEach((item, index) => {
......@@ -163,7 +265,13 @@ describe("QueueTest", function () {
});
expect(arr.length).assertEqual(0);
});
it("SR000GGR48_testIterator018", 0, function () {
/**
* @tc.name: testIterator018
* @tc.desc: Iterate over all elements in the queue instance. For example: for (let item of queue) { arr.push(item);}.
* @tc.author: wangyong
*/
it("testIterator018", 0, function () {
let queue = new Queue();
let arr = [];
for (let item of queue) {
......@@ -171,7 +279,13 @@ describe("QueueTest", function () {
}
expect(arr.length).assertEqual(0);
});
it("SR000GGR48_testIterator019", 0, function () {
/**
* @tc.name: testIterator019
* @tc.desc: Iterate over all elements in the queue instance. For example: queue[Symbol.iterator]().
* @tc.author: wangyong
*/
it("testIterator019", 0, function () {
let queue = new Queue();
queue.add(8);
queue.add("");
......
......@@ -16,7 +16,13 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
import Stack from "@ohos.util.Stack";
describe("StackTest", function () {
it("SR000GGR49_testConstructor001", 0, function () {
/**
* @tc.name: testConstructor001
* @tc.desc: Create an Stack instance. For example: let stack = new Stack().
* @tc.author: wangyong
*/
it("testConstructor001", 0, function () {
try {
let stack = new Stack();
expect(stack != undefined).assertEqual(true);
......@@ -25,33 +31,63 @@ describe("StackTest", function () {
expect(err.message).assertEqual("Cannot create new stack");
}
});
it("SR000GGR49_testPush002", 0, function () {
/**
* @tc.name: testPush002
* @tc.desc: Insert element at top of stack.For example: stack.push("四").
* @tc.author: wangyong
*/
it("testPush002", 0, function () {
let stack = new Stack();
stack.push("");
let res = stack.peek();
expect(res).assertEqual("");
});
it("SR000GGR49_testPush003", 0, function () {
/**
* @tc.name: testPush003
* @tc.desc: Insert element at top of stack.For example: stack.push(8).
* @tc.author: wangyong
*/
it("testPush003", 0, function () {
let stack = new Stack();
stack.push(8);
let res = stack.peek();
expect(res).assertEqual(8);
});
it("SR000GGR49_testPush004", 0, function () {
/**
* @tc.name: testPush004
* @tc.desc: Insert element at top of stack.For example: let a = {name: "lala", age: "13岁"}; stack.push(a).
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testPush005
* @tc.desc: Insert element at top of stack.For example: let a = [1, 2, 3, 4]; stack.push(a).
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testPeek006
* @tc.desc: Get stack top element. For example: stack.peek().
* @tc.author: wangyong
*/
it("testPeek006", 0, function () {
let stack = new Stack();
let a = [1, 2, 3, 4];
stack.push(a);
......@@ -61,7 +97,13 @@ describe("StackTest", function () {
let res = stack.peek();
expect(res).assertEqual(1);
});
it("SR000GGR49_testLocate007", 0, function () {
/**
* @tc.name: testLocate007
* @tc.desc: Get the index corresponding to the element in the stack. For example: stack.locate("A").
* @tc.author: wangyong
*/
it("testLocate007", 0, function () {
let stack = new Stack();
let a = [1, 2, 3, 4];
stack.push(8);
......@@ -74,7 +116,13 @@ describe("StackTest", function () {
expect(res).assertEqual(2);
expect(res1).assertEqual(-1);
});
it("SR000GGR49_testPop008", 0, function () {
/**
* @tc.name: testPop008
* @tc.desc: Delete top of stack element. For example: stack.pop().
* @tc.author: wangyong
*/
it("testPop008", 0, function () {
let stack = new Stack();
stack.push("B");
stack.push(1);
......@@ -83,7 +131,13 @@ describe("StackTest", function () {
expect(res).assertEqual(1);
expect(res1).assertEqual("B");
});
it("SR000GGR49_testForEach009", 0, function () {
/**
* @tc.name: testForEach009
* @tc.desc: Traversing elements in stack instances. For example: stack.forEach((item, index) => {arr.push(item);}).
* @tc.author: wangyong
*/
it("testForEach009", 0, function () {
let stack = new Stack();
stack.push(8);
stack.push("");
......@@ -101,7 +155,13 @@ describe("StackTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR49_testIterator010", 0, function () {
/**
* @tc.name: testIterator010
* @tc.desc: Iterate over all elements in the stack instance. For example: for (let item of stack) {arr.push(item);}.
* @tc.author: wangyong
*/
it("testIterator010", 0, function () {
let stack = new Stack();
stack.push(8);
stack.push("");
......@@ -121,7 +181,13 @@ describe("StackTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR49_testLength011", 0, function () {
/**
* @tc.name: testLength011
* @tc.desc: Get the number of elements in the stack instance. For example: stack.length.
* @tc.author: wangyong
*/
it("testLength011", 0, function () {
let stack = new Stack();
stack.push(8);
stack.push("");
......@@ -130,12 +196,24 @@ describe("StackTest", function () {
let res = stack.length;
expect(4).assertEqual(res);
});
it("SR000GGR49_testLength012", 0, function () {
/**
* @tc.name: testLength012
* @tc.desc: Get the number of elements in the stack instance. For example: stack.length.
* @tc.author: wangyong
*/
it("testLength012", 0, function () {
let stack = new Stack();
let res = stack.length;
expect(0).assertEqual(res);
});
it("SR000GGR49_testIsEmpty013", 0, function () {
/**
* @tc.name: testIsEmpty013
* @tc.desc: Determine whether the Stack instance is empty. For example: stack.isEmpty().
* @tc.author: wangyong
*/
it("testIsEmpty013", 0, function () {
let stack = new Stack();
stack.push(8);
stack.push("");
......@@ -144,42 +222,84 @@ describe("StackTest", function () {
let res = stack.isEmpty();
expect(res).assertEqual(false);
});
it("SR000GGR49_testIsEmpty014", 0, function () {
/**
* @tc.name: testIsEmpty014
* @tc.desc: Determine whether the Stack instance is empty. For example: stack.isEmpty().
* @tc.author: wangyong
*/
it("testIsEmpty014", 0, function () {
let stack = new Stack();
let res = stack.isEmpty();
expect(res).assertEqual(true);
});
it("SR000GGR49_testPush015", 0, function () {
/**
* @tc.name: testPush015
* @tc.desc: Insert element at top of stack.For example: stack.push("你好世界").
* @tc.author: wangyong
*/
it("testPush015", 0, function () {
let stack = new Stack();
stack.push("你好世界");
let res = stack.peek();
expect(res).assertEqual("你好世界");
});
it("SR000GGR49_testPush016", 0, function () {
/**
* @tc.name: testPush016
* @tc.desc: Insert element at top of stack.For example: stack.push(1234).
* @tc.author: wangyong
*/
it("testPush016", 0, function () {
let stack = new Stack();
stack.push(1234);
let res = stack.peek();
expect(res).assertEqual(1234);
});
it("SR000GGR49_testPush017", 0, function () {
/**
* @tc.name: testPush017
* @tc.desc: Insert element at top of stack.For example: stack.push(1.234).
* @tc.author: wangyong
*/
it("testPush017", 0, function () {
let stack = new Stack();
stack.push(1.234);
let res = stack.peek();
expect(res).assertEqual(1.234);
});
it("SR000GGR49_testPush018", 0, function () {
/**
* @tc.name: testPush018
* @tc.desc: Insert element at top of stack.For example: stack.push(-1234).
* @tc.author: wangyong
*/
it("testPush018", 0, function () {
let stack = new Stack();
stack.push(-1234);
let res = stack.peek();
expect(res).assertEqual(-1234);
});
it("SR000GGR49_testPush019", 0, function () {
/**
* @tc.name: testPush019
* @tc.desc: Insert element at top of stack.For example: stack.push(0).
* @tc.author: wangyong
*/
it("testPush019", 0, function () {
let stack = new Stack();
stack.push(0);
let res = stack.peek();
expect(res).assertEqual(0);
});
it("SR000GGR49_testPush020", 0, function () {
/**
* @tc.name: testPush020
* @tc.desc: Insert element at top of stack.For example: stack.push("*").
* @tc.author: wangyong
*/
it("testPush020", 0, function () {
let stack = new Stack();
stack.push(10);
stack.push(3.14);
......@@ -189,73 +309,145 @@ describe("StackTest", function () {
let res = stack.peek();
expect(res).assertEqual("*");
});
it("SR000GGR49_testPush021", 0, function () {
/**
* @tc.name: testPush021
* @tc.desc: Insert element at top of stack.For example: let arr = {}; stack.push(arr).
* @tc.author: wangyong
*/
it("testPush021", 0, function () {
let stack = new Stack();
let arr = {};
stack.push(arr);
let res = stack.peek();
expect(res).assertEqual(arr);
});
it("SR000GGR49_testPush022", 0, function () {
/**
* @tc.name: testPush022
* @tc.desc: Insert element at top of stack.For example: let arr = []; stack.push(arr).
* @tc.author: wangyong
*/
it("testPush022", 0, function () {
let stack = new Stack();
let arr = [];
stack.push(arr);
let res = stack.peek();
expect(res).assertEqual(arr);
});
it("SR000GGR49_testPush023", 0, function () {
/**
* @tc.name: testPush023
* @tc.desc: Insert element at top of stack.For example: stack.push("hello world").
* @tc.author: wangyong
*/
it("testPush023", 0, function () {
let stack = new Stack();
stack.push("hello world");
let res = stack.peek();
expect(res).assertEqual("hello world");
});
it("SR000GGR49_testPush024", 0, function () {
/**
* @tc.name: testPush024
* @tc.desc: Insert element at top of stack.
* @tc.author: wangyong
*/
it("testPush024", 0, function () {
let stack = new Stack();
stack.push("~!@#$^&*()_+-*/=.?<>:;|{}[]");
let res = stack.peek();
expect(res).assertEqual("~!@#$^&*()_+-*/=.?<>:;|{}[]");
});
it("SR000GGR49_testPush025", 0, function () {
/**
* @tc.name: testPush025
* @tc.desc: Insert element at top of stack. For example: stack.push("").
* @tc.author: wangyong
*/
it("testPush025", 0, function () {
let stack = new Stack();
stack.push("");
let res = stack.peek();
expect(res).assertEqual("");
});
it("SR000GGR49_testPush026", 0, function () {
/**
* @tc.name: testPush026
* @tc.desc: Insert element at top of stack. For example: stack.push(true).
* @tc.author: wangyong
*/
it("testPush026", 0, function () {
let stack = new Stack();
stack.push(true);
let res = stack.peek();
expect(res).assertEqual(true);
});
it("SR000GGR49_testPush027", 0, function () {
/**
* @tc.name: testPush027
* @tc.desc: Insert element at top of stack. For example: stack.push(false).
* @tc.author: wangyong
*/
it("testPush027", 0, function () {
let stack = new Stack();
stack.push(false);
let res = stack.peek();
expect(res).assertEqual(false);
});
it("SR000GGR49_testPush028", 0, function () {
/**
* @tc.name: testPush028
* @tc.desc: Insert element at top of stack. For example: stack.push(null).
* @tc.author: wangyong
*/
it("testPush028", 0, function () {
let stack = new Stack();
stack.push(null);
let res = stack.peek();
expect(res).assertEqual(null);
});
it("SR000GGR49_testPush029", 0, function () {
/**
* @tc.name: testPush029
* @tc.desc: Insert element at top of stack. For example: stack.push(undefined).
* @tc.author: wangyong
*/
it("testPush029", 0, function () {
let stack = new Stack();
stack.push(undefined);
let res = stack.peek();
expect(res).assertEqual(undefined);
});
it("SR000GGR49_testPeek030", 0, function () {
/**
* @tc.name: testPeek030
* @tc.desc: Get stack top element. For example: stack.peek().
* @tc.author: wangyong
*/
it("testPeek030", 0, function () {
let stack = new Stack();
let res = stack.peek();
expect(res).assertEqual(undefined);
});
it("SR000GGR49_testPop031", 0, function () {
/**
* @tc.name: testPop031
* @tc.desc: Delete top of stack element. For example: stack.pop().
* @tc.author: wangyong
*/
it("testPop031", 0, function () {
let stack = new Stack();
let res = stack.pop();
expect(res).assertEqual(undefined);
});
it("SR000GGR49_testForEach032", 0, function () {
/**
* @tc.name: testForEach032
* @tc.desc: Traversing elements in stack instances. For example: stack.forEach((item, index) => {arr.push(item);}).
* @tc.author: wangyong
*/
it("testForEach032", 0, function () {
let stack = new Stack();
let arr = [];
stack.forEach((item, index) => {
......@@ -263,7 +455,13 @@ describe("StackTest", function () {
});
expect(arr.length).assertEqual(0);
});
it("SR000GGR49_testIterator033", 0, function () {
/**
* @tc.name: testIterator033
* @tc.desc: Iterate over all elements in the stack instance. For example: for (let item of stack) {arr.push(item);}.
* @tc.author: wangyong
*/
it("testIterator033", 0, function () {
let stack = new Stack();
let arr = [];
for (let item of stack) {
......@@ -271,7 +469,13 @@ describe("StackTest", function () {
}
expect(arr.length).assertEqual(0);
});
it("SR000GGR49_testPush034", 0, function () {
/**
* @tc.name: testPush034
* @tc.desc: Insert element at top of stack. For example: for (let i = 0; i < 1000; i++) {stack.push(i);}.
* @tc.author: wangyong
*/
it("testPush034", 0, function () {
let stack = new Stack();
for (let i = 0; i < 1000; i++) {
stack.push(i);
......@@ -281,7 +485,13 @@ describe("StackTest", function () {
let res1 = stack.peek();
expect(res1).assertEqual(999);
});
it("SR000GGR49_testIterator035", 0, function () {
/**
* @tc.name: testIterator035
* @tc.desc: Iterate over all elements in the stack instance. For example: stack[Symbol.iterator]().
* @tc.author: wangyong
*/
it("testIterator035", 0, function () {
let stack = new Stack();
stack.push(8);
stack.push("");
......
/*
/*Pop
* Copyright (C) 2022 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.
......@@ -16,7 +16,13 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
import Vector from "@ohos.util.Vector";
describe("VectorTest", function () {
it("SR000GGR47_testConstructor001", 0, function () {
/**
* @tc.name: testConstructor001
* @tc.desc: Create an Vector instance. For example: let vector = new Vector().
* @tc.author: wangyong
*/
it("testConstructor001", 0, function () {
try {
let vector = new Vector();
} catch (err) {
......@@ -24,33 +30,64 @@ describe("VectorTest", function () {
expect(err.message).assertEqual("Cannot create new vector");
}
});
it("SR000GGR47_testAdd002", 0, function () {
/**
* @tc.name: testAdd002
* @tc.desc: Add a element to the end of the Vector instance. For example: vector.add("四").
* @tc.author: wangyong
*/
it("testAdd002", 0, function () {
let vector = new Vector();
vector.add("");
let res = vector.getFirstElement();
expect(res).assertEqual("");
});
it("SR000GGR47_testAdd003 ", 0, function () {
/**
* @tc.name: testAdd003
* @tc.desc: Add a element to the end of the Vector instance. For example: vector.add(4).
* @tc.author: wangyong
*/
it("testAdd003", 0, function () {
let vector = new Vector();
vector.add(4);
let res = vector.getFirstElement();
expect(res).assertEqual(4);
});
it("SR000GGR47_testAdd004 ", 0, function () {
/**
* @tc.name: testAdd004
* @tc.desc: Add a element to the end of the Vector instance.
* For example: let a = {name: "lala", age: "13岁"}; vector.add(a).
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testAdd005
* @tc.desc: Add a element to the end of the Vector instance. For example: let a = [1, 2, 3, 4]; vector.add(a).
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testInsert006
* @tc.desc: Insert an element into the middle of the Vector instance. For example: vector.insert(8, 2).
* @tc.author: wangyong
*/
it("testInsert006", 0, function () {
let vector = new Vector();
vector.add("");
vector.add("");
......@@ -60,7 +97,13 @@ describe("VectorTest", function () {
let res = vector.get(2);
expect(res).assertEqual(8);
});
it("SR000GGR47_testInsert007", 0, function () {
/**
* @tc.name: testInsert007
* @tc.desc: Insert an element into the middle of the Vector instance. For example: vector.insert(-1, 2).
* @tc.author: wangyong
*/
it("testInsert007", 0, function () {
let vector = new Vector();
vector.add("");
vector.add("");
......@@ -73,7 +116,13 @@ describe("VectorTest", function () {
expect(err.message).assertEqual("the index is out-of-bounds");
}
});
it("SR000GGR47_testInsert008", 0, function () {
/**
* @tc.name: testInsert008
* @tc.desc: Insert an element into the middle of the Vector instance. For example: vector.insert(capacity, 2).
* @tc.author: wangyong
*/
it("testInsert008", 0, function () {
let vector = new Vector();
vector.add("");
vector.add("");
......@@ -84,7 +133,13 @@ describe("VectorTest", function () {
let res = vector.get(2);
expect(res).assertEqual(10);
});
it("SR000GGR47_testInsert009", 0, function () {
/**
* @tc.name: testInsert009
* @tc.desc: Insert an element into the middle of the Vector instance. For example: vector.insert(2, capacity + 1).
* @tc.author: wangyong
*/
it("testInsert009", 0, function () {
let vector = new Vector();
vector.add("");
vector.add("");
......@@ -98,7 +153,13 @@ describe("VectorTest", function () {
expect(err.message).assertEqual("the index is out-of-bounds");
}
});
it("SR000GGR47_testLength010", 0, function () {
/**
* @tc.name: testLength010
* @tc.desc: Get the number of elements contained in the Vector instance. For example: vector.length.
* @tc.author: wangyong
*/
it("testLength010", 0, function () {
let vector = new Vector();
vector.add("");
vector.add("");
......@@ -107,7 +168,13 @@ describe("VectorTest", function () {
let res = vector.length;
expect(res).assertEqual(4);
});
it("SR000GGR47_testHas011", 0, function () {
/**
* @tc.name: testHas011
* @tc.desc: Check whether the Vector contains a specified element. For example: vector.has(8).
* @tc.author: wangyong
*/
it("testHas011", 0, function () {
let vector = new Vector();
vector.add("");
vector.add("");
......@@ -117,7 +184,13 @@ describe("VectorTest", function () {
let res = vector.has(8);
expect(res).assertEqual(true);
});
it("SR000GGR47_testHas012", 0, function () {
/**
* @tc.name: testHas012
* @tc.desc: Check whether the Vector contains a specified element. For example: vector.has("二").
* @tc.author: wangyong
*/
it("testHas012", 0, function () {
let vector = new Vector();
vector.add("");
vector.add("");
......@@ -127,7 +200,13 @@ describe("VectorTest", function () {
let res1 = vector.has("");
expect(res1).assertEqual(false);
});
it("SR000GGR47_testGet013", 0, function () {
/**
* @tc.name: testGet013
* @tc.desc: Gets the element corresponding to the specified index. For example: vector.get(1).
* @tc.author: wangyong
*/
it("testGet013", 0, function () {
let vector = new Vector();
vector.add("");
vector.add("");
......@@ -137,7 +216,13 @@ describe("VectorTest", function () {
let res1 = vector.get(1);
expect(res1).assertEqual("");
});
it("SR000GGR47_testGet014", 0, function () {
/**
* @tc.name: testGet014
* @tc.desc: Gets the element corresponding to the specified index. For example: vector.get(10).
* @tc.author: wangyong
*/
it("testGet014", 0, function () {
let vector = new Vector();
vector.add("");
vector.add("");
......@@ -151,7 +236,14 @@ describe("VectorTest", function () {
expect(err.message).assertEqual("the index is out-of-bounds");
}
});
it("SR000GGR47_testGetIndexOf015", 0, function () {
/**
* @tc.name: testGetIndexOf015
* @tc.desc: In the Vector instance, find the index of a specified element from front to back,
* and return the index found for the first time. If not found, return -1. For example: vector.getIndexOf(1).
* @tc.author: wangyong
*/
it("testGetIndexOf015", 0, function () {
let vector = new Vector();
vector.add(1);
vector.add("");
......@@ -161,7 +253,13 @@ describe("VectorTest", function () {
let res1 = vector.getIndexOf(1);
expect(res1).assertEqual(0);
});
it("SR000GGR47_testGetFirstElement016", 0, function () {
/**
* @tc.name: testGetFirstElement016
* @tc.desc: Get the header element of the Vector instance. For example: vector.getFirstElement().
* @tc.author: wangyong
*/
it("testGetFirstElement016", 0, function () {
let vector = new Vector();
vector.add("");
vector.add("");
......@@ -171,12 +269,24 @@ describe("VectorTest", function () {
let res = vector.getFirstElement();
expect(res).assertEqual("");
});
it("SR000GGR47_testGetFirstElement017", 0, function () {
/**
* @tc.name: testGetFirstElement017
* @tc.desc: Get the header element of the Vector instance. For example: vector.getFirstElement().
* @tc.author: wangyong
*/
it("testGetFirstElement017", 0, function () {
let vector = new Vector();
let res = vector.getFirstElement();
expect(res).assertEqual(undefined);
});
it("SR000GGR47_testSet018", 0, function () {
/**
* @tc.name: testSet018
* @tc.desc: Modify the element corresponding to the specified index. For example: vector.set(1, "二").
* @tc.author: wangyong
*/
it("testSet018", 0, function () {
let vector = new Vector();
vector.add("");
vector.add("");
......@@ -187,7 +297,13 @@ describe("VectorTest", function () {
let res = vector.get(1);
expect(res).assertEqual("");
});
it("SR000GGR47_testRemoveByIndex019", 0, function () {
/**
* @tc.name: testRemoveByIndex019
* @tc.desc: In the Vector instance, delete the element based on its index. For example: vector.removeByIndex(2).
* @tc.author: wangyong
*/
it("testRemoveByIndex019", 0, function () {
let vector = new Vector();
vector.add("");
vector.add("");
......@@ -197,7 +313,13 @@ describe("VectorTest", function () {
let res = vector.has(1);
expect(res).assertEqual(false);
});
it("SR000GGR47_testRemove020", 0, function () {
/**
* @tc.name: testRemove020
* @tc.desc: Delete the specified element. For example: vector.remove("三").
* @tc.author: wangyong
*/
it("testRemove020", 0, function () {
let vector = new Vector();
vector.add("");
vector.add("");
......@@ -207,7 +329,13 @@ describe("VectorTest", function () {
let res = vector.has("");
expect(res).assertEqual(false);
});
it("SR000GGR47_testRemove021", 0, function () {
/**
* @tc.name: testRemove021
* @tc.desc: Delete the specified element. For example: vector.remove(2).
* @tc.author: wangyong
*/
it("testRemove021", 0, function () {
let vector = new Vector();
vector.add("");
vector.add("");
......@@ -216,7 +344,13 @@ describe("VectorTest", function () {
let res = vector.remove(2);
expect(res).assertEqual(false);
});
it("SR000GGR47_testGetLastElement022", 0, function () {
/**
* @tc.name: testGetLastElement022
* @tc.desc: Get the end element of the Vector instance. For example: vector.getLastElement().
* @tc.author: wangyong
*/
it("testGetLastElement022", 0, function () {
let vector = new Vector();
vector.add("");
vector.add("");
......@@ -226,12 +360,25 @@ describe("VectorTest", function () {
let res = vector.getLastElement();
expect(res).assertEqual("a");
});
it("SR000GGR47_testGetLastElement023", 0, function () {
/**
* @tc.name: testGetLastElement023
* @tc.desc: Get the end element of the Vector instance. For example: vector.getLastElement().
* @tc.author: wangyong
*/
it("testGetLastElement023", 0, function () {
let vector = new Vector();
let res = vector.getLastElement();
expect(res).assertEqual(undefined);
});
it("SR000GGR47_testGetLastIndexOf024", 0, function () {
/**
* @tc.name: testGetLastIndexOf024
* @tc.desc: In the Vector instance, find the index of a specified element from back to front,
* and return the index found for the first time. If not found, return -1. For example: vector.getLastIndexOf(1).
* @tc.author: wangyong
*/
it("testGetLastIndexOf024", 0, function () {
let vector = new Vector();
vector.add("");
vector.add("");
......@@ -242,7 +389,15 @@ describe("VectorTest", function () {
let res = vector.getLastIndexOf(1);
expect(res).assertEqual(4);
});
it("SR000GGR47_testGetLastIndexFrom025", 0, function () {
/**
* @tc.name: testGetLastIndexFrom025
* In the vector instance, find the index of the specified element from back to front
* from the specified index position, and return the index found for the first time If not found,
* return -1.vector.getLastIndexFrom(1, 5).
* @tc.author: wangyong
*/
it("testGetLastIndexFrom025", 0, function () {
let vector = new Vector();
vector.add("");
vector.add("");
......@@ -255,7 +410,15 @@ describe("VectorTest", function () {
let res = vector.getLastIndexFrom(1, 5);
expect(res).assertEqual(4);
});
it("SR000GGR47_testGetIndexFrom026", 0, function () {
/**
* @tc.name: testGetIndexFrom026
* In the vector instance, find the index of the specified element from front to back
* from the specified index position, and return the index found for the first time If not found,
* return -1.vector.getLastIndexFrom(1, 5).
* @tc.author: wangyong
*/
it("testGetIndexFrom026", 0, function () {
let vector = new Vector();
vector.add("");
vector.add("");
......@@ -268,7 +431,14 @@ describe("VectorTest", function () {
let res = vector.getIndexFrom(1, 5);
expect(res).assertEqual(7);
});
it("SR000GGR47_testRemoveByRange027", 0, function () {
/**
* @tc.name: testRemoveByRange027
* @tc.desc: Deletes elements from a specified range, including elements at the start position and
* elements at the end position. For example: vector.removeByRange(1, 3).
* @tc.author: wangyong
*/
it("testRemoveByRange027", 0, function () {
let vector = new Vector();
vector.add("");
vector.add("");
......@@ -288,7 +458,14 @@ describe("VectorTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR47_testRemoveByRange028", 0, function () {
/**
* @tc.name: testRemoveByRange028
* @tc.desc: Deletes elements from a specified range, including elements at the start position and
* elements at the end position. For example: vector.removeByRange(3, 1).
* @tc.author: wangyong
*/
it("testRemoveByRange028", 0, function () {
let vector = new Vector();
vector.add("");
vector.add("");
......@@ -305,7 +482,14 @@ describe("VectorTest", function () {
expect(err.message).assertEqual("the fromIndex cannot be less than or equal to toIndex");
}
});
it("SR000GGR47_testRemoveByRange029", 0, function () {
/**
* @tc.name: testRemoveByRange029
* @tc.desc: Deletes elements from a specified range, including elements at the start position and
* elements at the end position. For example: vector.removeByRange(length + 1, 7).
* @tc.author: wangyong
*/
it("testRemoveByRange029", 0, function () {
let vector = new Vector();
vector.add("");
vector.add("");
......@@ -318,7 +502,14 @@ describe("VectorTest", function () {
expect(err.message).assertEqual("the fromIndex or the toIndex is out-of-bounds");
}
});
it("SR000GGR47_testRemoveByRange030", 0, function () {
/**
* @tc.name: testRemoveByRange030
* @tc.desc: Deletes elements from a specified range, including elements at the start position and
* elements at the end position. For example: vector.removeByRange(1, 7).
* @tc.author: wangyong
*/
it("testRemoveByRange030", 0, function () {
let vector = new Vector();
vector.add("");
vector.add("");
......@@ -331,7 +522,14 @@ describe("VectorTest", function () {
expect(err.message).assertEqual("the index is out-of-bounds");
}
});
it("SR000GGR47_testRemoveByRange031", 0, function () {
/**
* @tc.name: testRemoveByRange031
* @tc.desc: Deletes elements from a specified range, including elements at the start position and
* elements at the end position. For example: vector.removeByRange(0, capacity).
* @tc.author: wangyong
*/
it("testRemoveByRange031", 0, function () {
let vector = new Vector();
vector.add("");
vector.add("");
......@@ -349,7 +547,14 @@ describe("VectorTest", function () {
});
expect(arr.length).assertEqual(0);
});
it("SR000GGR47_testRemoveByRange032", 0, function () {
/**
* @tc.name: testRemoveByRange032
* @tc.desc: Deletes elements from a specified range, including elements at the start position and
* elements at the end position. For example: vector.removeByRange(-1, capacity).
* @tc.author: wangyong
*/
it("testRemoveByRange032", 0, function () {
let vector = new Vector();
vector.add("");
vector.add("");
......@@ -367,7 +572,14 @@ describe("VectorTest", function () {
expect(err.message).assertEqual("the fromIndex or the toIndex is out-of-bounds");
}
});
it("SR000GGR47_testRemoveByRange033", 0, function () {
/**
* @tc.name: testRemoveByRange033
* @tc.desc: Deletes elements from a specified range, including elements at the start position and
* elements at the end position. For example: vector.removeByRange(0, capacity + 1).
* @tc.author: wangyong
*/
it("testRemoveByRange033", 0, function () {
let vector = new Vector();
vector.add("");
vector.add("");
......@@ -382,7 +594,13 @@ describe("VectorTest", function () {
let length = vector.length;
expect(length).assertEqual(0);
});
it("SR000GGR47_testSetLength034", 0, function () {
/**
* @tc.name: testSetLength034
* @tc.desc: Get the number of elements contained in the Vector instance. For example: vector.length.
* @tc.author: wangyong
*/
it("testSetLength034", 0, function () {
let vector = new Vector();
vector.add("");
vector.add("");
......@@ -396,7 +614,14 @@ describe("VectorTest", function () {
let res1 = vector.length;
expect(res1).assertEqual(5);
});
it("SR000GGR47_testReplaceAllElements035", 0, function () {
/**
* @tc.name: testReplaceAllElements035
* @tc.desc: Perform some operation on the elements in the Vector instance and return the Vector instance
* after the operation. For example: vector.replaceAllElements((item, index) => {return (item = 2 * item);}).
* @tc.author: wangyong
*/
it("testReplaceAllElements035", 0, function () {
let vector = new Vector();
vector.add(4);
vector.add(3);
......@@ -415,7 +640,14 @@ describe("VectorTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR47_testForEach036", 0, function () {
/**
* @tc.name: testForEach036
* @tc.desc: Traversing elements in an Vector instance.
* For example: vector.forEach((item, index) => {arr.push(item);}).
* @tc.author: wangyong
*/
it("testForEach036", 0, function () {
let vector = new Vector();
vector.add(4);
vector.add(3);
......@@ -431,7 +663,14 @@ describe("VectorTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR47_testForEach037", 0, function () {
/**
* @tc.name: testForEach037
* @tc.desc: Traversing elements in an Vector instance.
* For example: vector.forEach((item, index) => {arr.push(item);}).
* @tc.author: wangyong
*/
it("testForEach037", 0, function () {
let vector = new Vector();
let arr = [];
vector.forEach((item, index) => {
......@@ -440,7 +679,14 @@ describe("VectorTest", function () {
let a = [4, 3, 1, 2, 14];
expect(arr.length).assertEqual(0);
});
it("SR000GGR47_testSubVector038", 0, function () {
/**
* @tc.name: testSubVector038
* @tc.desc: Intercepts an element within the specified range, including the element with the
* starting index but not the element with the ending index. For example: vector.subVector(2, 4).
* @tc.author: wangyong
*/
it("testSubVector038", 0, function () {
let vector = new Vector();
vector.add(4);
vector.add(3);
......@@ -457,7 +703,14 @@ describe("VectorTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR47_testSubVector039", 0, function () {
/**
* @tc.name: testSubVector039
* @tc.desc: Intercepts an element within the specified range, including the element with the
* starting index but not the element with the ending index. For example: vector.subVector(4, 2).
* @tc.author: wangyong
*/
it("testSubVector039", 0, function () {
let vector = new Vector();
vector.add(4);
vector.add(3);
......@@ -471,7 +724,14 @@ describe("VectorTest", function () {
expect(err.message).assertEqual("the fromIndex cannot be less than or equal to toIndex");
}
});
it("SR000GGR47_testSubVector040", 0, function () {
/**
* @tc.name: testSubVector040
* @tc.desc: Intercepts an element within the specified range, including the element with the
* starting index but not the element with the ending index. For example: vector.subVector(length + 1, length + 3).
* @tc.author: wangyong
*/
it("testSubVector040", 0, function () {
let vector = new Vector();
vector.add(4);
vector.add(3);
......@@ -486,7 +746,14 @@ describe("VectorTest", function () {
expect(err.message).assertEqual("the fromIndex or the toIndex is out-of-bounds");
}
});
it("SR000GGR47_testSubVector041", 0, function () {
/**
* @tc.name: testSubVector041
* @tc.desc: Intercepts an element within the specified range, including the element with the
* starting index but not the element with the ending index. For example: vector.vector.subVector(1, length + 1).
* @tc.author: wangyong
*/
it("testSubVector041", 0, function () {
let vector = new Vector();
vector.add(4);
vector.add(3);
......@@ -501,7 +768,13 @@ describe("VectorTest", function () {
expect(err.message).assertEqual("the fromIndex or the toIndex is out-of-bounds");
}
});
it("SR000GGR47_testClear042", 0, function () {
/**
* @tc.name: testClear042
* @tc.desc: Clear all elements in the Vector instance. For example: vector.clear().
* @tc.author: wangyong
*/
it("testClear042", 0, function () {
let vector = new Vector();
vector.add(4);
vector.add(3);
......@@ -512,7 +785,13 @@ describe("VectorTest", function () {
let res = vector.length;
expect(res).assertEqual(0);
});
it("SR000GGR47_testConvertToArray043", 0, function () {
/**
* @tc.name: testConvertToArray043
* @tc.desc: Convert an Vector instance to an array. For example: vector.convertToArray().
* @tc.author: wangyong
*/
it("testConvertToArray043", 0, function () {
let vector = new Vector();
vector.add(4);
vector.add(3);
......@@ -525,7 +804,14 @@ describe("VectorTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR47_testCopyToArray044", 0, function () {
/**
* @tc.name: testCopyToArray044
* @tc.desc: Appends the number of elements of corresponding length to a specified array.
* For example: vector.copyToArray(arr1).
* @tc.author: wangyong
*/
it("testCopyToArray044", 0, function () {
let vector = new Vector();
vector.add(4);
vector.add(3);
......@@ -539,7 +825,13 @@ describe("VectorTest", function () {
expect(arr1[i]).assertEqual(a[i]);
}
});
it("SR000GGR47_testToString045", 0, function () {
/**
* @tc.name: testToString045
* @tc.desc: Use "," to splice the elements in the vector instance into a string. For example: vector.toString().
* @tc.author: wangyong
*/
it("testToString045", 0, function () {
let vector = new Vector();
vector.add(4);
vector.add(3);
......@@ -549,7 +841,13 @@ describe("VectorTest", function () {
let res = vector.toString();
expect(res).assertEqual("4,3,1,2,14");
});
it("SR000GGR47_testClone046", 0, function () {
/**
* @tc.name: testClone046
* @tc.desc: Clone an ArrayList instance. For example: vector.clone().
* @tc.author: wangyong
*/
it("testClone046", 0, function () {
let vector = new Vector();
vector.add(4);
vector.add(3);
......@@ -566,7 +864,13 @@ describe("VectorTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR47_testGetCapacity047", 0, function () {
/**
* @tc.name: testGetCapacity047
* @tc.desc: Get the capacity of Vector instance. For example: vector.getCapacity().
* @tc.author: wangyong
*/
it("testGetCapacity047", 0, function () {
let vector = new Vector();
vector.add(4);
vector.add(3);
......@@ -576,7 +880,13 @@ describe("VectorTest", function () {
let res = vector.getCapacity();
expect(res).assertEqual(10);
});
it("SR000GGR47_testGetCapacity048", 0, function () {
/**
* @tc.name: testGetCapacity048
* @tc.desc: Get the capacity of Vector instance. For example: vector.getCapacity().
* @tc.author: wangyong
*/
it("testGetCapacity048", 0, function () {
let vector = new Vector();
vector.add(4);
vector.add(3);
......@@ -593,7 +903,13 @@ describe("VectorTest", function () {
let res = vector.getCapacity();
expect(res).assertEqual(20);
});
it("SR000GGR47_testIncreaseCapacityTo049", 0, function () {
/**
* @tc.name: testIncreaseCapacityTo049
* @tc.desc: Expand the Vector instance capacity to the specified value. For example: vector.increaseCapacityTo(30).
* @tc.author: wangyong
*/
it("testIncreaseCapacityTo049", 0, function () {
let vector = new Vector();
vector.add(4);
vector.add(3);
......@@ -604,7 +920,14 @@ describe("VectorTest", function () {
let res = vector.getCapacity();
expect(res).assertEqual(30);
});
it("SR000GGR47_testTrimToCurrentLength050", 0, function () {
/**
* @tc.name: testTrimToCurrentLength050
* @tc.desc: Limit the Vector instance capacity to the length of the Vector instance.
* For example: vector.trimToCurrentLength().
* @tc.author: wangyong
*/
it("testTrimToCurrentLength050", 0, function () {
let vector = new Vector();
vector.add(4);
vector.add(3);
......@@ -615,7 +938,13 @@ describe("VectorTest", function () {
let res = vector.getCapacity();
expect(res).assertEqual(5);
});
it("SR000GGR47_testSetLength051", 0, function () {
/**
* @tc.name: testSetLength051
* @tc.desc: Sets the length of the vector instance to the specified value. For example: vector.setLength(7).
* @tc.author: wangyong
*/
it("testSetLength051", 0, function () {
let vector = new Vector();
vector.add(4);
vector.add(3);
......@@ -626,7 +955,14 @@ describe("VectorTest", function () {
let res1 = vector.length;
expect(res1).assertEqual(7);
});
it("SR000GGR47_testIterator052", 0, function () {
/**
* @tc.name: testIterator052
* @tc.desc: Iterate over all elements in the Vector instance.
* For example: for (let item of vector) {arr.push(item);}.
* @tc.author: wangyong
*/
it("testIterator052", 0, function () {
let vector = new Vector();
vector.add(8);
vector.add("");
......@@ -646,7 +982,13 @@ describe("VectorTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR47_testIteratorAndRemove053", 0, function () {
/**
* @tc.name: testIteratorAndRemove053
* @tc.desc: Iterate over all elements in the Vector instance.
* @tc.author: wangyong
*/
it("testIteratorAndRemove053", 0, function () {
let vector = new Vector();
vector.add(8);
vector.add("");
......@@ -672,7 +1014,13 @@ describe("VectorTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR47_testIteratorAndRemove054", 0, function () {
/**
* @tc.name: testIteratorAndRemove054
* @tc.desc: Iterate over all elements in the Vector instance.
* @tc.author: wangyong
*/
it("testIteratorAndRemove054", 0, function () {
let vector = new Vector();
vector.add(8);
vector.add("");
......@@ -696,7 +1044,14 @@ describe("VectorTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR47_testIterator055", 0, function () {
/**
* @tc.name: testIterator055
* @tc.desc: Iterate over all elements in the Vector instance.
* For example: for (let item of vector) {arr.push(item);}.
* @tc.author: wangyong
*/
it("testIterator055", 0, function () {
let vector = new Vector();
let arr = [];
for (let item of vector) {
......@@ -704,7 +1059,14 @@ describe("VectorTest", function () {
}
expect(arr.length).assertEqual(0);
});
it("SR000GGR47_testSort056", 0, function () {
/**
* @tc.name: testSort056
* @tc.desc: Arrange the elements in the Vector instance in descending order.
* For example: vector.sort((a, b) => a - b).
* @tc.author: wangyong
*/
it("testSort056", 0, function () {
let vector = new Vector();
vector.add(4);
vector.add(3);
......@@ -721,18 +1083,37 @@ describe("VectorTest", function () {
expect(arr[i]).assertEqual(a[i]);
}
});
it("SR000GGR47_testisEmpty057", 0, function () {
/**
* @tc.name: testIsEmpty057
* @tc.desc: Determine whether the Vector instance is empty. For example: vector.isEmpty().
* @tc.author: wangyong
*/
it("testIsEmpty057", 0, function () {
let vector = new Vector();
vector.add("");
let res = vector.isEmpty();
expect(res).assertEqual(false);
});
it("SR000GGR47_testisEmpty058", 0, function () {
/**
* @tc.name: testisEmpty058
* @tc.desc: Determine whether the Vector instance is empty. For example: vector.isEmpty().
* @tc.author: wangyong
*/
it("testisEmpty058", 0, function () {
let vector = new Vector();
let res = vector.isEmpty();
expect(res).assertEqual(true);
});
it("SR000GGR47_testAdd060", 0, function () {
/**
* @tc.name: testAdd060
* @tc.desc: Add a element to the end of the Vector instance.
* For example: for (let i = 0; i < 100; i++) {let res3 = vector.add(i);}.
* @tc.author: wangyong
*/
it("testAdd060", 0, function () {
let vector = new Vector();
for (let i = 0; i < 100; i++) {
let res3 = vector.add(i);
......@@ -742,31 +1123,62 @@ describe("VectorTest", function () {
expect(res).assertEqual(99);
expect(res1).assertEqual(100);
});
it("SR000GGR47_testAdd061 ", 0, function () {
/**
* @tc.name: testAdd061
* @tc.desc: Add a element to the end of the Vector instance. For example: vector.add("%").
* @tc.author: wangyong
*/
it("testAdd061", 0, function () {
let vector = new Vector();
vector.add("%");
let res = vector.getFirstElement();
expect(res).assertEqual("%");
});
it("SR000GGR47_testAdd062 ", 0, function () {
/**
* @tc.name: testAdd062
* @tc.desc: Add a element to the end of the Vector instance. For example: vector.add(1.89).
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testAdd063
* @tc.desc: Add a element to the end of the Vector instance. For example: vector.add("").
* @tc.author: wangyong
*/
it("testAdd063", 0, function () {
let vector = new Vector();
vector.add("");
let res = vector.getFirstElement();
expect(res).assertEqual("");
});
it("SR000GGR47_testAdd064 ", 0, function () {
/**
* @tc.name: testAdd064
* @tc.desc: Add a element to the end of the Vector instance. For example: vector.add(true).
* @tc.author: wangyong
*/
it("testAdd064", 0, function () {
let vector = new Vector();
vector.add(true);
let res = vector.getFirstElement();
expect(res).assertEqual(true);
});
it("SR000GGR47_testGetIndexOf065", 0, function () {
/**
* @tc.name: testGetIndexOf065
* @tc.desc: In the Vector instance, find the index of a specified element from front to back,
* and return the index found for the first time. If not found, return -1. For example: vector.getIndexOf(23).
* @tc.author: wangyong
*/
it("testGetIndexOf065", 0, function () {
let vector = new Vector();
vector.add(1);
vector.add(2);
......@@ -774,7 +1186,13 @@ describe("VectorTest", function () {
let res = vector.getIndexOf(23);
expect(res).assertEqual(-1);
});
it("SR000GGR47_testSet066", 0, function () {
/**
* @tc.name: testSet066
* @tc.desc: Modify the element corresponding to the specified index. For example: vector.set(12, "二").
* @tc.author: wangyong
*/
it("testSet066", 0, function () {
let vector = new Vector();
vector.add("");
vector.add("");
......@@ -785,7 +1203,13 @@ describe("VectorTest", function () {
expect(err.message).assertEqual("the index is out-of-bounds");
}
});
it("SR000GGR47_testRemoveByIndex067", 0, function () {
/**
* @tc.name: testRemoveByIndex067
* @tc.desc: In the Vector instance, delete the element based on its index. For example: vector.removeByIndex(12).
* @tc.author: wangyong
*/
it("testRemoveByIndex067", 0, function () {
let vector = new Vector();
vector.add("");
vector.add("");
......@@ -796,14 +1220,27 @@ describe("VectorTest", function () {
expect(err.message).assertEqual("the index is out-of-bounds");
}
});
it("SR000GGR47_testGetLastIndexOf068", 0, function () {
/**
* @tc.name: testGetLastIndexOf068
* @tc.desc: In the Vector instance, find the index of a specified element from back to front,
* and return the index found for the first time. If not found, return -1. For example: vector.getLastIndexOf("二").
* @tc.author: wangyong
*/
it("testGetLastIndexOf068", 0, function () {
let vector = new Vector();
vector.add("");
vector.add("");
let res = vector.getLastIndexOf("");
expect(res).assertEqual(-1);
});
it("SR000GGR47_testIterator069", 0, function () {
/**
* @tc.name: testIterator069
* @tc.desc: Iterate over all elements in the Vector instance. For example: Vector[Symbol.iterator]().
* @tc.author: wangyong
*/
it("testIterator069", 0, function () {
let vector = new Vector();
vector.add(8);
vector.add("");
......
......@@ -16,7 +16,13 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
import HashMap from "@ohos.util.HashMap";
describe("HashMapTest", function () {
it("SR000GGR4B_testConstructor001", 0, function () {
/**
* @tc.name: testConstructor001
* @tc.desc: Create an HashMap instance. For example: let hashMap = new HashMap().
* @tc.author: wangyong
*/
it("testConstructor001", 0, function () {
try {
let hashMap = new HashMap();
expect(hashMap != undefined).assertEqual(true);
......@@ -25,107 +31,211 @@ describe("HashMapTest", function () {
expect(err.message).assertEqual("Cannot create new HashMap");
}
});
it("SR000GGR4B_testSet002", 0, function () {
/**
* @tc.name: testSet002
* @tc.desc: Add a pair of key value pairs to the HashMap. For example: hashMap.set(1, "A").
* @tc.author: wangyong
*/
it("testSet002", 0, function () {
let hashMap = new HashMap();
hashMap.set(1, "A");
let res = hashMap.get(1);
expect(res).assertEqual("A");
});
it("SR000GGR4B_testSet003", 0, function () {
/**
* @tc.name: testSet003
* @tc.desc: Add a pair of key value pairs to the HashMap. For example: hashMap.set(1, 2).
* @tc.author: wangyong
*/
it("testSet003", 0, function () {
let hashMap = new HashMap();
hashMap.set(1, 2);
let res = hashMap.get(1);
expect(res).assertEqual(2);
});
it("SR000GGR4B_testSet004", 0, function () {
/**
* @tc.name: testSet004
* @tc.desc: Add a pair of key value pairs to the HashMap. For example: let c = [1, 2, 3]; hashMap.set(1, c).
* @tc.author: wangyong
*/
it("testSet004", 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_testSet005", 0, function () {
/**
* @tc.name: testSet005
* @tc.desc: Add a pair of key value pairs to the HashMap.
* For example: let c = {name: "lili", age: "13"}; hashMap.set(1, c).
* @tc.author: wangyong
*/
it("testSet005", 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_testSet006", 0, function () {
/**
* @tc.name: testSet006
* @tc.desc: Add a pair of key value pairs to the HashMap. For example: hashMap.set("a", "A").
* @tc.author: wangyong
*/
it("testSet006", 0, function () {
let hashMap = new HashMap();
hashMap.set("a", "A");
let res = hashMap.get("a");
expect(res).assertEqual("A");
});
it("SR000GGR4B_testSet007", 0, function () {
/**
* @tc.name: testSet007
* @tc.desc: Add a pair of key value pairs to the HashMap. For example: hashMap.set("", "A").
* @tc.author: wangyong
*/
it("testSet007", 0, function () {
let hashMap = new HashMap();
hashMap.set("", "A");
let res = hashMap.get("");
expect(res).assertEqual("A");
});
it("SR000GGR4B_testSet008", 0, function () {
/**
* @tc.name: testSet008
* @tc.desc: Add a pair of key value pairs to the HashMap. For example: hashMap.set("$", "A").
* @tc.author: wangyong
*/
it("testSet008", 0, function () {
let hashMap = new HashMap();
hashMap.set("$", "A");
let res = hashMap.get("$");
expect(res).assertEqual("A");
});
it("SR000GGR4B_testSet009", 0, function () {
/**
* @tc.name: testSet009
* @tc.desc: Add a pair of key value pairs to the HashMap. For example: hashMap.set(3.14, "A").
* @tc.author: wangyong
*/
it("testSet009", 0, function () {
let hashMap = new HashMap();
hashMap.set(3.14, "A");
let res = hashMap.get(3.14);
expect(res).assertEqual("A");
});
it("SR000GGR4B_testSet010", 0, function () {
/**
* @tc.name: testSet010
* @tc.desc: Add a pair of key value pairs to the HashMap. For example: hashMap.set(0.3, "A").
* @tc.author: wangyong
*/
it("testSet010", 0, function () {
let hashMap = new HashMap();
hashMap.set(0.3, "A");
let res = hashMap.get(0.3);
expect(res).assertEqual("A");
});
it("SR000GGR4B_testSet011", 0, function () {
/**
* @tc.name: testSet011
* @tc.desc: Add a pair of key value pairs to the HashMap. For example: hashMap.set(-1, "A").
* @tc.author: wangyong
*/
it("testSet011", 0, function () {
let hashMap = new HashMap();
hashMap.set(-1, "A");
let res = hashMap.get(-1);
expect(res).assertEqual("A");
});
it("SR000GGR4B_testSet012", 0, function () {
/**
* @tc.name: testSet012
* @tc.desc: Add a pair of key value pairs to the HashMap. For example: let a = {}; hashMap.set(a, "A").
* @tc.author: wangyong
*/
it("testSet012", 0, function () {
let hashMap = new HashMap();
let a = {};
hashMap.set(a, "A");
let res = hashMap.get(a);
expect(res).assertEqual("A");
});
it("SR000GGR4B_testSet013", 0, function () {
/**
* @tc.name: testSet013
* @tc.desc: Add a pair of key value pairs to the HashMap. For example: hashMap.set(1, null).
* @tc.author: wangyong
*/
it("testSet013", 0, function () {
let hashMap = new HashMap();
hashMap.set(1, null);
let res = hashMap.get(1);
expect(res).assertEqual(null);
});
it("SR000GGR4B_testSet014", 0, function () {
/**
* @tc.name: testSet014
* @tc.desc: Add a pair of key value pairs to the HashMap. For example: hashMap.set(1, "$").
* @tc.author: wangyong
*/
it("testSet014", 0, function () {
let hashMap = new HashMap();
hashMap.set(1, "$");
let res = hashMap.get(1);
expect(res).assertEqual("$");
});
it("SR000GGR4B_testSet015", 0, function () {
/**
* @tc.name: testSet015
* @tc.desc: Add a pair of key value pairs to the HashMap. For example: hashMap.set(1, "3.14").
* @tc.author: wangyong
*/
it("testSet015", 0, function () {
let hashMap = new HashMap();
hashMap.set(1, 3.14);
let res = hashMap.get(1);
expect(res).assertEqual(3.14);
});
it("SR000GGR4B_testSet016", 0, function () {
/**
* @tc.name: testSet016
* @tc.desc: Add a pair of key value pairs to the HashMap. For example: hashMap.set(1, -1).
* @tc.author: wangyong
*/
it("testSet016", 0, function () {
let hashMap = new HashMap();
hashMap.set(1, -1);
let res = hashMap.get(1);
expect(res).assertEqual(-1);
});
it("SR000GGR4B_testSet017", 0, function () {
/**
* @tc.name: testSet017
* @tc.desc: Add a pair of key value pairs to the HashMap. For example: let a = {}; hashMap.set(1, a).
* @tc.author: wangyong
*/
it("testSet017", 0, function () {
let hashMap = new HashMap();
let a = {};
hashMap.set(1, a);
let res = hashMap.get(1);
expect(res).assertEqual(a);
});
it("SR000GGR4B_testSet018", 0, function () {
/**
* @tc.name: testSet018
* @tc.desc: Add a pair of key value pairs to the HashMap.
* For example: for (let i = 0; i < 100; i++) {hashMap.set(1, i);}.
* @tc.author: wangyong
*/
it("testSet018", 0, function () {
let hashMap = new HashMap();
for (let i = 0; i < 100; i++) {
hashMap.set(1, i);
......@@ -135,7 +245,13 @@ describe("HashMapTest", function () {
expect(res).assertEqual(99);
expect(res1).assertEqual(1);
});
it("SR000GGR4B_testSet019", 0, function () {
/**
* @tc.name: testSet019
* @tc.desc: Add a pair of key value pairs to the HashMap.
* @tc.author: wangyong
*/
it("testSet019", 0, function () {
let hashMap = new HashMap();
for (let i = 0; i < 100; i++) {
hashMap.set(i, 1);
......@@ -145,7 +261,13 @@ describe("HashMapTest", function () {
let res1 = hashMap.length;
expect(res1).assertEqual(100);
});
it("SR000GGR4B_testLength020", 0, function () {
/**
* @tc.name: testLength020
* @tc.desc: Get the number of key value pairs in the HashMap instance. For example: hashMap.length.
* @tc.author: wangyong
*/
it("testLength020", 0, function () {
let hashMap = new HashMap();
hashMap.set(1, "A");
hashMap.set(2, "B");
......@@ -155,7 +277,13 @@ describe("HashMapTest", function () {
let res = hashMap.length;
expect(res).assertEqual(5);
});
it("SR000GGR4B_testHasKey021", 0, function () {
/**
* @tc.name: testHasKey021
* @tc.desc: Determine whether the HashMap contains the specified key. For example: hashMap.hasKey(3).
* @tc.author: wangyong
*/
it("testHasKey021", 0, function () {
let hashMap = new HashMap();
hashMap.set(1, "A");
hashMap.set(2, "B");
......@@ -167,12 +295,24 @@ describe("HashMapTest", function () {
let res1 = hashMap.hasKey(8);
expect(res1).assertEqual(false);
});
it("SR000GGR4B_testHasKey022", 0, function () {
/**
* @tc.name: testHasKey022
* @tc.desc: Determine whether the HashMap contains the specified key. For example: hashMap.hasKey(8).
* @tc.author: wangyong
*/
it("testHasKey022", 0, function () {
let hashMap = new HashMap();
let res = hashMap.hasKey(8);
expect(res).assertEqual(false);
});
it("SR000GGR4B_testHasValue023", 0, function () {
/**
* @tc.name: testHasValue023
* @tc.desc: Determine whether the HashMap contains the specified value. For example: hashMap.hasValue("C").
* @tc.author: wangyong
*/
it("testHasValue023", 0, function () {
let hashMap = new HashMap();
hashMap.set(1, "A");
hashMap.set(2, "B");
......@@ -184,12 +324,24 @@ describe("HashMapTest", function () {
let res1 = hashMap.hasValue(8);
expect(res1).assertEqual(false);
});
it("SR000GGR4B_testHasValue024", 0, function () {
/**
* @tc.name: testHasValue024
* @tc.desc: Determine whether the HashMap contains the specified value. For example: hashMap.hasValue(8).
* @tc.author: wangyong
*/
it("testHasValue024", 0, function () {
let hashMap = new HashMap();
let res = hashMap.hasValue(8);
expect(res).assertEqual(false);
});
it("SR000GGR4B_testGet025", 0, function () {
/**
* @tc.name: testGet025
* @tc.desc: Get the corresponding value through the key. For example: hashMap.get(3).
* @tc.author: wangyong
*/
it("testGet025", 0, function () {
let hashMap = new HashMap();
hashMap.set(1, "A");
hashMap.set(2, "B");
......@@ -199,12 +351,24 @@ describe("HashMapTest", function () {
let res = hashMap.get(3);
expect(res).assertEqual("C");
});
it("SR000GGR4B_testGet026", 0, function () {
/**
* @tc.name: testGet026
* @tc.desc: Get the corresponding value through the key. For example: hashMap.get(3).
* @tc.author: wangyong
*/
it("testGet026", 0, function () {
let hashMap = new HashMap();
let res = hashMap.get(3);
expect(res).assertEqual(undefined);
});
it("SR000GGR4B_testSetAll027", 0, function () {
/**
* @tc.name: testSetAll027
* @tc.desc: Copy key value pairs from one HashMap to another.
* @tc.author: wangyong
*/
it("testSetAll027", 0, function () {
let hashMap = new HashMap();
hashMap.set(1, "A");
hashMap.set(2, "B");
......@@ -228,7 +392,13 @@ describe("HashMapTest", function () {
expect(arr[i][1]).assertEqual(hashMap.get(i + 1));
}
});
it("SR000GGR4B_testSetAll028", 0, function () {
/**
* @tc.name: testSetAll028
* @tc.desc: Copy key value pairs from one HashMap to another.
* @tc.author: wangyong
*/
it("testSetAll028", 0, function () {
let hashMap = new HashMap();
let hashMap1 = new HashMap();
hashMap1.set(1, 1);
......@@ -247,7 +417,13 @@ describe("HashMapTest", function () {
);
}
});
it("SR000GGR4B_testRemove029", 0, function () {
/**
* @tc.name: testRemove029
* @tc.desc: Delete key value pairs according to key. For example: hashMap.remove(3).
* @tc.author: wangyong
*/
it("testRemove029", 0, function () {
let hashMap = new HashMap();
hashMap.set(1, "A");
hashMap.set(2, "B");
......@@ -259,12 +435,24 @@ describe("HashMapTest", function () {
let res1 = hashMap.length;
expect(res1).assertEqual(4);
});
it("SR000GGR4B_testRemove030", 0, function () {
/**
* @tc.name: testRemove030
* @tc.desc: Delete key value pairs according to key. For example: hashMap.remove(3).
* @tc.author: wangyong
*/
it("testRemove030", 0, function () {
let hashMap = new HashMap();
let res = hashMap.remove(3);
expect(res).assertEqual(undefined);
});
it("SR000GGR4B_testClear031", 0, function () {
/**
* @tc.name: testClear031
* @tc.desc: Clear all key value pairs in HashMap. For example: hashMap.clear().
* @tc.author: wangyong
*/
it("testClear031", 0, function () {
let hashMap = new HashMap();
hashMap.set(1, "A");
hashMap.set(2, "B");
......@@ -277,13 +465,25 @@ describe("HashMapTest", function () {
let res1 = hashMap.length;
expect(res1).assertEqual(0);
});
it("SR000GGR4B_testClear032", 0, function () {
/**
* @tc.name: testClear032
* @tc.desc: Clear all key value pairs in HashMap. For example: hashMap.clear().
* @tc.author: wangyong
*/
it("testClear032", 0, function () {
let hashMap = new HashMap();
hashMap.clear();
let res = hashMap.length;
expect(res).assertEqual(0);
});
it("SR000GGR4B_testKeys033", 0, function () {
/**
* @tc.name: testKeys033
* @tc.desc: Get a collection of all the keys in the HashMap. For example: hashMap.keys().
* @tc.author: wangyong
*/
it("testKeys033", 0, function () {
let hashMap = new HashMap();
hashMap.set(1, "A");
hashMap.set(2, "B");
......@@ -295,7 +495,13 @@ describe("HashMapTest", function () {
console.log(res.next());
}
});
it("SR000GGR4B_testValues034", 0, function () {
/**
* @tc.name: testValues034
* @tc.desc: Get a collection of all the values in the HashMap. For example: hashMap.values().
* @tc.author: wangyong
*/
it("testValues034", 0, function () {
let hashMap = new HashMap();
hashMap.set(1, "A");
hashMap.set(2, "B");
......@@ -308,7 +514,13 @@ describe("HashMapTest", function () {
expect(has).assertEqual(true);
}
});
it("SR000GGR4B_testReplace035", 0, function () {
/**
* @tc.name: testReplace035
* @tc.desc: Modify the corresponding value according to the specified key. For example: hashMap.replace(2, "G").
* @tc.author: wangyong
*/
it("testReplace035", 0, function () {
let hashMap = new HashMap();
hashMap.set(1, "A");
hashMap.set(2, "B");
......@@ -319,12 +531,24 @@ describe("HashMapTest", function () {
expect(res).assertEqual(true);
expect(hashMap.get(2)).assertEqual("G");
});
it("SR000GGR4B_testReplace036", 0, function () {
/**
* @tc.name: testReplace036
* @tc.desc: Modify the corresponding value according to the specified key. For example: hashMap.replace(2, "G").
* @tc.author: wangyong
*/
it("testReplace036", 0, function () {
let hashMap = new HashMap();
let res = hashMap.replace(2, "G");
expect(res).assertEqual(false);
});
it("SR000GGR4B_testForEach037", 0, function () {
/**
* @tc.name: testForEach037
* @tc.desc: Traverse all key value pairs in the HashMap instance.
* @tc.author: wangyong
*/
it("testForEach037", 0, function () {
let hashMap = new HashMap();
hashMap.set(1, "A");
hashMap.set(2, "B");
......@@ -346,7 +570,13 @@ describe("HashMapTest", function () {
expect(has).assertEqual(true);
}
});
it("SR000GGR4B_testForEach038", 0, function () {
/**
* @tc.name: testForEach038
* @tc.desc: Traverse all key value pairs in the HashMap instance.
* @tc.author: wangyong
*/
it("testForEach038", 0, function () {
let hashMap = new HashMap();
let arr = [];
hashMap.forEach((item, index) => {
......@@ -354,7 +584,13 @@ describe("HashMapTest", function () {
});
expect(arr.length).assertEqual(0);
});
it("SR000GGR4B_testIterator039", 0, function () {
/**
* @tc.name: testIterator039
* @tc.desc: Iterate over all key value pairs in the HashMap.
* @tc.author: wangyong
*/
it("testIterator039", 0, function () {
let hashMap = new HashMap();
hashMap.set(1, "A");
hashMap.set(2, "B");
......@@ -373,7 +609,13 @@ describe("HashMapTest", function () {
expect(arr[i][1]).assertEqual(hashMap.get(i + 1));
}
});
it("SR000GGR4B_testIterator040", 0, function () {
/**
* @tc.name: testIterator040
* @tc.desc: Traverse all key value pairs in the HashMap instance.
* @tc.author: wangyong
*/
it("testIterator040", 0, function () {
let hashMap = new HashMap();
let arr = [];
for (let item of hashMap) {
......@@ -381,7 +623,13 @@ describe("HashMapTest", function () {
}
expect(arr.length).assertEqual(0);
});
it("SR000GGR4B_testEntries041", 0, function () {
/**
* @tc.name: testEntries041
* @tc.desc: Get all key value pairs collection in HashMap.
* @tc.author: wangyong
*/
it("testEntries041", 0, function () {
let hashMap = new HashMap();
hashMap.set(1, "A");
hashMap.set(2, "B");
......@@ -402,12 +650,24 @@ describe("HashMapTest", function () {
expect(arr[i][1]).assertEqual(hashMap.get(i + 1));
}
});
it("SR000GGR4B_testEntries042", 0, function () {
/**
* @tc.name: testEntries042
* @tc.desc: Get all key value pairs collection in HashMap.
* @tc.author: wangyong
*/
it("testEntries042", 0, function () {
let hashMap = new HashMap();
let res = hashMap.entries();
expect(undefined).assertEqual(res.next().value);
});
it("SR000GGR4B_testIsEmpty043", 0, function () {
/**
* @tc.name: testIsEmpty043
* @tc.desc: Determine whether the HashMap instance is empty. For example: hashMap.isEmpty().
* @tc.author: wangyong
*/
it("testIsEmpty043", 0, function () {
let hashMap = new HashMap();
hashMap.set(1, "A");
hashMap.set(2, "B");
......@@ -419,7 +679,13 @@ describe("HashMapTest", function () {
expect(res).assertEqual(5);
expect(res1).assertEqual(false);
});
it("SR000GGR4B_testIsEmpty044", 0, function () {
/**
* @tc.name: testIsEmpty044
* @tc.desc: Determine whether the HashMap instance is empty. For example: hashMap.isEmpty().
* @tc.author: wangyong
*/
it("testIsEmpty044", 0, function () {
let hashMap = new HashMap();
hashMap.set(1, "A");
hashMap.set(2, "B");
......@@ -432,12 +698,24 @@ describe("HashMapTest", function () {
expect(res).assertEqual(0);
expect(res1).assertEqual(true);
});
it("SR000GGR4B_testEntries045", 0, function () {
/**
* @tc.name: testEntries045
* @tc.desc: Get all key value pairs collection in HashMap.For example: hashMap.entries().
* @tc.author: wangyong
*/
it("testEntries045", 0, function () {
let hashMap = new HashMap();
let res = hashMap.entries();
expect(undefined).assertEqual(res.next().value);
});
it("SR000GGR4B_testIterator046", 0, function () {
/**
* @tc.name: testIterator046
* @tc.desc: Iterate over all key value pairs in the HashMap. For example: hashMap[Symbol.iterator]().
* @tc.author: wangyong
*/
it("testIterator046", 0, function () {
let hashMap = new HashMap();
hashMap.set(1, "A");
hashMap.set(2, "B");
......
......@@ -16,7 +16,13 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
import HashSet from "@ohos.util.HashSet";
describe("HashSetTest", function () {
it("SR000GGR3J_testNew001", 0, function () {
/**
* @tc.name: testConstructor001
* @tc.desc: Create an HashSet instance. For example: let hashSet = new HashSet().
* @tc.author: wangyong
*/
it("testConstructor001", 0, function () {
try {
let hashSet = new HashSet();
} catch (err) {
......@@ -24,13 +30,25 @@ describe("HashSetTest", function () {
expect(err.message).assertEqual("Cannot create new HashSet");
}
});
it("SR000GGR3J_testAdd001", 0, function () {
/**
* @tc.name: testAdd001
* @tc.desc: Add element to HashSet instance. For example: hashSet.add(1).
* @tc.author: wangyong
*/
it("testAdd001", 0, function () {
let hashSet = new HashSet();
hashSet.add(1);
let res = hashSet.has(1);
expect(res).assertEqual(true);
});
it("SR000GGR3J_testAdd002", 0, function () {
/**
* @tc.name: testAdd002
* @tc.desc: Add element to HashSet instance. For example: hashSet.add("a").
* @tc.author: wangyong
*/
it("testAdd002", 0, function () {
let hashSet = new HashSet();
hashSet.add("b");
hashSet.add("c");
......@@ -40,21 +58,39 @@ describe("HashSetTest", function () {
let res = hashSet.has("a");
expect(res).assertEqual(true);
});
it("SR000GGR3J_testAdd004", 0, function () {
/**
* @tc.name: testAdd003
* @tc.desc: Add element to HashSet instance. For example: let c = [1, 2, 3]; hashSet.add(c).
* @tc.author: wangyong
*/
it("testAdd003", 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 () {
/**
* @tc.name: testAdd004
* @tc.desc: Add element to HashSet instance. For example: let c = {name: "lili", age: "13"}; hashSet.add(c).
* @tc.author: wangyong
*/
it("testAdd004", 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 () {
/**
* @tc.name: testLength005
* @tc.desc: Get the number of element in the HashSet instance. For example: hashSet.length.
* @tc.author: wangyong
*/
it("testLength005", 0, function () {
let hashSet = new HashSet();
hashSet.add(1);
hashSet.add(2);
......@@ -64,7 +100,13 @@ describe("HashSetTest", function () {
let res = hashSet.length;
expect(res).assertEqual(5);
});
it("SR000GGR3J_testHas007", 0, function () {
/**
* @tc.name: testHas006
* @tc.desc: Determine whether the HashSet instance contains the specified element. For example: hashSet.has(1).
* @tc.author: wangyong
*/
it("testHas006", 0, function () {
let hashSet = new HashSet();
hashSet.add(4);
hashSet.add(1);
......@@ -76,7 +118,13 @@ describe("HashSetTest", function () {
let res1 = hashSet.has("A");
expect(res1).assertEqual(false);
});
it("SR000GGR3J_testIsEmpty008", 0, function () {
/**
* @tc.name: testIsEmpty007
* @tc.desc: Determine whether the HashSet instance is empty. For example: hashSet.isEmpty().
* @tc.author: wangyong
*/
it("testIsEmpty007", 0, function () {
let hashSet = new HashSet();
hashSet.add(4);
hashSet.add(1);
......@@ -86,7 +134,13 @@ describe("HashSetTest", function () {
let res = hashSet.isEmpty();
expect(res).assertEqual(false);
});
it("SR000GGR3J_testRemove009", 0, function () {
/**
* @tc.name: testRemove008
* @tc.desc: Delete the specified element. For example: hashSet.remove(1).
* @tc.author: wangyong
*/
it("testRemove008", 0, function () {
let hashSet = new HashSet();
hashSet.add(4);
hashSet.add(1);
......@@ -104,7 +158,13 @@ describe("HashSetTest", function () {
expect(has).assertEqual(true);
}
});
it("SR000GGR3J_testClear010", 0, function () {
/**
* @tc.name: testClear009
* @tc.desc: Clear all elements of the HashSet instance. For example: hashSet.clear().
* @tc.author: wangyong
*/
it("testClear009", 0, function () {
let hashSet = new HashSet();
hashSet.add(4);
hashSet.add(1);
......@@ -117,7 +177,13 @@ describe("HashSetTest", function () {
let res1 = hashSet.length;
expect(res1).assertEqual(0);
});
it("SR000GGR3J_testValues011", 0, function () {
/**
* @tc.name: testValues010
* @tc.desc: Get a collection of all elements of a HashSet instance. For example: hashSet.values().
* @tc.author: wangyong
*/
it("testValues010", 0, function () {
let hashSet = new HashSet();
hashSet.add("A");
hashSet.add("B");
......@@ -130,7 +196,13 @@ describe("HashSetTest", function () {
expect(has).assertEqual(true);
}
});
it("SR000GGR3J_testForEach012", 0, function () {
/**
* @tc.name: testForEach011
* @tc.desc: Traverse the collection of all elements of the HashSet instance.
* @tc.author: wangyong
*/
it("testForEach011", 0, function () {
let hashSet = new HashSet();
hashSet.add(1);
hashSet.add(2);
......@@ -146,7 +218,14 @@ describe("HashSetTest", function () {
expect(has).assertEqual(true);
}
});
it("SR000GGR3J_testIterator013", 0, function () {
/**
* @tc.name: testIterator012
* @tc.desc: Iterate over all elements of the HashSet instance.
* For example: for (let item of hashSet) {arr.push(item);}.
* @tc.author: wangyong
*/
it("testIterator012", 0, function () {
let hashSet = new HashSet();
hashSet.add(1);
hashSet.add(2);
......@@ -162,7 +241,14 @@ describe("HashSetTest", function () {
expect(has).assertEqual(true);
}
});
it("SR000GGR3J_testIterator014", 0, function () {
/**
* @tc.name: testIterator013
* @tc.desc: Iterate over all elements of the HashSet instance.
* For example: for (let item of hashSet) {arr.push(item);}.
* @tc.author: wangyong
*/
it("testIterator013", 0, function () {
let hashSet = new HashSet();
hashSet.add("A");
hashSet.add("B");
......@@ -178,7 +264,13 @@ describe("HashSetTest", function () {
expect(has).assertEqual(true);
}
});
it("SR000GGR3J_testEntries015", 0, function () {
/**
* @tc.name: testEntries014
* @tc.desc: Iterate over all elements of the HashSet instance. For example: hashSet.entries().
* @tc.author: wangyong
*/
it("testEntries014", 0, function () {
let hashSet = new HashSet();
hashSet.add(1);
hashSet.add(2);
......@@ -191,38 +283,74 @@ describe("HashSetTest", function () {
expect(has).assertEqual(true);
}
});
it("SR000GGR3J_testAdd016", 0, function () {
/**
* @tc.name: testAdd015
* @tc.desc: Add element to HashSet instance. For example: hashSet.add("").
* @tc.author: wangyong
*/
it("testAdd015", 0, function () {
let hashSet = new HashSet();
hashSet.add("");
let res = hashSet.has("");
expect(res).assertEqual(true);
});
it("SR000GGR3J_testAdd017", 0, function () {
/**
* @tc.name: testAdd016
* @tc.desc: Add element to HashSet instance. For example: hashSet.add("$").
* @tc.author: wangyong
*/
it("testAdd016", 0, function () {
let hashSet = new HashSet();
hashSet.add("$");
let res = hashSet.has("$");
expect(res).assertEqual(true);
});
it("SR000GGR3J_testAdd017", 0, function () {
/**
* @tc.name: testAdd017
* @tc.desc: Add element to HashSet instance. For example: hashSet.add(1.34).
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testAdd018
* @tc.desc: Add element to HashSet instance. For example: hashSet.add(-1).
* @tc.author: wangyong
*/
it("testAdd018", 0, function () {
let hashSet = new HashSet();
hashSet.add(-1);
let res = hashSet.has(-1);
expect(res).assertEqual(true);
});
it("SR000GGR3J_testAdd019", 0, function () {
/**
* @tc.name: testAdd019
* @tc.desc: Add element to HashSet instance. For example: let a = {}; hashSet.add(a).
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testAdd020
* @tc.desc: Add element to HashSet instance.
* @tc.author: wangyong
*/
it("testAdd020", 0, function () {
let hashSet = new HashSet();
for (let i = 0; i < 100; i++) {
hashSet.add(i);
......@@ -232,7 +360,13 @@ describe("HashSetTest", function () {
let res1 = hashSet.length;
expect(res1).assertEqual(100);
});
it("SR000GGR3J_testIterator021", 0, function () {
/**
* @tc.name: testIterator021
* @tc.desc: Iterate over all elements of the HashSet instance.
* @tc.author: wangyong
*/
it("testIterator021", 0, function () {
let hashSet = new HashSet();
let i = 0;
for (let item of hashSet) {
......@@ -240,7 +374,13 @@ describe("HashSetTest", function () {
i++;
}
});
it("SR000GGR3J_testForEach022", 0, function () {
/**
* @tc.name: testForEach022
* @tc.desc: Traverse the collection of all elements of the HashSet instance.
* @tc.author: wangyong
*/
it("testForEach022", 0, function () {
let hashSet = new HashSet();
let arr = [];
hashSet.forEach((value, index) => {
......@@ -248,7 +388,13 @@ describe("HashSetTest", function () {
});
expect(arr.length).assertEqual(0);
});
it("SR000GGR3J_testIsEmpty023", 0, function () {
/**
* @tc.name: testIsEmpty023
* @tc.desc: Determine whether the HashSet instance is empty. For example: hashSet.isEmpty().
* @tc.author: wangyong
*/
it("testIsEmpty023", 0, function () {
let hashSet = new HashSet();
hashSet.add(4);
hashSet.add(1);
......@@ -259,27 +405,57 @@ describe("HashSetTest", function () {
let res = hashSet.isEmpty();
expect(res).assertEqual(true);
});
it("SR000GGR3J_testHas024", 0, function () {
/**
* @tc.name:testHas024
* @tc.desc: Determine whether the HashSet instance contains the specified element. For example: hashSet.has(1).
* @tc.author: wangyong
*/
it("testHas024", 0, function () {
let hashSet = new HashSet();
let res = hashSet.has(1);
expect(res).assertEqual(false);
});
it("SR000GGR3J_testRemove025", 0, function () {
/**
* @tc.name: testConstructor001
* @tc.desc: Delete the specified element. For example: hashSet.remove(1).
* @tc.author: wangyong
*/
it("testRemove025", 0, function () {
let hashSet = new HashSet();
let res = hashSet.remove(1);
expect(res).assertEqual(false);
});
it("SR000GGR3J_testClear026", 0, function () {
/**
* @tc.name: testClear026
* @tc.desc: Clear all elements of the HashSet instance. For example: hashSet.clear().
* @tc.author: wangyong
*/
it("testClear026", 0, function () {
let hashSet = new HashSet();
let res = hashSet.clear();
expect(res).assertEqual(undefined);
});
it("SR000GGR3J_testEntries027", 0, function () {
/**
* @tc.name: testEntries027
* @tc.desc: Iterate over all elements of the HashSet instance. For example: hashSet.entries().
* @tc.author: wangyong
*/
it("testEntries027", 0, function () {
let hashSet = new HashSet();
let res = hashSet.entries();
expect(res.next().value).assertEqual(undefined);
});
it("SR000GGR3J_testIterator028", 0, function () {
/**
* @tc.name: testIterator028
* @tc.desc: Iterate over all elements of the HashSet instance.
* @tc.author: wangyong
*/
it("testIterator028", 0, function () {
let hashSet = new HashSet();
for (let i = 0; i < 100; i++) {
let text = hashSet.add(i);
......@@ -294,7 +470,13 @@ describe("HashSetTest", function () {
expect(res).assertEqual(true);
}
});
it("SR000GGR3J_testForEach029", 0, function () {
/**
* @tc.name: testForEach029
* @tc.desc: Traverse the collection of all elements of the HashSet instance.
* @tc.author: wangyong
*/
it("testForEach029", 0, function () {
let hashSet = new HashSet();
for (let i = 0; i < 100; i++) {
hashSet.add(i);
......@@ -309,7 +491,13 @@ describe("HashSetTest", function () {
expect(res).assertEqual(true);
}
});
it("SR000GGR3J_testAdd030", 0, function () {
/**
* @tc.name: testAdd030
* @tc.desc: Add element to HashSet instance. For example: hashSet.add(1).
* @tc.author: wangyong
*/
it("testAdd030", 0, function () {
let hashSet = new HashSet();
hashSet.add(1);
hashSet.add(1);
......@@ -318,7 +506,13 @@ describe("HashSetTest", function () {
expect(has).assertEqual(true);
expect(size).assertEqual(1);
});
it("SR000GGR3J_testIterator031", 0, function () {
/**
* @tc.name: testIterator031
* @tc.desc: Iterate over all elements of the HashSet instance. For example: hashSet[Symbol.iterator]().
* @tc.author: wangyong
*/
it("testIterator031", 0, function () {
let hashSet = new HashSet();
hashSet.add(1);
hashSet.add(2);
......
......@@ -16,7 +16,13 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
import LightWeightMap from "@ohos.util.LightWeightMap";
describe("LightWeightMapTest", function () {
it("SR00GGR3L_testConstructor001", 0, function () {
/**
* @tc.name: testConstructor001
* @tc.desc: Create an LightWeightMap instance. For example: let lightWeightMap = new LightWeightMap().
* @tc.author: wangyong
*/
it("testConstructor001", 0, function () {
try {
let lightWeightMap = new LightWeightMap();
expect(lightWeightMap != undefined).assertEqual(true);
......@@ -25,7 +31,13 @@ describe("LightWeightMapTest", function () {
expect(err.message).assertEqual("Cannot create new TreeMap");
}
});
it("SR00GGR3L_testSet002", 0, function () {
/**
* @tc.name: testSet002
* @tc.desc: Add a pair of key value pairs to the LightWeightMap. For example: lightWeightMap.set(1, "A").
* @tc.author: wangyong
*/
it("testSet002", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
let res = lightWeightMap.hasValue("A");
......@@ -33,7 +45,13 @@ describe("LightWeightMapTest", function () {
let res1 = lightWeightMap.hasKey(1);
expect(res1).assertEqual(true);
});
it("SR00GGR3L_testSet003", 0, function () {
/**
* @tc.name: testSet003
* @tc.desc: Add a pair of key value pairs to the LightWeightMap. For example: lightWeightMap.set("a", "A").
* @tc.author: wangyong
*/
it("testSet003", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("a", "A");
let res = lightWeightMap.hasValue("A");
......@@ -41,7 +59,13 @@ describe("LightWeightMapTest", function () {
let res1 = lightWeightMap.hasKey("a");
expect(res1).assertEqual(true);
});
it("SR00GGR3L_testSet004", 0, function () {
/**
* @tc.name: testSet004
* @tc.desc: Add a pair of key value pairs to the LightWeightMap. For example: lightWeightMap.set("a", "A").
* @tc.author: wangyong
*/
it("testSet004", 0, function () {
let lightWeightMap = new LightWeightMap();
let a = [1, 2, 3, 4];
lightWeightMap.set(1, a);
......@@ -50,7 +74,13 @@ describe("LightWeightMapTest", function () {
let res1 = lightWeightMap.hasKey(1);
expect(res1).assertEqual(true);
});
it("SR00GGR3L_testSet005", 0, function () {
/**
* @tc.name: testSet005
* @tc.desc: Add a pair of key value pairs to the LightWeightMap.
* @tc.author: wangyong
*/
it("testSet005", 0, function () {
let lightWeightMap = new LightWeightMap();
let c = {name: "lili", age: "13"};
lightWeightMap.set(1, c);
......@@ -59,7 +89,13 @@ describe("LightWeightMapTest", function () {
let res1 = lightWeightMap.hasKey(1);
expect(res1).assertEqual(true);
});
it("SR00GGR3L_testGet006", 0, function () {
/**
* @tc.name: testGet006
* @tc.desc: Get the corresponding value through the key. For example: lightWeightMap.get(4).
* @tc.author: wangyong
*/
it("testGet006", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
......@@ -69,7 +105,13 @@ describe("LightWeightMapTest", function () {
let res = lightWeightMap.get(4);
expect(res).assertEqual("D");
});
it("SR00GGR3L_testLength007", 0, function () {
/**
* @tc.name: testLength007
* @tc.desc: Get the number of key value pairs in the lightWeightMap instance. For example: lightWeightMap.length.
* @tc.author: wangyong
*/
it("testLength007", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
......@@ -79,7 +121,13 @@ describe("LightWeightMapTest", function () {
let res = lightWeightMap.length;
expect(res).assertEqual(5);
});
it("SR00GGR3L_testHasAll008", 0, function () {
/**
* @tc.name: testHasAll008
* @tc.desc: Judge whether a lightweightmap contains all key value pairs in another lightweightmap.
* @tc.author: wangyong
*/
it("testHasAll008", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("a", "A");
lightWeightMap.set("b", "B");
......@@ -92,7 +140,13 @@ describe("LightWeightMapTest", function () {
let res = lightWeightMap.hasAll(lightWeightMap1);
expect(res).assertEqual(true);
});
it("SR00GGR3L_testHasKey009", 0, function () {
/**
* @tc.name: testConstructor001
* @tc.desc: Determine whether the LightWeightMap contains the specified key. For example: lightWeightMap.hasKey("a").
* @tc.author: wangyong
*/
it("testHasKey009", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("a", "A");
lightWeightMap.set("b", "B");
......@@ -104,7 +158,14 @@ describe("LightWeightMapTest", function () {
let res1 = lightWeightMap.hasKey(1);
expect(res1).assertEqual(false);
});
it("SR00GGR3L_testHasValue010", 0, function () {
/**
* @tc.name: testHasValue010
* @tc.desc: Determine whether the LightWeightMap contains the specified value.
* For example: lightWeightMap.hasValue("A").
* @tc.author: wangyong
*/
it("testHasValue010", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("a", "A");
lightWeightMap.set("b", "B");
......@@ -116,7 +177,14 @@ describe("LightWeightMapTest", function () {
let res1 = lightWeightMap.hasValue(1);
expect(res1).assertEqual(false);
});
it("SR00GGR3L_testIncreaseCapacityTo011", 0, function () {
/**
* @tc.name: testIncreaseCapacityTo011
* @tc.desc: Expand the LightWeightMap instance capacity to the specified value.
* For example: lightWeightMap.increaseCapacityTo(3).
* @tc.author: wangyong
*/
it("testIncreaseCapacityTo011", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("a", "A");
lightWeightMap.set("b", "B");
......@@ -127,7 +195,13 @@ describe("LightWeightMapTest", function () {
let length = lightWeightMap.length;
expect(length).assertEqual(5);
});
it("SR00GGR3L_testEntries012", 0, function () {
/**
* @tc.name: testEntries012
* @tc.desc: Get all key value pairs collection in lightWeightMap.
* @tc.author: wangyong
*/
it("testEntries012", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
......@@ -141,7 +215,14 @@ describe("LightWeightMapTest", function () {
expect(JSON.stringify(res.next().value)).assertEqual('[4,"D"]');
expect(JSON.stringify(res.next().value)).assertEqual('[5,"E"]');
});
it("SR00GGR3L_testGetIndexOfKey013", 0, function () {
/**
* @tc.name: testGetIndexOfKey013
* @tc.desc: Find the index of the key value pair according to the corresponding key.
* If no key is specified, return -1.
* @tc.author: wangyong
*/
it("testGetIndexOfKey013", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
......@@ -151,7 +232,14 @@ describe("LightWeightMapTest", function () {
let res = lightWeightMap.getIndexOfKey(2);
expect(res).assertEqual(1);
});
it("SR00GGR3L_testGetIndexOfValue014", 0, function () {
/**
* @tc.name: testGetIndexOfValue014
* @tc.desc: Find the index of the key value pair according to the corresponding value.
* If no key is specified, return -1.
* @tc.author: wangyong
*/
it("testGetIndexOfValue014", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
......@@ -162,7 +250,13 @@ describe("LightWeightMapTest", function () {
let res = lightWeightMap.getIndexOfValue("F");
expect(res).assertEqual(4);
});
it("SR00GGR3L_testIsEmpty015", 0, function () {
/**
* @tc.name: testIsEmpty015
* @tc.desc: Determine whether the LightWeightMap instance is empty. For example: lightWeightMap.isEmpty().
* @tc.author: wangyong
*/
it("testIsEmpty015", 0, function () {
let lightWeightMap = new LightWeightMap();
let res1 = lightWeightMap.isEmpty();
expect(res1).assertEqual(true);
......@@ -174,7 +268,14 @@ describe("LightWeightMapTest", function () {
let res2 = lightWeightMap.isEmpty();
expect(res2).assertEqual(false);
});
it("SR00GGR3L_testGetKeyAt016", 0, function () {
/**
* @tc.name: testGetKeyAt016
* @tc.desc: Find the key of the key value pair according to the corresponding index.
* For example: lightWeightMap.getKeyAt(1).
* @tc.author: wangyong
*/
it("testGetKeyAt016", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
......@@ -184,7 +285,13 @@ describe("LightWeightMapTest", function () {
let res = lightWeightMap.getKeyAt(1);
expect(res).assertEqual(2);
});
it("SR00GGR3L_testKeys017", 0, function () {
/**
* @tc.name: testKeys017
* @tc.desc: Get a collection of all the keys in the LightWeightMap. For example: lightWeightMap.keys().
* @tc.author: wangyong
*/
it("testKeys017", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
......@@ -198,7 +305,13 @@ describe("LightWeightMapTest", function () {
expect(res.next().value).assertEqual(4);
expect(res.next().value).assertEqual(5);
});
it("SR00GGR3L_testSetAll018", 0, function () {
/**
* @tc.name: testSetAll018
* @tc.desc: Copy key value pairs from one LightWeightMap to another.
* @tc.author: wangyong
*/
it("testSetAll018", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
......@@ -213,7 +326,13 @@ describe("LightWeightMapTest", function () {
expect(lightWeightMap.hasKey(i)).assertEqual(true);
}
});
it("SR00GGR3L_testRemove019", 0, function () {
/**
* @tc.name: testRemove019
* @tc.desc: Delete key value pairs according to key. For example: lightWeightMap.remove(3).
* @tc.author: wangyong
*/
it("testRemove019", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
......@@ -225,7 +344,13 @@ describe("LightWeightMapTest", function () {
let res1 = lightWeightMap.hasValue("C");
expect(res1).assertEqual(false);
});
it("SR00GGR3L_testRemoveAt020", 0, function () {
/**
* @tc.name: testRemoveAt020
* @tc.desc: Delete key value pairs according to index. For example: lightWeightMap.removeAt(1).
* @tc.author: wangyong
*/
it("testRemoveAt020", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
......@@ -241,7 +366,13 @@ describe("LightWeightMapTest", function () {
let res3 = lightWeightMap.removeAt(10);
expect(res3).assertEqual(false);
});
it("SR00GGR3L_testClear021", 0, function () {
/**
* @tc.name: testClear021
* @tc.desc: Clear all key value pairs in LightWeightMap. For example: lightWeightMap.clear().
* @tc.author: wangyong
*/
it("testClear021", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
......@@ -254,7 +385,14 @@ describe("LightWeightMapTest", function () {
let isEmpty = lightWeightMap.isEmpty();
expect(isEmpty).assertEqual(true);
});
it("SR00GGR3L_testSetValueAt022", 0, function () {
/**
* @tc.name: testSetValueAt022
* @tc.desc: Modify the value of the key value pair according to the corresponding index.
* For example: setValueAt(0, "a").
* @tc.author: wangyong
*/
it("testSetValueAt022", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
......@@ -265,7 +403,13 @@ describe("LightWeightMapTest", function () {
let res = lightWeightMap.get(1);
expect(res).assertEqual("a");
});
it("SR00GGR3L_testForEach023", 0, function () {
/**
* @tc.name: testForEach023
* @tc.desc: Traverse all key value pairs in the LightWeightMap instance.
* @tc.author: wangyong
*/
it("testForEach023", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
......@@ -281,7 +425,14 @@ describe("LightWeightMapTest", function () {
expect(arr[i]).assertEqual(arr1[i]);
}
});
it("SR00GGR3L_testToString024", 0, function () {
/**
* @tc.name: testToString024
* @tc.desc: Use "," to splice the elements in the LightWeightMap instance into a string.
* For example: lightWeightMap.toString().
* @tc.author: wangyong
*/
it("testToString024", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
......@@ -289,7 +440,13 @@ describe("LightWeightMapTest", function () {
let res = lightWeightMap.toString();
expect(res).assertEqual("1:A,2:B,3:C");
});
it("SR00GGR3L_testValues025", 0, function () {
/**
* @tc.name: testValues025
* @tc.desc: Get a collection of all the values in the LightWeightMap. For example: lightWeightMap.values().
* @tc.author: wangyong
*/
it("testValues025", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
......@@ -303,7 +460,14 @@ describe("LightWeightMapTest", function () {
expect(res.next().value).assertEqual("D");
expect(res.next().value).assertEqual("E");
});
it("SR00GGR3L_testGetValueAt026", 0, function () {
/**
* @tc.name: testGetValueAt026
* @tc.desc: Get the value of the key value pair according to the corresponding index.
* For example: lightWeightMap.getValueAt(1).
* @tc.author: wangyong
*/
it("testGetValueAt026", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
......@@ -313,7 +477,13 @@ describe("LightWeightMapTest", function () {
let res = lightWeightMap.getValueAt(1);
expect(res).assertEqual("B");
});
it("SR00GGR3L_testIterator027", 0, function () {
/**
* @tc.name: testIterator027
* @tc.desc: Iterate over all key value pairs in the LightWeightMap.
* @tc.author: wangyong
*/
it("testIterator027", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
......@@ -332,7 +502,13 @@ describe("LightWeightMapTest", function () {
}
expect(flag).assertEqual(true);
});
it("SR00GGR3L_testSet028", 0, function () {
/**
* @tc.name: testSet028
* @tc.desc: Add a pair of key value pairs to the LightWeightMap. For example: lightWeightMap.set(1, null).
* @tc.author: wangyong
*/
it("testSet028", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, null);
let res = lightWeightMap.hasValue(null);
......@@ -340,7 +516,13 @@ describe("LightWeightMapTest", function () {
let res1 = lightWeightMap.hasKey(1);
expect(res1).assertEqual(true);
});
it("SR00GGR3L_testSet029", 0, function () {
/**
* @tc.name: testSet029
* @tc.desc: Add a pair of key value pairs to the LightWeightMap. For example: lightWeightMap.set(null, null).
* @tc.author: wangyong
*/
it("testSet029", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(null, null);
let res = lightWeightMap.hasValue(null);
......@@ -348,7 +530,13 @@ describe("LightWeightMapTest", function () {
let res1 = lightWeightMap.hasKey(null);
expect(res1).assertEqual(true);
});
it("SR00GGR3L_testSet030", 0, function () {
/**
* @tc.name: testSet030
* @tc.desc: Add a pair of key value pairs to the LightWeightMap. For example: lightWeightMap.set(true, false).
* @tc.author: wangyong
*/
it("testSet030", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(true, false);
let res = lightWeightMap.hasValue(false);
......@@ -356,7 +544,13 @@ describe("LightWeightMapTest", function () {
let res1 = lightWeightMap.hasKey(true);
expect(res1).assertEqual(true);
});
it("SR00GGR3L_testSet031", 0, function () {
/**
* @tc.name: testSet031
* @tc.desc: Add a pair of key value pairs to the LightWeightMap. For example: lightWeightMap.set(1.23, 321).
* @tc.author: wangyong
*/
it("testSet031", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1.23, 321);
let res = lightWeightMap.hasValue(321);
......@@ -364,7 +558,13 @@ describe("LightWeightMapTest", function () {
let res1 = lightWeightMap.hasKey(1.23);
expect(res1).assertEqual(true);
});
it("SR00GGR3L_testHasAll032", 0, function () {
/**
* @tc.name: testHasAll032
* @tc.desc: Judge whether a lightweightmap contains all key value pairs in another lightweightmap.
* @tc.author: wangyong
*/
it("testHasAll032", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("a", "A");
lightWeightMap.set("b", "B");
......@@ -377,7 +577,13 @@ describe("LightWeightMapTest", function () {
let res = lightWeightMap.hasAll(lightWeightMap1);
expect(res).assertEqual(false);
});
it("SR00GGR3L_testHasAll033", 0, function () {
/**
* @tc.name: testHasAll033
* @tc.desc: Judge whether a lightweightmap contains all key value pairs in another lightweightmap.
* @tc.author: wangyong
*/
it("testHasAll033", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("a", "A");
lightWeightMap.set("b", "B");
......@@ -390,17 +596,36 @@ describe("LightWeightMapTest", function () {
let res = lightWeightMap.hasAll(lightWeightMap1);
expect(res).assertEqual(false);
});
it("SR00GGR3L_testRemove034", 0, function () {
/**
* @tc.name: testRemove034
* @tc.desc: Delete key value pairs according to key. For example: lightWeightMap.remove(3).
* @tc.author: wangyong
*/
it("testRemove034", 0, function () {
let lightWeightMap = new LightWeightMap();
let res = lightWeightMap.remove(3);
expect(res).assertEqual(undefined);
});
it("SR00GGR3L_testRemoveAt035", 0, function () {
/**
* @tc.name: testRemoveAt035
* @tc.desc: Delete key value pairs according to index. For example: lightWeightMap.removeAt(1).
* @tc.author: wangyong
*/
it("testRemoveAt035", 0, function () {
let lightWeightMap = new LightWeightMap();
let res = lightWeightMap.removeAt(1);
expect(res).assertEqual(false);
});
it("SR00GGR3L_testIncreaseCapacityTo036", 0, function () {
/**
* @tc.name: testIncreaseCapacityTo036
* @tc.desc: Expand the LightWeightMap instance capacity to the specified value.
* For example: lightWeightMap.increaseCapacityTo(10).
* @tc.author: wangyong
*/
it("testIncreaseCapacityTo036", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("a", "A");
lightWeightMap.set("b", "B");
......@@ -410,7 +635,14 @@ describe("LightWeightMapTest", function () {
let res = lightWeightMap.increaseCapacityTo(10);
expect(res).assertEqual(undefined);
});
it("SR00GGR3L_testIncreaseCapacityTo037", 0, function () {
/**
* @tc.name: testIncreaseCapacityTo037
* @tc.desc: Expand the LightWeightMap instance capacity to the specified value.
* For example: lightWeightMap.increaseCapacityTo("qwe").
* @tc.author: wangyong
*/
it("testIncreaseCapacityTo037", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("a", "A");
lightWeightMap.set("b", "B");
......@@ -424,16 +656,29 @@ describe("LightWeightMapTest", function () {
expect(err.message).assertEqual("the size is not integer");
}
});
it("SR00GGR3L_testRemoveAt038", 0, function () {
/**
* @tc.name: testRemoveAt038
* @tc.desc: Delete key value pairs according to index. For example: lightWeightMap.removeAt("123").
* @tc.author: wangyong
*/
it("testRemoveAt038", 0, function () {
let lightWeightMap = new LightWeightMap();
try {
let res = lightWeightMap.removeAt("123");
} catch (err) {
expect(err.name).assertEqual("TypeError");
expect(err.message).assertEqual("the size is not integer");
expect(err.message).assertEqual("index is not integer");
}
});
it("SR00GGR3L_testGetValueAt039", 0, function () {
/**
* @tc.name: testGetValueAt039
* @tc.desc: Get the value of the key value pair according to the corresponding index.
* For example: lightWeightMap.getValueAt("123").
* @tc.author: wangyong
*/
it("testGetValueAt039", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
......@@ -447,7 +692,14 @@ describe("LightWeightMapTest", function () {
expect(err.message).assertEqual("the index is not integer");
}
});
it("SR00GGR3L_testGetKeyAt040", 0, function () {
/**
* @tc.name: testGetKeyAt040
* @tc.desc: Find the key of the key value pair according to the corresponding index.
* For example: lightWeightMap.getKeyAt("123").
* @tc.author: wangyong
*/
it("testGetKeyAt040", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
......@@ -461,13 +713,25 @@ describe("LightWeightMapTest", function () {
expect(err.message).assertEqual("the index is not integer");
}
});
it("SR00GGR3L_testHasAll041", 0, function () {
/**
* @tc.name: testConstructor001
* @tc.desc: Judge whether a lightweightmap contains all key value pairs in another lightweightmap.
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testSet042
* @tc.desc: Add a pair of key value pairs to the LightWeightMap.
* @tc.author: wangyong
*/
it("testSet042", 0, function () {
let lightWeightMap = new LightWeightMap();
for (let i = 0; i < 100; i++) {
lightWeightMap.set(i, "A");
......@@ -477,7 +741,13 @@ describe("LightWeightMapTest", function () {
let res1 = lightWeightMap.length;
expect(res1).assertEqual(100);
});
it("SR00GGR3L_testSet043", 0, function () {
/**
* @tc.name: testSet043
* @tc.desc: Add a pair of key value pairs to the LightWeightMap.
* @tc.author: wangyong
*/
it("testSet043", 0, function () {
let lightWeightMap = new LightWeightMap();
for (let i = 0; i < 100; i++) {
lightWeightMap.set(1, i);
......@@ -487,7 +757,13 @@ describe("LightWeightMapTest", function () {
let res1 = lightWeightMap.length;
expect(res1).assertEqual(1);
});
it("SR00GGR3L_testSet044", 0, function () {
/**
* @tc.name: testSet044
* @tc.desc: Add a pair of key value pairs to the LightWeightMap.
* @tc.author: wangyong
*/
it("testSet044", 0, function () {
let lightWeightMap = new LightWeightMap();
for (let i = 0; i < 10000; i++) {
lightWeightMap.set(i, i);
......@@ -501,7 +777,13 @@ describe("LightWeightMapTest", function () {
expect(resValue).assertEqual(true);
}
});
it("SR00GGR3L_testSet045", 0, function () {
/**
* @tc.name: testSet045
* @tc.desc: Add a pair of key value pairs to the LightWeightMap.
* @tc.author: wangyong
*/
it("testSet045", 0, function () {
let lightWeightMap = new LightWeightMap();
for (let i = 0; i < 5000; i++) {
lightWeightMap.set(i, i);
......@@ -524,7 +806,13 @@ describe("LightWeightMapTest", function () {
expect(resValue).assertEqual(true);
}
});
it("SR00GGR3L_testSet046", 0, function () {
/**
* @tc.name: testSet046
* @tc.desc: Add a pair of key value pairs to the LightWeightMap.
* @tc.author: wangyong
*/
it("testSet046", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(true, 0.001);
let res = lightWeightMap.hasValue(0.001);
......@@ -532,7 +820,13 @@ describe("LightWeightMapTest", function () {
let res1 = lightWeightMap.hasKey(true);
expect(res1).assertEqual(true);
});
it("SR00GGR3L_testSet047", 0, function () {
/**
* @tc.name: testSet047
* @tc.desc: Add a pair of key value pairs to the LightWeightMap.
* @tc.author: wangyong
*/
it("testSet047", 0, function () {
let lightWeightMap = new LightWeightMap();
let a = [1, 2, 3, 4];
lightWeightMap.set(a, 1);
......@@ -541,7 +835,13 @@ describe("LightWeightMapTest", function () {
let res1 = lightWeightMap.hasKey(a);
expect(res1).assertEqual(true);
});
it("SR00GGR3L_testSet048", 0, function () {
/**
* @tc.name: testSet048
* @tc.desc: Add a pair of key value pairs to the LightWeightMap.
* @tc.author: wangyong
*/
it("testSet048", 0, function () {
let lightWeightMap = new LightWeightMap();
let a = {abc: 1};
lightWeightMap.set(a, "");
......@@ -550,7 +850,13 @@ describe("LightWeightMapTest", function () {
let res1 = lightWeightMap.hasKey(a);
expect(res1).assertEqual(true);
});
it("SR00GGR3L_testGet049", 0, function () {
/**
* @tc.name: testGet049
* @tc.desc: Get the corresponding value through the key. For example: lightWeightMap.get(10).
* @tc.author: wangyong
*/
it("testGet049", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set(1, "A");
lightWeightMap.set(2, "B");
......@@ -560,7 +866,13 @@ describe("LightWeightMapTest", function () {
let res = lightWeightMap.get(10);
expect(res).assertEqual(undefined);
});
it("SR00GGR3L_testHasAll050", 0, function () {
/**
* @tc.name: testHasAll050
* @tc.desc: Judge whether a lightweightmap contains all key value pairs in another lightweightmap.
* @tc.author: wangyong
*/
it("testHasAll050", 0, function () {
let lightWeightMap = new LightWeightMap();
lightWeightMap.set("a", "A");
lightWeightMap.set("b", "B");
......
......@@ -16,7 +16,13 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
import LightWeightSet from "@ohos.util.LightWeightSet";
describe("LightWeightSetTest", function () {
it("SR000GGR43_testNew001", 0, function () {
/**
* @tc.name: testConstructor001
* @tc.desc: Create an LightWeightSet instance. For example: let lightWeightSet = new LightWeightSet().
* @tc.author: wangyong
*/
it("testConstructor001", 0, function () {
try {
let lightWeightSet = new LightWeightSet();
expect(lightWeightSet != undefined).assertEqual(true);
......@@ -25,40 +31,78 @@ describe("LightWeightSetTest", function () {
expect(err.message).assertEqual("Cannot create new TreeMap");
}
});
it("SR000GGR43_testAdd002", 0, function () {
/**
* @tc.name: testAdd002
* @tc.desc: Add element to LightWeightSet instance. For example: lightWeightSet.add(1).
* @tc.author: wangyong
*/
it("testAdd002", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add(1);
let res = lightWeightSet.has(1);
expect(res).assertEqual(true);
});
it("SR000GGR43_testAdd003", 0, function () {
/**
* @tc.name: testAdd003
* @tc.desc: Add element to LightWeightSet instance. For example: lightWeightSet.add("a").
* @tc.author: wangyong
*/
it("testAdd003", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add("a");
let res = lightWeightSet.has("a");
expect(res).assertEqual(true);
});
it("SR000GGR43_testAdd004", 0, function () {
/**
* @tc.name: testAdd004
* @tc.desc: Add element to LightWeightSet instance.
* For example: let a = [1, 2, 3, 4]; lightWeightSet.add(a).
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testAdd005
* @tc.desc: Add element to LightWeightSet instance.
* For example: let a = {name: "lili", age: "13"}; lightWeightSet.add(a).
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testAdd006
* @tc.desc: Add element to LightWeightSet instance. For example: let c = false; lightWeightSet.add(c).
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testLength007
* @tc.desc: Get the number of element in the LightWeightSet instance. For example: lightWeightSet.length.
* @tc.author: wangyong
*/
it("testLength007", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add(1);
lightWeightSet.add(2);
......@@ -68,7 +112,13 @@ describe("LightWeightSetTest", function () {
let res = lightWeightSet.length;
expect(res).assertEqual(5);
});
it("SR000GGR43_testAddAll008", 0, function () {
/**
* @tc.name: testAddAll008
* @tc.desc: Copy all element from one LightWeightSet to another.
* @tc.author: wangyong
*/
it("testAddAll008", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add(1);
lightWeightSet.add(2);
......@@ -90,7 +140,13 @@ describe("LightWeightSetTest", function () {
}
expect(res1).assertEqual(true);
});
it("SR000GGR43_testHasAll009", 0, function () {
/**
* @tc.name: testHasAll009
* @tc.desc: Judge whether a lightWeightSet contains all elements in another lightWeightSet.
* @tc.author: wangyong
*/
it("testHasAll009", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add("a");
lightWeightSet.add("b");
......@@ -103,7 +159,13 @@ describe("LightWeightSetTest", function () {
let res = lightWeightSet.hasAll(lightWeightSet1);
expect(res).assertEqual(true);
});
it("SR000GGR43_testHasAllr010", 0, function () {
/**
* @tc.name: testHasAll010
* @tc.desc: Judge whether a lightWeightSet contains all elements in another lightWeightSet.
* @tc.author: wangyong
*/
it("testHasAll010", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add("a");
lightWeightSet.add("b");
......@@ -115,7 +177,13 @@ describe("LightWeightSetTest", function () {
let res = lightWeightSet.hasAll(lightWeightSet1);
expect(res).assertEqual(false);
});
it("SR000GGR43_testHas011", 0, function () {
/**
* @tc.name: testHas011
* @tc.desc: Judge whether a lightWeightSet contains all elements in another lightWeightSet.
* @tc.author: wangyong
*/
it("testHas011", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add("a");
lightWeightSet.add("b");
......@@ -127,7 +195,13 @@ describe("LightWeightSetTest", function () {
let res1 = lightWeightSet.has(1);
expect(res1).assertEqual(false);
});
it("SR000GGR43_testEntries012", 0, function () {
/**
* @tc.name: testEntries012
* @tc.desc: Get all key value pairs collection in lightWeightSet.
* @tc.author: wangyong
*/
it("testEntries012", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add(1);
lightWeightSet.add(2);
......@@ -141,7 +215,13 @@ describe("LightWeightSetTest", function () {
expect(JSON.stringify(res.next().value)).assertEqual("[4,4]");
expect(JSON.stringify(res.next().value)).assertEqual("[5,5]");
});
it("SR000GGR43_testGetIndexOf013", 0, function () {
/**
* @tc.name: testGetIndexOf013
* @tc.desc: Get the index according to the specified element. For example: lightWeightSet.getIndexOf(2).
* @tc.author: wangyong
*/
it("testGetIndexOf013", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add(1);
lightWeightSet.add(2);
......@@ -151,7 +231,13 @@ describe("LightWeightSetTest", function () {
let res = lightWeightSet.getIndexOf(2);
expect(res).assertEqual(1);
});
it("SR000GGR43_testIsEmpty014", 0, function () {
/**
* @tc.name: testIsEmpty014
* @tc.desc: Determine whether the lightWeightSet instance is empty. For example: lightWeightSet.isEmpty().
* @tc.author: wangyong
*/
it("testIsEmpty014", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add(1);
lightWeightSet.add(2);
......@@ -161,7 +247,13 @@ describe("LightWeightSetTest", function () {
let res = lightWeightSet.isEmpty();
expect(res).assertEqual(false);
});
it("SR000GGR43_testRemove015", 0, function () {
/**
* @tc.name: testRemove015
* @tc.desc: Delete elements according to key. For example: lightWeightMap.remove(1).
* @tc.author: wangyong
*/
it("testRemove015", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add(1);
lightWeightSet.add(2);
......@@ -179,7 +271,13 @@ describe("LightWeightSetTest", function () {
expect(arr1[i]).assertEqual(arr[i]);
}
});
it("SR000GGR43_testRemoveAt016", 0, function () {
/**
* @tc.name: testRemoveAt016
* @tc.desc: Delete elements according to index. For example: lightWeightSet.removeAt(1).
* @tc.author: wangyong
*/
it("testRemoveAt016", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add(1);
lightWeightSet.add(2);
......@@ -197,7 +295,13 @@ describe("LightWeightSetTest", function () {
expect(arr1[i]).assertEqual(arr[i]);
}
});
it("SR000GGR43_testClear017", 0, function () {
/**
* @tc.name: testClear017
* @tc.desc: Clear all elements in LightWeightSet. For example: lightWeightSet.clear().
* @tc.author: wangyong
*/
it("testClear017", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add(1);
lightWeightSet.add(2);
......@@ -208,7 +312,13 @@ describe("LightWeightSetTest", function () {
let res = lightWeightSet.length;
expect(res).assertEqual(0);
});
it("SR000GGR43_testForEach018", 0, function () {
/**
* @tc.name: testForEach018
* @tc.desc: Traverse all elements in the LightWeightSet instance.
* @tc.author: wangyong
*/
it("testForEach018", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add(1);
lightWeightSet.add(2);
......@@ -224,7 +334,14 @@ describe("LightWeightSetTest", function () {
expect(arr[i]).assertEqual(arr1[i]);
}
});
it("SR000GGR43_testToString019", 0, function () {
/**
* @tc.name: testToString019
* @tc.desc: Use "," to splice the elements in the LightWeightSet instance into a string.
* For example: lightWeightSet.toString().
* @tc.author: wangyong
*/
it("testToString019", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add(1);
lightWeightSet.add(2);
......@@ -232,7 +349,13 @@ describe("LightWeightSetTest", function () {
let res = lightWeightSet.toString();
expect(res).assertEqual("1,2,3");
});
it("SR000GGR43_testToArray020", 0, function () {
/**
* @tc.name: testToArray020
* @tc.desc: Convert an lightWeightSet instance to an array. For example: lightWeightSet.toArray().
* @tc.author: wangyong
*/
it("testToArray020", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add(1);
lightWeightSet.add(2);
......@@ -245,7 +368,13 @@ describe("LightWeightSetTest", function () {
expect(res[i]).assertEqual(arr1[i]);
}
});
it("SR000GGR43_testGetValueAt021", 0, function () {
/**
* @tc.name: testGetValueAt021
* @tc.desc: Get the element according to the corresponding index. For example: lightWeightSet.getValueAt(1).
* @tc.author: wangyong
*/
it("testGetValueAt021", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add(1);
lightWeightSet.add(2);
......@@ -255,7 +384,13 @@ describe("LightWeightSetTest", function () {
let res = lightWeightSet.getValueAt(1);
expect(res).assertEqual(2);
});
it("SR000GGR43_testIterator022", 0, function () {
/**
* @tc.name: testIterator022
* @tc.desc: Iterate over all elements in the LightWeightSet.
* @tc.author: wangyong
*/
it("testIterator022", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add(1);
lightWeightSet.add(2);
......@@ -271,7 +406,13 @@ describe("LightWeightSetTest", function () {
expect(arr[i]).assertEqual(arr1[i]);
}
});
it("SR000GGR43_testValues023", 0, function () {
/**
* @tc.name: testValues023
* @tc.desc: Get a collection of all the values in the LightWeightSet. For example: lightWeightSet.values().
* @tc.author: wangyong
*/
it("testValues023", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add(1);
lightWeightSet.add(2);
......@@ -285,19 +426,37 @@ describe("LightWeightSetTest", function () {
expect(res.next().value).assertEqual(4);
expect(res.next().value).assertEqual(5);
});
it("SR000GGR43_testAdd024", 0, function () {
/**
* @tc.name: testAdd024
* @tc.desc: Add element to LightWeightSet instance. For example: lightWeightSet.add(null).
* @tc.author: wangyong
*/
it("testAdd024", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add(null);
let res = lightWeightSet.has(null);
expect(res).assertEqual(true);
});
it("SR000GGR43_testAdd025", 0, function () {
/**
* @tc.name: testAdd025
* @tc.desc: Add element to LightWeightSet instance. For example: lightWeightSet.add(1.23).
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testHasAll026
* @tc.desc: Judge whether a lightWeightSet contains all elements in another lightWeightSet.
* @tc.author: wangyong
*/
it("testHasAll026", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add(1);
lightWeightSet.add(2);
......@@ -310,7 +469,13 @@ describe("LightWeightSetTest", function () {
let res = lightWeightSet.hasAll(lightWeightSet1);
expect(res).assertEqual(false);
});
it("SR000GGR43_testHasAll027", 0, function () {
/**
* @tc.name: testHasAll027
* @tc.desc: Judge whether a lightWeightSet contains all elements in another lightWeightSet.
* @tc.author: wangyong
*/
it("testHasAll027", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add(1);
lightWeightSet.add(2);
......@@ -323,17 +488,36 @@ describe("LightWeightSetTest", function () {
let res = lightWeightSet.hasAll(lightWeightSet1);
expect(res).assertEqual(false);
});
it("SR000GGR43_testRemove028", 0, function () {
/**
* @tc.name: testRemove028
* @tc.desc: Delete elements according to key. For example: lightWeightMap.remove(3).
* @tc.author: wangyong
*/
it("testRemove028", 0, function () {
let lightWeightSet = new LightWeightSet();
let res = lightWeightSet.remove(3);
expect(res).assertEqual(undefined);
});
it("SR000GGR43_testRemoveAt029", 0, function () {
/**
* @tc.name: testRemoveAt029
* @tc.desc: Delete elements according to index. For example: lightWeightSet.removeAt(1).
* @tc.author: wangyong
*/
it("testRemoveAt029", 0, function () {
let lightWeightSet = new LightWeightSet();
let res = lightWeightSet.removeAt(1);
expect(res).assertEqual(false);
});
it("SR000GGR43_testIncreaseCapacityTo030", 0, function () {
/**
* @tc.name: testIncreaseCapacityTo030
* @tc.desc: Expand the LightWeightSet capacity to the specified value.
* For example: lightWeightSet.increaseCapacityTo(3).
* @tc.author: wangyong
*/
it("testIncreaseCapacityTo030", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add(1);
lightWeightSet.add(2);
......@@ -347,7 +531,14 @@ describe("LightWeightSetTest", function () {
expect(err.message).assertEqual("the index is not integer");
}
});
it("SR000GGR43_testIncreaseCapacityTo031", 0, function () {
/**
* @tc.name: testIncreaseCapacityTo031
* @tc.desc: Expand the LightWeightSet capacity to the specified value.
* For example: lightWeightSet.increaseCapacityTo("qwe").
* @tc.author: wangyong
*/
it("testIncreaseCapacityTo031", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add(1);
lightWeightSet.add(2);
......@@ -361,7 +552,13 @@ describe("LightWeightSetTest", function () {
expect(err.message).assertEqual("the index is not integer");
}
});
it("SR000GGR43_testRemoveAt032", 0, function () {
/**
* @tc.name: testRemoveAt032
* @tc.desc: Delete elements according to index. For example: lightWeightSet.removeAt("123").
* @tc.author: wangyong
*/
it("testRemoveAt032", 0, function () {
let lightWeightSet = new LightWeightSet();
try {
let res = lightWeightSet.removeAt("123");
......@@ -370,7 +567,14 @@ describe("LightWeightSetTest", function () {
expect(err.message).assertEqual("the index is not integer");
}
});
it("SR000GGR43_testIncreaseCapacityTo033", 0, function () {
/**
* @tc.name: testIncreaseCapacityTo033
* @tc.desc: Expand the LightWeightSet capacity to the specified value.
* For example: lightWeightSet.increaseCapacityTo(20).
* @tc.author: wangyong
*/
it("testIncreaseCapacityTo033", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add(1);
lightWeightSet.add(2);
......@@ -380,7 +584,13 @@ describe("LightWeightSetTest", function () {
let res = lightWeightSet.increaseCapacityTo(20);
expect(res).assertEqual(undefined);
});
it("SR000GGR43_testGetValueAt034", 0, function () {
/**
* @tc.name: testGetValueAt034
* @tc.desc: Get the element according to the corresponding index. For example: lightWeightSet.getValueAt("123").
* @tc.author: wangyong
*/
it("testGetValueAt034", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add(1);
lightWeightSet.add(2);
......@@ -394,7 +604,13 @@ describe("LightWeightSetTest", function () {
expect(err.message).assertEqual("the index is not integer");
}
});
it("SR000GGR43_testIsEmpty035", 0, function () {
/**
* @tc.name: testIsEmpty035
* @tc.desc: Determine whether the lightWeightSet instance is empty. For example: lightWeightSet.isEmpty().
* @tc.author: wangyong
*/
it("testIsEmpty035", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add(1);
lightWeightSet.add(2);
......@@ -405,7 +621,13 @@ describe("LightWeightSetTest", function () {
let res = lightWeightSet.isEmpty();
expect(res).assertEqual(true);
});
it("SR000GGR43_testAdd036", 0, function () {
/**
* @tc.name: testAdd036
* @tc.desc: Add element to LightWeightSet instance.
* @tc.author: wangyong
*/
it("testAdd036", 0, function () {
let lightWeightSet = new LightWeightSet();
for (let i = 0; i < 10000; i++) {
lightWeightSet.add(i);
......@@ -415,19 +637,37 @@ describe("LightWeightSetTest", function () {
expect(res).assertEqual(9999);
expect(res1).assertEqual(10000);
});
it("SR000GGR43_testAdd037", 0, function () {
/**
* @tc.name: testAdd037
* @tc.desc: Add element to LightWeightSet instance. For example: lightWeightSet.add("").
* @tc.author: wangyong
*/
it("testAdd037", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add("");
let res = lightWeightSet.has("");
expect(res).assertEqual(true);
});
it("SR000GGR43_testAdd038", 0, function () {
/**
* @tc.name: testAdd038
* @tc.desc: Add element to LightWeightSet instance. For example: lightWeightSet.add("$").
* @tc.author: wangyong
*/
it("testAdd038", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add("$");
let res = lightWeightSet.has("$");
expect(res).assertEqual(true);
});
it("SR000GGR43_testClear039", 0, function () {
/**
* @tc.name: testClear039
* @tc.desc: Clear all elements in LightWeightSet. For example: lightWeightSet.clear().
* @tc.author: wangyong
*/
it("testClear039", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add(1);
lightWeightSet.add(2);
......@@ -440,7 +680,13 @@ describe("LightWeightSetTest", function () {
expect(res).assertEqual(5);
expect(res1).assertEqual(0);
});
it("SR000GGR43_testRemove040", 0, function () {
/**
* @tc.name: testRemove040
* @tc.desc: Delete elements according to key. For example: lightWeightMap.remove("A").
* @tc.author: wangyong
*/
it("testRemove040", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add(1);
lightWeightSet.add(2);
......@@ -454,7 +700,13 @@ describe("LightWeightSetTest", function () {
expect(err.message).assertEqual("the index is not integer");
}
});
it("SR000GGR43_testIterator41", 0, function () {
/**
* @tc.name: testIterator41
* @tc.desc: Iterate over all elements in the LightWeightSet.
* @tc.author: wangyong
*/
it("testIterator41", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add(1);
lightWeightSet.add(2);
......@@ -473,7 +725,13 @@ describe("LightWeightSetTest", function () {
expect(arr[i]).assertEqual(arr1[i]);
}
});
it("SR000GGR43_testEqual42", 0, function () {
/**
* @tc.name: testEqual42
* @tc.desc: Compare lightweightmap and specified object for equality. For example: lightWeightSet.equal(obj).
* @tc.author: wangyong
*/
it("testEqual42", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add(1);
lightWeightSet.add(2);
......@@ -482,7 +740,13 @@ describe("LightWeightSetTest", function () {
let res = lightWeightSet.equal(obj);
expect(res).assertEqual(true);
});
it("SR000GGR43_testEqual43", 0, function () {
/**
* @tc.name: testEqual43
* @tc.desc: Compare lightweightmap and specified object for equality. For example: lightWeightSet.equal(obj).
* @tc.author: wangyong
*/
it("testEqual43", 0, function () {
let lightWeightSet = new LightWeightSet();
lightWeightSet.add(1);
lightWeightSet.add(2);
......
......@@ -16,7 +16,13 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
import PlainArray from "@ohos.util.PlainArray";
describe("PlainArrayTest", function () {
it("SR000GGR45_testConstructor001", 0, function () {
/**
* @tc.name: testConstructor001
* @tc.desc: Create an PlainArray instance. For example: let plainArray = new PlainArray().
* @tc.author: wangyong
*/
it("testConstructor001", 0, function () {
try {
let plainArray = new PlainArray();
} catch (err) {
......@@ -24,40 +30,76 @@ describe("PlainArrayTest", function () {
expect(err.message).assertEqual("Cannot create new PlainArray");
}
});
it("SR000GGR45_testAdd002", 0, function () {
/**
* @tc.name: testAdd002
* @tc.desc: Add a pair of key value pairs to the PlainArray. For example: plainArray.add(1, "A").
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testAdd003
* @tc.desc: Add a pair of key value pairs to the PlainArray.
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testAdd004
* @tc.desc: Add a pair of key value pairs to the PlainArray.
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testAdd005
* @tc.desc: Add a pair of key value pairs to the PlainArray.
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testAdd006
* @tc.desc: Add a pair of key value pairs to the PlainArray.
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testGet007
* @tc.desc: Get the corresponding value through the key. For example: plainArray.get(4).
* @tc.author: wangyong
*/
it("testGet007", 0, function () {
let plainArray = new PlainArray();
plainArray.add(1, "A");
plainArray.add(2, "B");
......@@ -69,7 +111,13 @@ describe("PlainArrayTest", function () {
res = plainArray.get(10);
expect(res).assertEqual(undefined);
});
it("SR000GGR45_testLength008", 0, function () {
/**
* @tc.name: testLength008
* @tc.desc: Get the number of key value pairs in the PlainArray instance. For example: plainArray.length.
* @tc.author: wangyong
*/
it("testLength008", 0, function () {
let plainArray = new PlainArray();
let res = plainArray.length;
expect(res).assertEqual(0);
......@@ -81,7 +129,13 @@ describe("PlainArrayTest", function () {
res = plainArray.length;
expect(res).assertEqual(5);
});
it("SR000GGR45_testClone009", 0, function () {
/**
* @tc.name: testClone009
* @tc.desc: Clone an PlainArray instance. For example: plainArray.clone().
* @tc.author: wangyong
*/
it("testClone009", 0, function () {
let plainArray = new PlainArray();
let clonePlainarray = plainArray.clone();
let cloneLength = clonePlainarray.length;
......@@ -101,7 +155,13 @@ describe("PlainArrayTest", function () {
expect(arr[i]).assertEqual(arr1[i]);
}
});
it("SR000GGR45_testClear010", 0, function () {
/**
* @tc.name: testClear010
* @tc.desc: Clear all key value pairs in PlainArray. For example: plainArray.clear().
* @tc.author: wangyong
*/
it("testClear010", 0, function () {
let plainArray = new PlainArray();
plainArray.add(1, "A");
plainArray.add(2, "B");
......@@ -117,7 +177,13 @@ describe("PlainArrayTest", function () {
let res2 = plainArray.length;
expect(res2).assertEqual(0);
});
it("SR000GGR45_testHas011", 0, function () {
/**
* @tc.name: testHas011
* @tc.desc: Check whether the PlainArray contains a specified element. For example: plainArray.has("a").
* @tc.author: wangyong
*/
it("testHas011", 0, function () {
let plainArray = new PlainArray();
plainArray.add(1, "A");
plainArray.add(2, "B");
......@@ -129,7 +195,14 @@ describe("PlainArrayTest", function () {
let res1 = plainArray.has(1);
expect(res1).assertEqual(true);
});
it("SR000GGR45_testGetIndexOfKey012", 0, function () {
/**
* @tc.name: testGetIndexOfKey012
* @tc.desc: Find the index of the key value pair according to the corresponding key.
* If no key is specified, return -1.
* @tc.author: wangyong
*/
it("testGetIndexOfKey012", 0, function () {
let plainArray = new PlainArray();
plainArray.add(1, "A");
plainArray.add(2, "B");
......@@ -141,7 +214,14 @@ describe("PlainArrayTest", function () {
res = plainArray.getIndexOfKey(12);
expect(res).assertEqual(-1);
});
it("SR000GGR45_testGetIndexOfValue013", 0, function () {
/**
* @tc.name: testGetIndexOfValue013
* @tc.desc: Find the index of the key value pair according to the corresponding value.
* If no key is specified, return -1.
* @tc.author: wangyong
*/
it("testGetIndexOfValue013", 0, function () {
let plainArray = new PlainArray();
plainArray.add(1, "A");
plainArray.add(2, "B");
......@@ -153,7 +233,13 @@ describe("PlainArrayTest", function () {
res = plainArray.getIndexOfValue("Z");
expect(res).assertEqual(-1);
});
it("SR000GGR45_testIsEmpty014", 0, function () {
/**
* @tc.name: testIsEmpty014
* @tc.desc: Determine whether the PlainArray instance is empty. For example: plainArray.isEmpty().
* @tc.author: wangyong
*/
it("testIsEmpty014", 0, function () {
let plainArray = new PlainArray();
let result = plainArray.length;
expect(result).assertEqual(0);
......@@ -165,7 +251,14 @@ describe("PlainArrayTest", function () {
let res = plainArray.isEmpty();
expect(res).assertEqual(false);
});
it("SR000GGR45_testGetKeyAt015", 0, function () {
/**
* @tc.name: testGetKeyAt015
* @tc.desc: Find the key of the key value pair according to the corresponding index.
* For example: plainArray.getKeyAt(2).
* @tc.author: wangyong
*/
it("testGetKeyAt015", 0, function () {
let plainArray = new PlainArray();
plainArray.add(1, "A");
plainArray.add(2, "B");
......@@ -177,7 +270,13 @@ describe("PlainArrayTest", function () {
res = plainArray.getKeyAt(10);
expect(res).assertEqual(undefined);
});
it("SR000GGR45_testReMove016", 0, function () {
/**
* @tc.name: testReMove016
* @tc.desc: Delete key value pairs according to key. For example: plainArray.remove(2).
* @tc.author: wangyong
*/
it("testReMove016", 0, function () {
let plainArray = new PlainArray();
plainArray.add(1, "A");
plainArray.add(2, "B");
......@@ -191,7 +290,13 @@ describe("PlainArrayTest", function () {
res = plainArray.remove(12);
expect(res).assertEqual(undefined);
});
it("SR000GGR45_testReMoveAt017", 0, function () {
/**
* @tc.name: testReMoveAt017
* @tc.desc: Delete key value pairs according to index. For example: plainArray.removeAt(2).
* @tc.author: wangyong
*/
it("testReMoveAt017", 0, function () {
let plainArray = new PlainArray();
plainArray.add(1, "A");
plainArray.add(2, "B");
......@@ -205,7 +310,14 @@ describe("PlainArrayTest", function () {
res = plainArray.removeAt(12);
expect(res).assertEqual(undefined);
});
it("SR000GGR45_testReMoveRangeFrom018", 0, function () {
/**
* @tc.name: testReMoveRangeFrom018
* @tc.desc: Deletes the specified number of elements from the specified starting index.
* For example: plainArray.removeRangeFrom(2, 2).
* @tc.author: wangyong
*/
it("testReMoveRangeFrom018", 0, function () {
let plainArray = new PlainArray();
plainArray.add(1, "A");
plainArray.add(2, "B");
......@@ -231,7 +343,14 @@ describe("PlainArrayTest", function () {
expect(err.message).assertEqual("the size cannot be less than 0");
}
});
it("SR000GGR45_testSetValueAt019", 0, function () {
/**
* @tc.name: testSetValueAt019
* @tc.desc: Modify the value of the key value pair according to the corresponding index.
* For example: plainArray.setValueAt(2, "V").
* @tc.author: wangyong
*/
it("testSetValueAt019", 0, function () {
let plainArray = new PlainArray();
plainArray.add(1, "A");
plainArray.add(2, "B");
......@@ -251,7 +370,14 @@ describe("PlainArrayTest", function () {
expect(err.message).assertEqual("the index is out-of-bounds");
}
});
it("SR000GGR45_testToString020", 0, function () {
/**
* @tc.name: testToString020
* @tc.desc: Use "," to splice the elements in the LightWeightMap instance into a string.
* For example: plainArray.toString().
* @tc.author: wangyong
*/
it("testToString020", 0, function () {
let plainArray = new PlainArray();
let res1 = plainArray.toString();
expect(res1).assertEqual("");
......@@ -261,7 +387,13 @@ describe("PlainArrayTest", function () {
let res = plainArray.toString();
expect(res).assertEqual("1:A,2:B,3:C");
});
it("SR000GGR45_testForEach021", 0, function () {
/**
* @tc.name: testForEach021
* @tc.desc: Traverse all key value pairs in the PlainArray instance.
* @tc.author: wangyong
*/
it("testForEach021", 0, function () {
let plainArray = new PlainArray();
plainArray.add(1, "A");
plainArray.add(2, "B");
......@@ -277,7 +409,13 @@ describe("PlainArrayTest", function () {
expect(arr[i]).assertEqual(arr1[i]);
}
});
it("SR000GGR45_testIterator022", 0, function () {
/**
* @tc.name: testIterator022
* @tc.desc: Iterate over all key value pairs in the PlainArray.
* @tc.author: wangyong
*/
it("testIterator022", 0, function () {
let plainArray = new PlainArray();
plainArray.add(1, "A");
plainArray.add(2, "B");
......@@ -290,7 +428,14 @@ describe("PlainArrayTest", function () {
expect(values[i]).assertEqual(plainArray.get(keys[i]));
}
});
it("SR000GGR45_testGetValueAt023", 0, function () {
/**
* @tc.name: testGetValueAt023
* @tc.desc: Get the value of the key value pair according to the corresponding index.
* For example: plainArray.getValueAt(2).
* @tc.author: wangyong
*/
it("testGetValueAt023", 0, function () {
let plainArray = new PlainArray();
plainArray.add(1, "A");
plainArray.add(2, "B");
......@@ -302,19 +447,37 @@ describe("PlainArrayTest", function () {
res = plainArray.getValueAt(12);
expect(res).assertEqual(undefined);
});
it("SR000GGR45_testAdd024", 0, function () {
/**
* @tc.name: testAdd024
* @tc.desc: Add a pair of key value pairs to the PlainArray.For example: plainArray.add(1, 3.1).
* @tc.author: wangyong
*/
it("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 () {
/**
* @tc.name: testAdd025
* @tc.desc: Add a pair of key value pairs to the PlainArray.For example: plainArray.add(1, null).
* @tc.author: wangyong
*/
it("testAdd025", 0, function () {
let plainArray = new PlainArray();
plainArray.add(1, null);
let res = plainArray.get(1);
expect(res).assertEqual(null);
});
it("SR000GGR45_testAdd025", 0, function () {
/**
* @tc.name: testAdd026
* @tc.desc: Add a pair of key value pairs to the PlainArray.For example: plainArray.add("123", null).
* @tc.author: wangyong
*/
it("testAdd026", 0, function () {
let plainArray = new PlainArray();
try {
let res = plainArray.add("123", null);
......@@ -323,7 +486,13 @@ describe("PlainArrayTest", function () {
expect(err.message).assertEqual("the index is not integer");
}
});
it("SR000GGR45_testGet026", 0, function () {
/**
* @tc.name: testGet027
* @tc.desc: Get the corresponding value through the key. For example: plainArray.get(8).
* @tc.author: wangyong
*/
it("testGet027", 0, function () {
let plainArray = new PlainArray();
plainArray.add(1, "A");
plainArray.add(2, "B");
......@@ -333,7 +502,14 @@ describe("PlainArrayTest", function () {
let res = plainArray.get(8);
expect(res).assertEqual(undefined);
});
it("SR000GGR45_testGetIndexOfKey027", 0, function () {
/**
* @tc.name: testGetIndexOfKey028
* @tc.desc: Find the index of the key value pair according to the corresponding key.
* If no key is specified, return -1.
* @tc.author: wangyong
*/
it("testGetIndexOfKey028", 0, function () {
let plainArray = new PlainArray();
plainArray.add(1, "A");
plainArray.add(2, "B");
......@@ -343,7 +519,14 @@ describe("PlainArrayTest", function () {
let res = plainArray.getIndexOfKey(9);
expect(res).assertEqual(-1);
});
it("SR000GGR45_testGetIndexOfValue028", 0, function () {
/**
* @tc.name: testGetIndexOfValue029
* @tc.desc: Find the index of the key value pair according to the corresponding value.
* If no key is specified, return -1.
* @tc.author: wangyong
*/
it("testGetIndexOfValue029", 0, function () {
let plainArray = new PlainArray();
plainArray.add(1, "A");
plainArray.add(2, "B");
......@@ -353,7 +536,14 @@ describe("PlainArrayTest", function () {
let res = plainArray.getIndexOfValue("Asad");
expect(res).assertEqual(-1);
});
it("SR000GGR45_testGetKeyAt029", 0, function () {
/**
* @tc.name: testGetKeyAt030
* @tc.desc: Find the key of the key value pair according to the corresponding index.
* For example: plainArray.getKeyAt(50).
* @tc.author: wangyong
*/
it("testGetKeyAt030", 0, function () {
let plainArray = new PlainArray();
plainArray.add(1, "A");
plainArray.add(2, "B");
......@@ -363,7 +553,14 @@ describe("PlainArrayTest", function () {
let res = plainArray.getKeyAt(50);
expect(res).assertEqual(undefined);
});
it("SR000GGR45_testGetValueAt030", 0, function () {
/**
* @tc.name: testGetValueAt031
* @tc.desc: Find the value of the key value pair according to the corresponding index.
* For example: plainArray.getValueAt(50).
* @tc.author: wangyong
*/
it("testGetValueAt031", 0, function () {
let plainArray = new PlainArray();
plainArray.add(1, "A");
plainArray.add(2, "B");
......@@ -373,12 +570,24 @@ describe("PlainArrayTest", function () {
let res = plainArray.getValueAt(50);
expect(res).assertEqual(undefined);
});
it("SR000GGR45_testRemove031", 0, function () {
/**
* @tc.name: testRemove032
* @tc.desc: Delete key value pairs according to key. For example: plainArray.remove(2).
* @tc.author: wangyong
*/
it("testRemove032", 0, function () {
let plainArray = new PlainArray();
let res = plainArray.remove(2);
expect(res).assertEqual(undefined);
});
it("SR000GGR45_testRemoveAt032", 0, function () {
/**
* @tc.name: testRemoveAt033
* @tc.desc: Delete key value pairs according to index. For example: plainArray.removeAt(2).
* @tc.author: wangyong
*/
it("testRemoveAt033", 0, function () {
let plainArray = new PlainArray();
try {
let res = plainArray.removeAt(2);
......@@ -387,7 +596,14 @@ describe("PlainArrayTest", function () {
expect(err.message).assertEqual("the index is out-of-bounds");
}
});
it("SR000GGR45_testReMoveRangeFrom033", 0, function () {
/**
* @tc.name: testReMoveRangeFrom034
* @tc.desc: Deletes the specified number of elements from the specified starting index.
* For example: plainArray.removeRangeFrom(0, 5).
* @tc.author: wangyong
*/
it("testReMoveRangeFrom034", 0, function () {
let plainArray = new PlainArray();
plainArray.add(1, "A");
plainArray.add(2, "B");
......@@ -398,7 +614,14 @@ describe("PlainArrayTest", function () {
let res = plainArray.length;
expect(res).assertEqual(0);
});
it("SR000GGR45_testSetValueAt034", 0, function () {
/**
* @tc.name: testSetValueAt035
* @tc.desc: Modify the value of the key value pair according to the corresponding index.
* For example: plainArray.setValueAt(8, "V").
* @tc.author: wangyong
*/
it("testSetValueAt035", 0, function () {
let plainArray = new PlainArray();
plainArray.add(1, "A");
plainArray.add(2, "B");
......@@ -412,7 +635,13 @@ describe("PlainArrayTest", function () {
expect(err.message).assertEqual("the index is out-of-bounds");
}
});
it("SR000GGR45_testAdd035", 0, function () {
/**
* @tc.name: testAdd036
* @tc.desc: Add a pair of key value pairs to the PlainArray.
* @tc.author: wangyong
*/
it("testAdd036", 0, function () {
let plainArray = new PlainArray();
for (let i = 0; i < 100; i++) {
plainArray.add(i, i + 1);
......@@ -422,7 +651,13 @@ describe("PlainArrayTest", function () {
expect(res).assertEqual(2);
expect(res1).assertEqual(100);
});
it("SR000GGR45_testAdd036", 0, function () {
/**
* @tc.name: testAdd037
* @tc.desc: Add a pair of key value pairs to the PlainArray.
* @tc.author: wangyong
*/
it("testAdd037", 0, function () {
let plainArray = new PlainArray();
for (let i = 0; i < 1000; i++) {
plainArray.add(i, i + 1);
......@@ -432,7 +667,13 @@ describe("PlainArrayTest", function () {
expect(res).assertEqual(100);
expect(res1).assertEqual(1000);
});
it("SR000GGR45_testAdd037", 0, function () {
/**
* @tc.name: testAdd038
* @tc.desc: Add a pair of key value pairs to the PlainArray.
* @tc.author: wangyong
*/
it("testAdd038", 0, function () {
let plainArray = new PlainArray();
plainArray.add(3, "a");
plainArray.add(1, "b");
......@@ -442,7 +683,13 @@ describe("PlainArrayTest", function () {
let res = plainArray.get(2);
expect(res).assertEqual("c");
});
it("SR000GGR45_testAdd038", 0, function () {
/**
* @tc.name: testAdd039
* @tc.desc: Add a pair of key value pairs to the PlainArray.
* @tc.author: wangyong
*/
it("testAdd039", 0, function () {
let plainArray = new PlainArray();
plainArray.add(1, "ABCd");
plainArray.add(2, "~!@#$^&*()_+-*/=.?<>:;|{}[]");
......@@ -457,7 +704,13 @@ describe("PlainArrayTest", function () {
let res = plainArray.get(2);
expect(res).assertEqual("~!@#$^&*()_+-*/=.?<>:;|{}[]");
});
it("SR000GGR45_testAdd039", 0, function () {
/**
* @tc.name: testAdd040
* @tc.desc: Add a pair of key value pairs to the PlainArray.
* @tc.author: wangyong
*/
it("testAdd040", 0, function () {
let plainArray = new PlainArray();
plainArray.add(-2, "b");
try {
......@@ -469,7 +722,13 @@ describe("PlainArrayTest", function () {
let res = plainArray.get(-2);
expect(res).assertEqual("b");
});
it("SR000GGR45_testAdd040", 0, function () {
/**
* @tc.name: testAdd041
* @tc.desc: Add a pair of key value pairs to the PlainArray.
* @tc.author: wangyong
*/
it("testAdd041", 0, function () {
let plainArray = new PlainArray();
plainArray.add(1, 1);
plainArray.add(2, "b");
......@@ -481,7 +740,13 @@ describe("PlainArrayTest", function () {
let res = plainArray.get(2);
expect(res).assertEqual("b");
});
it("SR000GGR45_testIterator041", 0, function () {
/**
* @tc.name: testIterator042
* @tc.desc: Iterate over all key value pairs in the PlainArray.
* @tc.author: wangyong
*/
it("testIterator042", 0, function () {
let plainArray = new PlainArray();
plainArray.add(1, "A");
plainArray.add(2, "B");
......@@ -500,7 +765,13 @@ describe("PlainArrayTest", function () {
}
expect(flag).assertEqual(true);
});
it("SR000GGR45_testAdd042", 0, function () {
/**
* @tc.name: testAdd043
* @tc.desc: Add a pair of key value pairs to the PlainArray. For example: plainArray.add(1.23, "a").
* @tc.author: wangyong
*/
it("testAdd043", 0, function () {
let plainArray = new PlainArray();
plainArray.add(-2, "b");
try {
......
......@@ -16,7 +16,13 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
import TreeMap from "@ohos.util.TreeMap";
describe("TreeMapTest", function () {
it("SR000GGR3H_testConstructor001", 0, function () {
/**
* @tc.name: testConstructor001
* @tc.desc: Create an TreeMap instance. For example: let treeMap = new TreeMap().
* @tc.author: wangyong
*/
it("testConstructor001", 0, function () {
try {
let treeMap = new TreeMap();
expect(treeMap != undefined).assertEqual(true);
......@@ -25,63 +31,123 @@ describe("TreeMapTest", function () {
expect(err.message).assertEqual("Cannot create new TreeMap");
}
});
it("SR000GGR3H_testSet002", 0, function () {
/**
* @tc.name: testSet002
* @tc.desc: Add a pair of key value pairs to the TreeMap. For example: treeMap.set(0, "四").
* @tc.author: wangyong
*/
it("testSet002", 0, function () {
let treeMap = new TreeMap();
treeMap.set(0, "");
let res = treeMap.get(0);
expect(res).assertEqual("");
});
it("SR000GGR3H_testSet003", 0, function () {
/**
* @tc.name: testSet003
* @tc.desc: Add a pair of key value pairs to the TreeMap. For example: treeMap.set(0, 8).
* @tc.author: wangyong
*/
it("testSet003", 0, function () {
let treeMap = new TreeMap();
treeMap.set(0, 8);
let res = treeMap.get(0);
expect(res).assertEqual(8);
});
it("SR000GGR3H_testSet004", 0, function () {
/**
* @tc.name: testSet004
* @tc.desc: Add a pair of key value pairs to the TreeMap.
* @tc.author: wangyong
*/
it("testSet004", 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_testSet005", 0, function () {
/**
* @tc.name: testSet005
* @tc.desc: Add a pair of key value pairs to the TreeMap.
* @tc.author: wangyong
*/
it("testSet005", 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_testSet006", 0, function () {
/**
* @tc.name: testSet006
* @tc.desc: Add a pair of key value pairs to the TreeMap. For example: treeMap.set(2, "*").
* @tc.author: wangyong
*/
it("testSet006", 0, function () {
let treeMap = new TreeMap();
treeMap.set(2, "*");
let res = treeMap.get(2);
expect(res).assertEqual("*");
});
it("SR000GGR3H_testSet007", 0, function () {
/**
* @tc.name: testSet007
* @tc.desc: Add a pair of key value pairs to the TreeMap. For example: treeMap.set(-2, 3.14).
* @tc.author: wangyong
*/
it("testSet007", 0, function () {
let treeMap = new TreeMap();
treeMap.set(-2, 3.14);
let res = treeMap.get(-2);
expect(res).assertEqual(3.14);
});
it("SR000GGR3H_testSet008", 0, function () {
/**
* @tc.name: testSet008
* @tc.desc: Add a pair of key value pairs to the TreeMap. For example: treeMap.set(100, true).
* @tc.author: wangyong
*/
it("testSet008", 0, function () {
let treeMap = new TreeMap();
treeMap.set(100, true);
let res = treeMap.get(100);
expect(res).assertEqual(true);
});
it("SR000GGR3H_testSet009", 0, function () {
/**
* @tc.name: testSet009
* @tc.desc: Add a pair of key value pairs to the TreeMap. For example: treeMap.set(100, true).
* @tc.author: wangyong
*/
it("testSet009", 0, function () {
let treeMap = new TreeMap();
treeMap.set(100, "");
let res = treeMap.get(100);
expect(res).assertEqual("");
});
it("SR000GGR3H_testSet010", 0, function () {
/**
* @tc.name: testSet010
* @tc.desc: Add a pair of key value pairs to the TreeMap. For example: treeMap.set("a", "四").
* @tc.author: wangyong
*/
it("testSet010", 0, function () {
let treeMap = new TreeMap();
treeMap.set("a", "");
let res = treeMap.get("a");
expect(res).assertEqual("");
});
it("SR000GGR3H_testSet011", 0, function () {
/**
* @tc.name: testSet011
* @tc.desc: Add a pair of key value pairs to the TreeMap.
* @tc.author: wangyong
*/
it("testSet011", 0, function () {
let treeMap = new TreeMap();
for (let i = 0; i < 10000; i++) {
treeMap.set(0, 8);
......@@ -90,7 +156,13 @@ describe("TreeMapTest", function () {
expect(res).assertEqual(8);
expect(treeMap.length).assertEqual(1);
});
it("SR000GGR3H_testHasKey012", 0, function () {
/**
* @tc.name: testHasKey012
* @tc.desc: Determine whether the TreeMap contains the specified key. For example: treeMap.hasKey(1).
* @tc.author: wangyong
*/
it("testHasKey012", 0, function () {
let treeMap = new TreeMap();
treeMap.set(0, "a");
treeMap.set(1, "b");
......@@ -99,7 +171,13 @@ describe("TreeMapTest", function () {
let res1 = treeMap.hasKey(6);
expect(res1).assertEqual(false);
});
it("SR000GGR3H_testHasValue013", 0, function () {
/**
* @tc.name: testHasValue013
* @tc.desc: Determine whether the TreeMap contains the specified Value. For example: treeMap.hasValue("a").
* @tc.author: wangyong
*/
it("testHasValue013", 0, function () {
let treeMap = new TreeMap();
treeMap.set(0, "a");
treeMap.set(1, "b");
......@@ -109,7 +187,13 @@ describe("TreeMapTest", function () {
let res1 = treeMap.hasValue("d");
expect(res1).assertEqual(false);
});
it("SR000GGR3H_testGet014", 0, function () {
/**
* @tc.name: testGet014
* @tc.desc: Get the corresponding value through the key. For example: treeMap.get(1).
* @tc.author: wangyong
*/
it("testGet014", 0, function () {
let treeMap = new TreeMap();
treeMap.set(0, "a");
treeMap.set(1, "b");
......@@ -117,12 +201,24 @@ describe("TreeMapTest", function () {
let res = treeMap.get(1);
expect(res).assertEqual("b");
});
it("SR000GGR3H_testGet015", 0, function () {
/**
* @tc.name: testGet015
* @tc.desc: Get the corresponding value through the key. For example: treeMap.get(1).
* @tc.author: wangyong
*/
it("testGet015", 0, function () {
let treeMap = new TreeMap();
let res = treeMap.get(1);
expect(res).assertEqual(undefined);
});
it("SR000GGR3H_testGet016", 0, function () {
/**
* @tc.name: testGet016
* @tc.desc: Get the corresponding value through the key. For example: treeMap.get(0).
* @tc.author: wangyong
*/
it("testGet016", 0, function () {
let treeMap = new TreeMap();
treeMap.set(0, "a");
treeMap.clear();
......@@ -130,7 +226,13 @@ describe("TreeMapTest", function () {
let res = treeMap.get(0);
expect(res).assertEqual(undefined);
});
it("SR000GGR3H_testGetFirstKey017", 0, function () {
/**
* @tc.name: testGetFirstKey017
* @tc.desc: Get the key that ranks first in the TreeMap instance. For example: treeMap.getFirstKey().
* @tc.author: wangyong
*/
it("testGetFirstKey017", 0, function () {
let treeMap = new TreeMap();
treeMap.set(0, "a");
treeMap.set(1, "b");
......@@ -138,12 +240,24 @@ describe("TreeMapTest", function () {
let res = treeMap.getFirstKey();
expect(res).assertEqual(0);
});
it("SR000GGR3H_testGetFirstKey018", 0, function () {
/**
* @tc.name: testGetFirstKey018
* @tc.desc: Get the key that ranks first in the TreeMap instance. For example: treeMap.getFirstKey().
* @tc.author: wangyong
*/
it("testGetFirstKey018", 0, function () {
let treeMap = new TreeMap();
let res = treeMap.getFirstKey();
expect(res).assertEqual(undefined);
});
it("SR000GGR3H_testGetLastKey019", 0, function () {
/**
* @tc.name: testGetLastKey019
* @tc.desc: Get the last sorted key in the TreeMap instance. For example: treeMap.getLastKey().
* @tc.author: wangyong
*/
it("testGetLastKey019", 0, function () {
let treeMap = new TreeMap();
treeMap.set(0, "a");
treeMap.set(1, "b");
......@@ -151,12 +265,24 @@ describe("TreeMapTest", function () {
let res = treeMap.getLastKey();
expect(res).assertEqual(2);
});
it("SR000GGR3H_testGetLastKey020", 0, function () {
/**
* @tc.name: testGetLastKey020
* @tc.desc: Get the last sorted key in the TreeMap instance. For example: treeMap.getLastKey().
* @tc.author: wangyong
*/
it("testGetLastKey020", 0, function () {
let treeMap = new TreeMap();
let res = treeMap.getLastKey();
expect(res).assertEqual(undefined);
});
it("SR000GGR3H_testSetAll021", 0, function () {
/**
* @tc.name: testSetAll021
* @tc.desc: Copy key value pairs from one HashMap to another. For example: treeMap.setAll(treeMap1).
* @tc.author: wangyong
*/
it("testSetAll021", 0, function () {
let treeMap = new TreeMap();
treeMap.set(0, "a");
treeMap.set(1, "b");
......@@ -172,7 +298,13 @@ describe("TreeMapTest", function () {
let res2 = treeMap.get(2);
expect(res2).assertEqual("c");
});
it("SR000GGR3H_testRemove022", 0, function () {
/**
* @tc.name: testRemove022
* @tc.desc: Delete key value pairs according to key. For example: treeMap.remove(1).
* @tc.author: wangyong
*/
it("testRemove022", 0, function () {
let treeMap = new TreeMap();
treeMap.set(0, "a");
treeMap.set(1, "b");
......@@ -180,13 +312,25 @@ describe("TreeMapTest", function () {
let res = treeMap.remove(1);
expect(res).assertEqual("b");
});
it("SR000GGR3H_testRemove023", 0, function () {
/**
* @tc.name: testRemove023
* @tc.desc: Delete key value pairs according to key. For example: treeMap.remove(1).
* @tc.author: wangyong
*/
it("testRemove023", 0, function () {
let treeMap = new TreeMap();
treeMap.set(0, "a");
let res = treeMap.remove(1);
expect(res).assertEqual(undefined);
});
it("SR000GGR3H_testClear024", 0, function () {
/**
* @tc.name: testClear024
* @tc.desc: Clear all key value pairs in TreeMap. For example: treeMap.clear().
* @tc.author: wangyong
*/
it("testClear024", 0, function () {
let treeMap = new TreeMap();
treeMap.set(0, "a");
treeMap.set(1, "b");
......@@ -195,7 +339,13 @@ describe("TreeMapTest", function () {
let res = treeMap.length;
expect(res).assertEqual(0);
});
it("SR000GGR3H_testClear025", 0, function () {
/**
* @tc.name: testClear025
* @tc.desc: Clear all key value pairs in TreeMap. For example: treeMap.clear().
* @tc.author: wangyong
*/
it("testClear025", 0, function () {
let treeMap = new TreeMap();
treeMap.set(0, "a");
treeMap.set(1, "b");
......@@ -207,7 +357,14 @@ describe("TreeMapTest", function () {
let va = treeMap.get(3);
expect(va).assertEqual("d");
});
it("SR000GGR3H_testGetLowerKey026", 0, function () {
/**
* @tc.name: testGetLowerKey026
* @tc.desc: Get a key that is a little lower than the specified key sort.
* For example: treeMap.getLowerKey(2).
* @tc.author: wangyong
*/
it("testGetLowerKey026", 0, function () {
let treeMap = new TreeMap();
treeMap.set(0, "a");
treeMap.set(1, "b");
......@@ -217,12 +374,24 @@ describe("TreeMapTest", function () {
let res = treeMap.getLowerKey(2);
expect(res).assertEqual(1);
});
it("SR000GGR3H_testGetLowerKey027", 0, function () {
/**
* @tc.name: testGetLowerKey027
* @tc.desc: Get a key that is a little lower than the specified key sort. For example: treeMap.getLowerKey(2).
* @tc.author: wangyong
*/
it("testGetLowerKey027", 0, function () {
let treeMap = new TreeMap();
let res = treeMap.getLowerKey(2);
expect(res).assertEqual(undefined);
});
it("SR000GGR3H_testGetHigherKey028", 0, function () {
/**
* @tc.name: testGetHigherKey028
* @tc.desc: Get a key that is a little higher than the specified key sort. For example: treeMap.getLowerKey(2).
* @tc.author: wangyong
*/
it("testGetHigherKey028", 0, function () {
let treeMap = new TreeMap();
treeMap.set(0, "a");
treeMap.set(1, "b");
......@@ -232,12 +401,24 @@ describe("TreeMapTest", function () {
let res = treeMap.getHigherKey(2);
expect(res).assertEqual(3);
});
it("SR000GGR3H_testGetHigherKey029", 0, function () {
/**
* @tc.name: testGetHigherKey029
* @tc.desc: Get a key that is a little higher than the specified key sort. For example: treeMap.getLowerKey(2).
* @tc.author: wangyong
*/
it("testGetHigherKey029", 0, function () {
let treeMap = new TreeMap();
let res = treeMap.getHigherKey(2);
expect(res).assertEqual(undefined);
});
it("SR000GGR3H_testKeys030", 0, function () {
/**
* @tc.name: testKeys030
* @tc.desc: Get a collection of all the keys in the TreeMap. For example: treeMap.keys().
* @tc.author: wangyong
*/
it("testKeys030", 0, function () {
let treeMap = new TreeMap();
treeMap.set(0, "a");
treeMap.set(1, "b");
......@@ -251,7 +432,13 @@ describe("TreeMapTest", function () {
expect(res.next().value).assertEqual(3);
expect(res.next().value).assertEqual(4);
});
it("SR000GGR3H_testValues031", 0, function () {
/**
* @tc.name: testValues031
* @tc.desc: Get a collection of all the values in the TreeMap. For example: treeMap.values().
* @tc.author: wangyong
*/
it("testValues031", 0, function () {
let treeMap = new TreeMap();
treeMap.set(0, "a");
treeMap.set(1, "b");
......@@ -265,7 +452,13 @@ describe("TreeMapTest", function () {
expect(res.next().value).assertEqual("d");
expect(res.next().value).assertEqual("g");
});
it("SR000GGR3H_testReplace032", 0, function () {
/**
* @tc.name: testReplace032
* @tc.desc: Modify the corresponding value according to the specified key. For example: treeMap.replace(2, "B").
* @tc.author: wangyong
*/
it("testReplace032", 0, function () {
let treeMap = new TreeMap();
treeMap.set(0, "a");
treeMap.set(1, "b");
......@@ -276,7 +469,13 @@ describe("TreeMapTest", function () {
let res1 = treeMap.get(2);
expect(res1).assertEqual("B");
});
it("SR000GGR3H_testReplace033", 0, function () {
/**
* @tc.name: testReplace033
* @tc.desc: Modify the corresponding value according to the specified key. For example: treeMap.replace(2, "B").
* @tc.author: wangyong
*/
it("testReplace033", 0, function () {
let treeMap = new TreeMap();
treeMap.set(0, "a");
let res = treeMap.replace(2, "B");
......@@ -284,7 +483,13 @@ describe("TreeMapTest", function () {
let res1 = treeMap.get(2);
expect(res1).assertEqual(undefined);
});
it("SR000GGR3H_testLength034", 0, function () {
/**
* @tc.name: testLength034
* @tc.desc: Get the number of key value pairs in the TreeMap instance. For example: treeMap.length.
* @tc.author: wangyong
*/
it("testLength034", 0, function () {
let treeMap = new TreeMap();
treeMap.set(0, "a");
treeMap.set(1, "b");
......@@ -294,12 +499,24 @@ describe("TreeMapTest", function () {
let res = treeMap.length;
expect(res).assertEqual(5);
});
it("SR000GGR3H_testLength035", 0, function () {
/**
* @tc.name: testLength035
* @tc.desc: Get the number of key value pairs in the TreeMap instance. For example: treeMap.length.
* @tc.author: wangyong
*/
it("testLength035", 0, function () {
let treeMap = new TreeMap();
let res = treeMap.length;
expect(res).assertEqual(0);
});
it("SR000GGR3H_testForEach036", 0, function () {
/**
* @tc.name: testForEach036
* @tc.desc: Traverse all key value pairs in the TreeMap instance.
* @tc.author: wangyong
*/
it("testForEach036", 0, function () {
let treeMap = new TreeMap();
treeMap.set(0, "a");
treeMap.set(1, "b");
......@@ -323,7 +540,13 @@ describe("TreeMapTest", function () {
expect(arr3[i]).assertEqual(arr2[i]);
}
});
it("SR000GGR3H_testEntries037", 0, function () {
/**
* @tc.name: testEntries037
* @tc.desc: Get all key value pairs collection in TreeMap.
* @tc.author: wangyong
*/
it("testEntries037", 0, function () {
let treeMap = new TreeMap();
treeMap.set(0, "a");
treeMap.set(1, "b");
......@@ -342,7 +565,13 @@ describe("TreeMapTest", function () {
}
expect(flag).assertEqual(true);
});
it("SR000GGR3H_testIterator038", 0, function () {
/**
* @tc.name: testIterator038
* @tc.desc: Traverse all key value pairs in the TreeMap instance.
* @tc.author: wangyong
*/
it("testIterator038", 0, function () {
let treeMap = new TreeMap();
treeMap.set(0, "a");
treeMap.set(1, "b");
......@@ -358,7 +587,13 @@ describe("TreeMapTest", function () {
expect(arr[i]).assertEqual(iterArr[i]);
}
});
it("SR000GGR3H_testIterator039", 0, function () {
/**
* @tc.name: testIterator039
* @tc.desc: Traverse all key value pairs in the TreeMap instance. For example: treeMap[Symbol.iterator]().
* @tc.author: wangyong
*/
it("testIterator039", 0, function () {
let treeMap = new TreeMap();
treeMap.set(0, "a");
treeMap.set(1, "b");
......@@ -377,7 +612,13 @@ describe("TreeMapTest", function () {
}
expect(flag).assertEqual(true);
});
it("SR000GGR3H_testIsEmpty040", 0, function () {
/**
* @tc.name: testIsEmpty040
* @tc.desc: Determine whether the TreeMap instance is empty. For example: treeMap.isEmpty().
* @tc.author: wangyong
*/
it("testIsEmpty040", 0, function () {
let treeMap = new TreeMap();
treeMap.set(0, "a");
treeMap.set(1, "b");
......
......@@ -16,7 +16,13 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
import TreeSet from "@ohos.util.TreeSet";
describe("TreeSetTest", function () {
it("SR000GGR3I_testConstructor001", 0, function () {
/**
* @tc.name: testConstructor001
* @tc.desc: Create an TreeSet instance. For example: let treeSet = new TreeSet().
* @tc.author: wangyong
*/
it("testConstructor001", 0, function () {
try {
let treeSet = new TreeSet();
expect(treeSet != undefined).assertEqual(true);
......@@ -25,57 +31,111 @@ describe("TreeSetTest", function () {
expect(err.message).assertEqual("Cannot create new TreeSet");
}
});
it("SR000GGR3I_testAdd002", 0, function () {
/**
* @tc.name: testAdd002
* @tc.desc: Add element to TreeSet instance. For example: treeSet.add("四").
* @tc.author: wangyong
*/
it("testAdd002", 0, function () {
let treeSet = new TreeSet();
treeSet.add("");
let res = treeSet.has("");
expect(res).assertEqual(true);
});
it("SR000GGR3I_testAdd003", 0, function () {
/**
* @tc.name: testAdd003
* @tc.desc: Add element to TreeSet instance. For example: treeSet.add("四").
* @tc.author: wangyong
*/
it("testAdd003", 0, function () {
let treeSet = new TreeSet();
treeSet.add(8);
let res = treeSet.has(8);
expect(res).assertEqual(true);
});
it("SR000GGR3I_testAdd004", 0, function () {
/**
* @tc.name: testAdd004
* @tc.desc: Add element to TreeSet instance. For example: let a = [1, 2, 3, 4]; treeSet.add(a).
* @tc.author: wangyong
*/
it("testAdd004", 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_testAdd005", 0, function () {
/**
* @tc.name: testAdd005
* @tc.desc: Add element to TreeSet instance. For example: treeSet.add("*").
* @tc.author: wangyong
*/
it("testAdd005", 0, function () {
let treeSet = new TreeSet();
treeSet.add("*");
let res = treeSet.has("*");
expect(res).assertEqual(true);
});
it("SR000GGR3I_testAdd006", 0, function () {
/**
* @tc.name: testAdd006
* @tc.desc: Add element to TreeSet instance.
* @tc.author: wangyong
*/
it("testAdd006", 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_testAdd007", 0, function () {
/**
* @tc.name: testAdd007
* @tc.desc: Add element to TreeSet instance. For example: treeSet.add(1.234).
* @tc.author: wangyong
*/
it("testAdd007", 0, function () {
let treeSet = new TreeSet();
treeSet.add(1.234);
let res = treeSet.has(1.234);
expect(res).assertEqual(true);
});
it("SR000GGR3I_testAdd008", 0, function () {
/**
* @tc.name: testAdd008
* @tc.desc: Add element to TreeSet instance. For example: treeSet.add(true).
* @tc.author: wangyong
*/
it("testAdd008", 0, function () {
let treeSet = new TreeSet();
treeSet.add(true);
let res = treeSet.has(true);
expect(res).assertEqual(true);
});
it("SR000GGR3I_testAdd009", 0, function () {
/**
* @tc.name: testAdd009
* @tc.desc: Add element to TreeSet instance. For example: treeSet.add("").
* @tc.author: wangyong
*/
it("testAdd009", 0, function () {
let treeSet = new TreeSet();
treeSet.add("");
let res = treeSet.has("");
expect(res).assertEqual(true);
});
it("SR000GGR3I_testAdd010", 0, function () {
/**
* @tc.name: testAdd010
* @tc.desc: Add element to TreeSet instance.
* @tc.author: wangyong
*/
it("testAdd010", 0, function () {
let treeSet = new TreeSet();
for (let i = 0; i < 10000; i++) {
treeSet.add(i);
......@@ -84,7 +144,13 @@ describe("TreeSetTest", function () {
let res = treeSet.has(8888);
expect(res).assertEqual(true);
});
it("SR000GGR3I_testLength011", 0, function () {
/**
* @tc.name: testLength011
* @tc.desc: Get the number of element in the TreeSet instance. For example: treeSet.length.
* @tc.author: wangyong
*/
it("testLength011", 0, function () {
let treeSet = new TreeSet();
treeSet.add(0);
treeSet.add(1);
......@@ -92,12 +158,24 @@ describe("TreeSetTest", function () {
let res = treeSet.length;
expect(res).assertEqual(3);
});
it("SR000GGR3I_testLength012", 0, function () {
/**
* @tc.name: testLength012
* @tc.desc: Get the number of element in the TreeSet instance. For example: treeSet.length.
* @tc.author: wangyong
*/
it("testLength012", 0, function () {
let treeSet = new TreeSet();
let res = treeSet.length;
expect(res).assertEqual(0);
});
it("SR000GGR3I_testHas013", 0, function () {
/**
* @tc.name: testHas013
* @tc.desc: Determine whether the TreeSet instance contains the specified element. For example: treeSet.has(2).
* @tc.author: wangyong
*/
it("testHas013", 0, function () {
let treeSet = new TreeSet();
treeSet.add(0);
treeSet.add(1);
......@@ -105,7 +183,13 @@ describe("TreeSetTest", function () {
let res = treeSet.has(2);
expect(res).assertEqual(true);
});
it("SR000GGR3I_testHas014", 0, function () {
/**
* @tc.name: testHas014
* @tc.desc: Determine whether the TreeSet instance contains the specified element. For example: treeSet.has(2).
* @tc.author: wangyong
*/
it("testHas014", 0, function () {
let treeSet = new TreeSet();
treeSet.add(0);
treeSet.add(1);
......@@ -113,7 +197,13 @@ describe("TreeSetTest", function () {
let res1 = treeSet.has(3);
expect(res1).assertEqual(false);
});
it("SR000GGR3I_testGetFirstValue015", 0, function () {
/**
* @tc.name: testGetFirstValue015
* @tc.desc: Get the value that ranks first in the TreeSet instance. For example: treeSet.getFirstValue().
* @tc.author: wangyong
*/
it("testGetFirstValue015", 0, function () {
let treeSet = new TreeSet();
treeSet.add(0);
treeSet.add(1);
......@@ -123,12 +213,25 @@ describe("TreeSetTest", function () {
let res = treeSet.getFirstValue();
expect(res).assertEqual(0);
});
it("SR000GGR3I_testGetFirstValue016", 0, function () {
/**
* @tc.name: testGetFirstValue016
* @tc.desc: Get the value that ranks first in the TreeSet instance.
* For example: treeSet.getFirstValue().
* @tc.author: wangyong
*/
it("testGetFirstValue016", 0, function () {
let treeSet = new TreeSet();
let res = treeSet.getFirstValue();
expect(res).assertEqual(undefined);
});
it("SR000GGR3I_testGetLastValue017", 0, function () {
/**
* @tc.name: testGetLastValue017
* @tc.desc: Get the last sorted key in the TreeSet instance. For example: treeSet.getLastValue().
* @tc.author: wangyong
*/
it("testGetLastValue017", 0, function () {
let treeSet = new TreeSet();
treeSet.add(0);
treeSet.add(1);
......@@ -136,12 +239,25 @@ describe("TreeSetTest", function () {
let res = treeSet.getLastValue();
expect(res).assertEqual(2);
});
it("SR000GGR3I_testGetLastValue018", 0, function () {
/**
* @tc.name: testGetLastValue018
* @tc.desc: Get the last sorted key in the TreeSet instance. For example: treeSet.getLastValue().
* @tc.author: wangyong
*/
it("testGetLastValue018", 0, function () {
let treeSet = new TreeSet();
let res = treeSet.getLastValue();
expect(res).assertEqual(undefined);
});
it("SR000GGR3I_testGetLowerValue019", 0, function () {
/**
* @tc.name: testGetLowerValue019
* @tc.desc: Get a value that is a little lower than the specified value sort.
* For example: treeSet.getLowerValue(2).
* @tc.author: wangyong
*/
it("testGetLowerValue019", 0, function () {
let treeSet = new TreeSet();
treeSet.add(0);
treeSet.add(1);
......@@ -151,12 +267,26 @@ describe("TreeSetTest", function () {
let res = treeSet.getLowerValue(2);
expect(res).assertEqual(1);
});
it("SR000GGR3I_testGetLowerValue020", 0, function () {
/**
* @tc.name: testGetLowerValue020
* @tc.desc: Get a value that is a little lower than the specified value sort.
* For example: treeSet.getLowerValue(2).
* @tc.author: wangyong
*/
it("testGetLowerValue020", 0, function () {
let treeSet = new TreeSet();
let res = treeSet.getLowerValue(2);
expect(res).assertEqual(undefined);
});
it("SR000GGR3I_testGetHigherValue021", 0, function () {
/**
* @tc.name: testGetHigherValue021
* @tc.desc: Get a value that is a little higher than the specified value sort.
* For example: treeSet.getHigherValue(3).
* @tc.author: wangyong
*/
it("testGetHigherValue021", 0, function () {
let treeSet = new TreeSet();
treeSet.add(0);
treeSet.add(1);
......@@ -166,12 +296,25 @@ describe("TreeSetTest", function () {
let res = treeSet.getHigherValue(3);
expect(res).assertEqual(4);
});
it("SR000GGR3I_testGetHigherValue022", 0, function () {
/**
* @tc.name: testGetHigherValue022
* @tc.desc: Get a value that is a little higher than the specified value sort.
* For example: treeSet.getHigherValue(3).
* @tc.author: wangyong
*/
it("testGetHigherValue022", 0, function () {
let treeSet = new TreeSet();
let res = treeSet.getHigherValue(3);
expect(res).assertEqual(undefined);
});
it("SR000GGR3I_testPopFirst023", 0, function () {
/**
* @tc.name: testPopFirst023
* @tc.desc: Delete first value of sort. For example: treeSet.popFirst().
* @tc.author: wangyong
*/
it("testPopFirst023", 0, function () {
let treeSet = new TreeSet();
treeSet.add("a");
treeSet.add("b");
......@@ -181,12 +324,24 @@ describe("TreeSetTest", function () {
let res = treeSet.popFirst();
expect(res).assertEqual("a");
});
it("SR000GGR3I_testPopFirst024", 0, function () {
/**
* @tc.name: testPopFirst024
* @tc.desc: Delete first value of sort. For example: treeSet.popFirst().
* @tc.author: wangyong
*/
it("testPopFirst024", 0, function () {
let treeSet = new TreeSet();
let res = treeSet.popFirst();
expect(res).assertEqual(undefined);
});
it("SR000GGR3I_testPopLast025", 0, function () {
/**
* @tc.name: testPopLast025
* @tc.desc: Delete last value of sort. For example: treeSet.popLast().
* @tc.author: wangyong
*/
it("testPopLast025", 0, function () {
let treeSet = new TreeSet();
treeSet.add("a");
treeSet.add("b");
......@@ -196,12 +351,24 @@ describe("TreeSetTest", function () {
let res = treeSet.popLast();
expect(res).assertEqual("e");
});
it("SR000GGR3I_testPopLast026", 0, function () {
/**
* @tc.name: testPopLast026
* @tc.desc: Delete last value of sort. For example: treeSet.popLast().
* @tc.author: wangyong
*/
it("testPopLast026", 0, function () {
let treeSet = new TreeSet();
let res = treeSet.popLast();
expect(res).assertEqual(undefined);
});
it("SR000GGR3I_testClear027", 0, function () {
/**
* @tc.name: testClear027
* @tc.desc: Clear all elements of the TreeSet instance. For example: treeSet.clear().
* @tc.author: wangyong
*/
it("testClear027", 0, function () {
let treeSet = new TreeSet();
treeSet.add(0);
treeSet.add(1);
......@@ -210,7 +377,13 @@ describe("TreeSetTest", function () {
let res = treeSet.length;
expect(res).assertEqual(0);
});
it("SR000GGR3I_testClear028", 0, function () {
/**
* @tc.name: testClear028
* @tc.desc: Clear all elements of the TreeSet instance. For example: treeSet.clear().
* @tc.author: wangyong
*/
it("testClear028", 0, function () {
let treeSet = new TreeSet();
treeSet.add(0);
treeSet.add(1);
......@@ -221,18 +394,36 @@ describe("TreeSetTest", function () {
let res1 = treeSet.popFirst();
expect(res1).assertEqual(undefined);
});
it("SR000GGR3I_testIsEmpty029", 0, function () {
/**
* @tc.name: testIsEmpty029
* @tc.desc: Determine whether the TreeSet instance is empty. For example: treeSet.isEmpty().
* @tc.author: wangyong
*/
it("testIsEmpty029", 0, function () {
let treeSet = new TreeSet();
treeSet.add("a");
let res1 = treeSet.isEmpty();
expect(res1).assertEqual(false);
});
it("SR000GGR3I_testIsEmpty030", 0, function () {
/**
* @tc.name: testIsEmpty030
* @tc.desc: Determine whether the TreeSet instance is empty. For example: treeSet.isEmpty().
* @tc.author: wangyong
*/
it("testIsEmpty030", 0, function () {
let treeSet = new TreeSet();
let res2 = treeSet.isEmpty();
expect(res2).assertEqual(true);
});
it("SR000GGR3I_testRemove031", 0, function () {
/**
* @tc.name: testRemove031
* @tc.desc: Delete the specified value. For example: hashSet.remove("c").
* @tc.author: wangyong
*/
it("testRemove031", 0, function () {
let treeSet = new TreeSet();
treeSet.add("a");
treeSet.add("b");
......@@ -245,12 +436,24 @@ describe("TreeSetTest", function () {
let res2 = treeSet.has("c");
expect(res2).assertEqual(false);
});
it("SR000GGR3I_testRemove032", 0, function () {
/**
* @tc.name: testRemove032
* @tc.desc: Delete the specified value. For example: hashSet.remove("c").
* @tc.author: wangyong
*/
it("testRemove032", 0, function () {
let treeSet = new TreeSet();
let res = treeSet.remove("c");
expect(res).assertEqual(false);
});
it("SR000GGR3I_testValues033", 0, function () {
/**
* @tc.name: testValues033
* @tc.desc: Get a collection of all the values in the TreeSet. For example: treeSet.values().
* @tc.author: wangyong
*/
it("testValues033", 0, function () {
let treeSet = new TreeSet();
treeSet.add("a");
treeSet.add("b");
......@@ -264,7 +467,13 @@ describe("TreeSetTest", function () {
expect(res.next().value).assertEqual("d");
expect(res.next().value).assertEqual("g");
});
it("SR000GGR3I_testForEach034", 0, function () {
/**
* @tc.name: testForEach034
* @tc.desc: Traverse the collection of all elements of the TreeSet instance.
* @tc.author: wangyong
*/
it("testForEach034", 0, function () {
let treeSet = new TreeSet();
treeSet.add(0);
treeSet.add(1);
......@@ -280,7 +489,13 @@ describe("TreeSetTest", function () {
expect(arr[i]).assertEqual(arr1[i]);
}
});
it("SR000GGR3I_testEntries035", 0, function () {
/**
* @tc.name: testEntries035
* @tc.desc: Get all key value pairs collection in TreeMap.
* @tc.author: wangyong
*/
it("testEntries035", 0, function () {
let treeSet = new TreeSet();
treeSet.add("a");
treeSet.add("b");
......@@ -294,7 +509,14 @@ describe("TreeSetTest", function () {
expect(JSON.stringify(res.next().value)).assertEqual('["d","d"]');
expect(JSON.stringify(res.next().value)).assertEqual('["g","g"]');
});
it("SR000GGR3I_testIterator036", 0, function () {
/**
* @tc.name: testIterator036
* @tc.desc: Iterate over all elements of the TreeSet instance.
* For example: for (let item of treeSet) {arr.push(item);}
* @tc.author: wangyong
*/
it("testIterator036", 0, function () {
let treeSet = new TreeSet();
treeSet.add(0);
treeSet.add(1);
......@@ -310,7 +532,13 @@ describe("TreeSetTest", function () {
expect(arr[i]).assertEqual(arr1[i]);
}
});
it("SR000GGR3I_testIterator037", 0, function () {
/**
* @tc.name: testIterator037
* @tc.desc: Iterate over all elements of the TreeSet instance. For example: treeSet[Symbol.iterator]().
* @tc.author: wangyong
*/
it("testIterator037", 0, function () {
let treeSet = new TreeSet();
treeSet.add(0);
treeSet.add(1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册