blob: 2a9834008157f2334f97d01bcc0316cd4eea7250 (
plain)
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
|
require "stack"
class StackTests < Test::Unit::TestCase
def test_math
assert_equal(2, 1+1)
end
def test_assertions
# puts self.methods
end
def test_should_be_able_to_push_items_onto_the_stack
stack = Stack.new
stack.push "hello"
assert_equal(1, stack.total_items)
stack.push "yo"
assert_equal(2, stack.total_items)
end
def test_should_be_able_to_pop_the_last_item_off_of_the_stack
stack=Stack.new
stack.push "hello"
stack.push "goodbye"
assert_equal("goodbye", stack.pop)
end
def test_should_remove_the_last_item_popped_off_of_the_stack
stack=Stack.new
stack.push "hello"
stack.push "goodbye"
assert_equal("goodbye", stack.pop)
assert_equal(1, stack.total_items)
assert_equal("hello", stack.pop)
assert_equal(0, stack.total_items)
end
def test_should_return_nil_when_there_is_nothing_on_the_stack
stack=Stack.new
assert_equal(nil, stack.pop)
end
end
|