Skip to content

Add regression doctests for KMP search and failure arrays - #15546

Open
Miladkhoshdel wants to merge 1 commit into
TheAlgorithms:masterfrom
Miladkhoshdel:test/kmp-empty-pattern
Open

Miladkhoshdel wants to merge 1 commit into
TheAlgorithms:masterfrom
Miladkhoshdel:test/kmp-empty-pattern

Conversation

@Miladkhoshdel

Copy link
Copy Markdown
Contributor

Describe your change

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Add or change doctests? -- Note: Please avoid changing both code and tests in a single pull request.
  • Documentation change?

Add regression doctests for empty-pattern handling in knuth_morris_pratt() and examples for get_failure_array().

The search tests verify that an empty pattern returns 0 for both empty and nonempty text, consistent with str.find(). The helper tests cover distinct characters and overlapping prefixes.

This PR changes only doctests in one algorithm file.

Dependency: #15545 must merge first. Without that fix, the two empty-pattern doctests fail. After it merges, this branch should be updated before running CI again.

Validation:

  • Both new get_failure_array() doctests pass.
  • All 6 doctests pass with the pending fix applied in memory.
  • Ruff lint and formatting checks pass.
  • git diff --check passes.

Checklist

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory. — No new files added.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing. — Both functions now have doctests; passing CI depends on merging Fix empty-pattern handling in KMP search #15545 first.
  • All new algorithms include at least one URL that points to Wikipedia or another similar explanation. — No new algorithms added.
  • If this pull request resolves one or more open issues, then the description above includes the issue number(s) with a closing keyword: "Fixes #ISSUE-NUMBER". — No linked issues to close.

@algorithms-keeper algorithms-keeper Bot added awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files tests are failing Do not merge until tests pass labels Oct 10, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files tests are failing Do not merge until tests pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant