Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def test_find() -> None:
- print("Test 19: je v \"abc\" podretezec \"abc\"?")
- try:
- res = find_substring("abc", "abc")
- if res == 0:
- print("OK.")
- else:
- print("NOK, podretezec je na pozici 0, vy vracite", res)
- except IndexError as exc:
- print("NOK: pristupovani mimo pole.")
- print("Chybova hlaska Pythonu: {}".format(exc))
- print("Test 20: je v \"abc\" podretezec \"b\"?")
- try:
- res = find_substring("abc", "b")
- if res == 1:
- print("OK.")
- else:
- print("NOK, podretezec je na pozici 1, vy vracite", res)
- except IndexError as exc:
- print("NOK: pristupovani mimo pole.")
- print("Chybova hlaska Pythonu: {}".format(exc))
- print("Test 21: je v \"abcb\" podretezec \"abb\"?")
- try:
- res = find_substring("abcb", "abb")
- if res == -1:
- print("OK.")
- else:
- print("NOK, podretezec zde neni, vy vracite", res)
- except IndexError as exc:
- print("NOK: pristupovani mimo pole.")
- print("Chybova hlaska Pythonu: {}".format(exc))
- print("Test 22: je v \"ab\" podretezec \"bb\"?")
- try:
- res = find_substring("ab", "bb")
- if res == -1:
- print("OK.")
- else:
- print("NOK, podretezec zde neni, vy vracite", res)
- except IndexError as exc:
- print("NOK: pristupovani mimo pole.")
- print("Chybova hlaska Pythonu: {}".format(exc))
- print("Test 23: je v \"baba\" podretezec \"ab\"?")
- try:
- res = find_substring("ababcb", "abcb")
- if res == 1:
- print("OK.")
- else:
- print("NOK, podretezec je na pozici 1, vy vracite", res)
- except IndexError as exc:
- print("NOK: pristupovani mimo pole.")
- print("Chybova hlaska Pythonu: {}".format(exc))
- if __name__ == '__main__':
- test_find()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement