Guest User

Untitled

a guest
Apr 19th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1.  
  2. require 'test/unit'
  3. require 'stack'
  4.  
  5. class TestStack < Test::Unit::TestCase
  6. def setup
  7. @stack = Stack.new
  8. end
  9.  
  10. def test_empty
  11. assert @stack.empty?
  12. end
  13.  
  14. def test_size
  15. assert_equal 0, @stack.size
  16. end
  17.  
  18. def test_empty_pop
  19. assert_raise(Stack::EmptyError){
  20. @stack.pop
  21. }
  22. end
  23.  
  24. def test_push_and_pop
  25. @stack.push(3)
  26. assert_equal 3, @stack.pop
  27. end
  28.  
  29. def test_push_and_size
  30. @stack.push(3)
  31. assert_equal 1, @stack.size
  32. end
  33.  
  34. def test_push_push_and_size
  35. @stack.push(3)
  36. @stack.push(5)
  37. assert_equal 2, @stack.size
  38. end
  39.  
  40. def test_push_and_empty
  41. @stack.push(3)
  42. assert !@stack.empty?
  43. end
  44.  
  45. def test_push_push_pop_and_size
  46. @stack.push(3)
  47. @stack.push(5)
  48. @stack.pop
  49. assert_equal 1, @stack.size
  50. end
  51.  
  52. def test_push_push_and_pop
  53. @stack.push(3)
  54. @stack.push(5)
  55. assert_equal 5, @stack.pop
  56. end
  57.  
  58. end
Add Comment
Please, Sign In to add comment