Repository navigation
[R45-T015] Add determinism checks for HowManyTimesRotated - #51
Open
shyamlibakale1001-alt wants to merge 1 commit into
Open
shyamlibakale1001-alt wants to merge 1 commit into
shyamlibakale1001-alt wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds JUnit determinism checks for
HowManyTimesRotated.rotated(int[])and a small runner (work/R45-T015/check.py) that executes them and propagates failures. The method is already pure (no I/O, time, randomness or input mutation), so this PR adds regression tests only and does not change the implementation.Related Issue
Fixes: #15
Type of Change
Changes Made
src/test/java/com/thealgorithms/searches/HowManyTimesRotatedDeterminismTest.javawith 6 tests:{7}→ 0, called twice{15, 17, 2, 3, 5}→ 2, called twice{11, 12, 15, 18, 2, 5, 6, 8}→ 4 and{7}→ 0) run in betweenSystem.in(onlymain()reads stdin)rotatedat line 45, loop skipped for length 1 at line 49, result at line 58).work/R45-T015/check.py, which runsmvn testfor the new class, requires a nonzero test count, and saves the command, test count, tool versions and Maven output inwork/R45-T015/.Not applicable (no UI changes).
Testing
Command:
python3 work/R45-T015/check.py(runs
mvn -B test -Dtest=HowManyTimesRotatedDeterminismTest -Dsurefire.failIfNoSpecifiedTests=false)Result:
tests=6 failures/errors=0 skipped=0 mvn_exit=0,PASSNegative check: temporarily changing
a[mid] > a[high]toa[mid] < a[high]on line 51 made the check printFAIL(4 of 6 tests failed) and exit non-zero; the change was reverted andgit diff src/mainis empty.Style:
mvn -B checkstyle:checkreports 0 violations.Tool versions are saved in
work/R45-T015/tool_versions.txt.Checklist
Additional Notes
No documentation change was needed, and there is no earlier review feedback to address.
The task text points at "line 30", which is the private constructor; the method under test is at line 45.
The
work/R45-T015/evidence folder is for coursework review only and should not go into any later upstream PR.I have read CONTRIBUTING.md.
This pull request is all my own work -- I have not plagiarized it.
All filenames are in PascalCase.
All functions and variable names follow Java naming conventions.
All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
All new algorithms include a corresponding test class that validates their functionality.
All new code is formatted with
clang-format -i --style=file path/to/your/file.java