-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack_test.dart
More file actions
30 lines (28 loc) · 769 Bytes
/
stack_test.dart
File metadata and controls
30 lines (28 loc) · 769 Bytes
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
import "package:test/test.dart";
import 'stack.dart';
void main() {
test("Empty stack should be empty, non empty stack should not", () {
Stack<String> s = new Stack();
expect(s.isEmpty(), equals(true));
s.push("?");
expect(s.isEmpty(), equals(false));
});
test("Stack should support pushing, peeking and popping", () {
Stack<int> s = new Stack();
s.push(1);
expect(s.peek(), equals(1));
expect(s.pop(), equals(1));
expect(s.peek(), equals(null));
expect(s.pop(), equals(null));
s.push(1);
s.push(2);
s.push(3);
s.push(4);
s.push(1);
expect(s.pop(), equals(1));
expect(s.pop(), equals(4));
expect(s.pop(), equals(3));
expect(s.pop(), equals(2));
expect(s.pop(), equals(1));
});
}