You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
719 B

  1. import pytest
  2. from src.bm import Bm
  3. @pytest.mark.parametrize("text,pattern,expected", [
  4. ("GCTCACTGAGCGCTCGT", "GCTCG", 11),
  5. ("GCTCACTGAGCGCTCGT", "CACTGAG", 3),
  6. ("GCTCACTGAGCGCTCGT", "AAAAA", -1),
  7. ("GCTCACTGAGCGCTCGT", "GCTCGTT", -1),
  8. ("GCTCACTGAGCGCTCGT", "GCTCACTGAGCGCTCGT", 0),
  9. ("ANPANMAN", "PAN", 2),
  10. ("ANPANMAN", "ANPAN", 0),
  11. ("ANPANMAN", "BIKINMAN", -1),
  12. # Other useful test cases:
  13. ("ユニコード", "コード", 2),
  14. ("", "", -1),
  15. ("a", "", -1),
  16. ("", "a", -1),
  17. ("t", "too long", -1),
  18. ])
  19. def test_bm(text, pattern, expected):
  20. bm = Bm(text, pattern)
  21. actual = bm.search()
  22. assert actual == expected
  23. # assert False # for print debugging