Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.91 KB | None | 0 0
  1. def test_find() -> None:
  2.     print("Test 19: je v \"abc\" podretezec \"abc\"?")
  3.     try:
  4.         res = find_substring("abc", "abc")
  5.         if res == 0:
  6.             print("OK.")
  7.         else:
  8.             print("NOK, podretezec je na pozici 0, vy vracite", res)
  9.     except IndexError as exc:
  10.         print("NOK: pristupovani mimo pole.")
  11.         print("Chybova hlaska Pythonu: {}".format(exc))
  12.  
  13.     print("Test 20: je v \"abc\" podretezec \"b\"?")
  14.     try:
  15.         res = find_substring("abc", "b")
  16.         if res == 1:
  17.             print("OK.")
  18.         else:
  19.             print("NOK, podretezec je na pozici 1, vy vracite", res)
  20.     except IndexError as exc:
  21.         print("NOK: pristupovani mimo pole.")
  22.         print("Chybova hlaska Pythonu: {}".format(exc))
  23.  
  24.     print("Test 21: je v \"abcb\" podretezec \"abb\"?")
  25.     try:
  26.         res = find_substring("abcb", "abb")
  27.         if res == -1:
  28.             print("OK.")
  29.         else:
  30.             print("NOK, podretezec zde neni, vy vracite", res)
  31.     except IndexError as exc:
  32.         print("NOK: pristupovani mimo pole.")
  33.         print("Chybova hlaska Pythonu: {}".format(exc))
  34.  
  35.     print("Test 22: je v \"ab\" podretezec \"bb\"?")
  36.     try:
  37.         res = find_substring("ab", "bb")
  38.         if res == -1:
  39.             print("OK.")
  40.         else:
  41.             print("NOK, podretezec zde neni, vy vracite", res)
  42.     except IndexError as exc:
  43.         print("NOK: pristupovani mimo pole.")
  44.         print("Chybova hlaska Pythonu: {}".format(exc))
  45.  
  46.     print("Test 23: je v \"baba\" podretezec \"ab\"?")
  47.     try:
  48.         res = find_substring("ababcb", "abcb")
  49.         if res == 1:
  50.             print("OK.")
  51.         else:
  52.             print("NOK, podretezec je na pozici 1, vy vracite", res)
  53.     except IndexError as exc:
  54.         print("NOK: pristupovani mimo pole.")
  55.         print("Chybova hlaska Pythonu: {}".format(exc))
  56.  
  57.  
  58. if __name__ == '__main__':
  59.     test_find()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement