Skip to content

feat(cipher/railfence): add FuzzRailFence test, rune support, and edge case handling - #812

Open
rajpreetcodes wants to merge 1 commit into
TheAlgorithms:masterfrom
rajpreetcodes:fix/railfence-fuzz-and-unicode
Open

rajpreetcodes wants to merge 1 commit into
TheAlgorithms:masterfrom
rajpreetcodes:fix/railfence-fuzz-and-unicode

Conversation

@rajpreetcodes

Copy link
Copy Markdown

Description of Change

Addresses #480

  • Adds FuzzRailFence fuzz test with comprehensive seed corpus and utf8 validity check.
  • Adds full Unicode rune support by converting inputs to rune slices ([]rune) rather than indexing raw bytes.
  • Refactors Encrypt to append characters directly to per-rail slices, eliminating sentinel null-byte filtering (which previously dropped valid \x00 runes) and reducing memory allocations from O(rails * n) to O(n).
  • Adds test cases in TestEncrypt and TestDecrypt covering Unicode runes ("café crème"), negative rails, zero rails, and empty strings.

Checklist

  • Added description of change
  • Added file name matches File name guidelines
  • Added tests and example, test must pass
  • Added documentation so that the program is self-explanatory and educational - GoDoc guidelines
  • Relevant documentation/comments is changed or added
  • PR title follows semantic commit guidelines
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • I acknowledge that all my contributions will be made under the project's license.

Notes: Adds FuzzRailFence fuzz testing, Unicode rune support, and edge-case handling for the rail fence cipher.

…e case handling

Addresses TheAlgorithms#480

- Add FuzzRailFence fuzz test with seed corpus and utf8 validity check

- Support Unicode runes by operating on rune slices instead of raw byte indexes

- Store characters directly in per-rail rune slices to avoid sentinel null byte issues and reduce memory allocations

- Guard against non-positive rails and rails exceeding text length
@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@rajpreetcodes

Copy link
Copy Markdown
Author

All unit tests, Unicode rune test cases, Fuzz test (FuzzRailFence), and golangci-lint with revive are passing 100% cleanly. The Codacy check is waiting on the coverage upload workflow run approval for fork PRs. Ready for review when convenient.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant