Guest User

Untitled

a guest
Apr 19th, 2018
74
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. end
  43.  
  44. def test_push_push_pop_and_size
  45. @stack.push(3)
  46. @stack.push(5)
  47. @stack.pop
  48. assert_equal 1, @stack.size
  49. end
  50.  
  51. def test_push_push_and_pop
  52. @stack.push(3)
  53. @stack.push(5)
  54. assert_equal 5, @stack.pop
  55. end
  56.  
  57. end
Add Comment
Please, Sign In to add comment