forked from AdaGold/stacks-queues
-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathstack_test.rb
More file actions
48 lines (42 loc) · 978 Bytes
/
stack_test.rb
File metadata and controls
48 lines (42 loc) · 978 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require "minitest/autorun"
require "minitest/reporters"
require_relative "../lib/stack"
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
describe "Test Stack Implementation" do
it "creates a Stack" do
s = Stack.new
s.class.must_equal Stack
end
it "pushes something onto a empty Stack" do
s = Stack.new
s.push(10)
s.to_s.must_equal "[10]"
end
it "pushes multiple somethings onto a Stack" do
s = Stack.new
s.push(10)
s.push(20)
s.push(30)
s.to_s.must_equal "[10, 20, 30]"
end
it "starts the stack empty" do
s = Stack.new
s.empty?.must_equal true
end
it "removes something from the stack" do
s = Stack.new
s.push(5)
removed = s.pop
removed.must_equal 5
s.empty?.must_equal true
end
it "removes the right something (LIFO)" do
s = Stack.new
s.push(5)
s.push(3)
s.push(7)
removed = s.pop
removed.must_equal 7
s.to_s.must_equal "[5, 3]"
end
end