Advertisement
Guest User

Testy stosu

a guest
Apr 9th, 2020
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.31 KB | None | 0 0
  1. import my_stack as st
  2.  
  3. #Stos
  4.  
  5. def test_new():
  6.     s = st.new()
  7.     if s == []:
  8.         print("Test passed succesfully!")
  9.         passed = True
  10.     else:
  11.         print("Test didnt passed!")
  12.         passed = False
  13.     return passed
  14.  
  15. def test_empty():
  16.     s = st.new()
  17.     if st.empty(s):
  18.         print("Test passed succesfully!")
  19.         passed = True
  20.     else:
  21.         print("Test didnt passed!")
  22.         passed = False
  23.     return passed
  24.  
  25. def test_pop():
  26.     s = st.new()
  27.     st.push(s, 5)
  28.     st.push(s, 10)
  29.     st.push(s, 15)
  30.     ostatni = st.pop(s)
  31.     if ostatni == 15:
  32.         print("Test passed succesfully!")
  33.         passed = True
  34.     else:
  35.         print("Test didnt passed!")
  36.         passed = False
  37.     return passed
  38.  
  39. def test_push():
  40.     s = st.new()
  41.     st.push(s, 5)
  42.     if s[0] == 5:
  43.        print("Test passed succesfully!")
  44.        passed = True
  45.     else:
  46.         print("Test didnt passed!")
  47.         passed = False
  48.     return passed
  49.  
  50. def test_top():
  51.     s = st.new()
  52.     st.push(s, 5)
  53.     st.push(s, 15)
  54.     if st.top(s) == 20:
  55.         print("Test passed succesfully!")
  56.         passed = False
  57.     else:
  58.         print("Test didnt passed!")
  59.         passed = False
  60.     return passed
  61.  
  62. print("Testy stos")
  63. test_new()
  64. test_empty()
  65. test_pop()
  66. test_push()
  67. test_top()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement