-
Notifications
You must be signed in to change notification settings - Fork 0
/
ArrayUtilsTest.ts
48 lines (40 loc) · 1.08 KB
/
ArrayUtilsTest.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import "reflect-metadata";
import {expect} from "chai";
import {Suite} from "mocha";
import {ArrayUtils} from "../src";
let arr: number[];
before(() =>
{
arr = [1, 2, 3, 4];
});
describe('ArrayUtilsTest', function (this: Suite)
{
it("testIsLast", () =>
{
expect(ArrayUtils.isLast(arr, 4)).true;
expect(ArrayUtils.isLast(arr, 1)).false;
expect(ArrayUtils.isLast(arr, 0)).false;
});
it("testContains", () =>
{
expect(ArrayUtils.contains(arr, 4)).true;
expect(ArrayUtils.contains(arr, 2)).true;
expect(ArrayUtils.contains(arr, 2)).true;
expect(ArrayUtils.contains(arr, 5)).false;
expect(ArrayUtils.contains(arr, -5)).false;
expect(ArrayUtils.contains(arr, -6)).false;
});
it("testRemove", () =>
{
ArrayUtils.remove(arr, 2);
expect(arr[0]).equals(1);
expect(arr[1]).equals(3);
expect(arr[2]).equals(4);
expect(arr.length).equals(3);
});
it("testClear", () =>
{
ArrayUtils.clear(arr);
expect(arr.length).equals(0);
});
});