Initial commit
This commit is contained in:
25
src/day1/Stack.test.ts
Normal file
25
src/day1/Stack.test.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import Stack from "@code/Stack";
|
||||
|
||||
test("stack", function () {
|
||||
const list = new Stack<number>();
|
||||
|
||||
list.push(5);
|
||||
list.push(7);
|
||||
list.push(9);
|
||||
|
||||
expect(list.pop()).toEqual(9);
|
||||
expect(list.length).toEqual(2);
|
||||
|
||||
list.push(11);
|
||||
expect(list.pop()).toEqual(11);
|
||||
expect(list.pop()).toEqual(7);
|
||||
expect(list.peek()).toEqual(5);
|
||||
expect(list.pop()).toEqual(5);
|
||||
expect(list.pop()).toEqual(undefined);
|
||||
|
||||
// just wanted to make sure that I could not blow up myself when i remove
|
||||
// everything
|
||||
list.push(69);
|
||||
expect(list.peek()).toEqual(69);
|
||||
expect(list.length).toEqual(1);
|
||||
});
|
||||
Reference in New Issue
Block a user