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.

21 lines
563 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. ])
  13. def test_bm(text, pattern, expected):
  14. bm = Bm(text, pattern)
  15. actual = bm.search()
  16. assert actual == expected
  17. # assert False # for print debugging