feat: the kata machine
This commit is contained in:
commit
dc0e0e0358
20 changed files with 2771 additions and 0 deletions
34
src/__tests__/array-list.ts
Normal file
34
src/__tests__/array-list.ts
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import ArrayList from "@code/array-list";
|
||||
|
||||
test("array-list", function() {
|
||||
const list = new ArrayList<number>(3);
|
||||
|
||||
list.add(5);
|
||||
list.add(7);
|
||||
list.add(9);
|
||||
|
||||
expect(list.remove()).toEqual(5);
|
||||
expect(list.length).toEqual(2);
|
||||
|
||||
list.add(11);
|
||||
expect(list.remove()).toEqual(7);
|
||||
expect(list.remove()).toEqual(9);
|
||||
expect(list.remove()).toEqual(11);
|
||||
expect(list.remove()).toEqual(undefined);
|
||||
expect(list.length).toEqual(0);
|
||||
|
||||
list.add(5);
|
||||
list.add(7);
|
||||
list.add(9);
|
||||
expect(list.length).toEqual(3);
|
||||
expect(list.removeAt(1)).toEqual(7);
|
||||
expect(list.capacity).toEqual(3);
|
||||
|
||||
list.add(11);
|
||||
list.add(13);
|
||||
expect(list.length).toEqual(5);
|
||||
expect(list.capacity).toEqual(6);
|
||||
});
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue