Repository navigation
[R45-T013] Add reference-comparison checks for FairShareScheduling.addWeight - #52
Open
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 reference-comparison regression tests for
FairShareScheduling.User#addWeight(int)insrc/main/java/com/thealgorithms/scheduling/FairShareScheduling.java, documents one representative result in the source Javadoc foraddWeight(int), and adds a focused runner (work/R45-T013/check.py) that runs the tests and saves inputs, expected versus actual results, and tool versions. All existing behavior and public interfaces are preserved.Related Issue
Fixes: #13
Type of Change
Changes Made
FairShareScheduling.User#addWeight(int)explaining one representative result (totalWeight = 0->addWeight(2)->addWeight(3)->totalWeight = 5; paired with a second user of weight5andtotalResources = 100,allocateResources(100)assigns50to each user). No executable code or public API was altered.src/test/java/com/thealgorithms/scheduling/FairShareSchedulingReferenceTest.javawith 4 test methods covering 36 logged comparisons:weight = 0,weight = 1, and single-usertotalResources = 1→{"u1": 1}) with hand-calculated literal expected outputs and source-line citations.addWeight(2)thenaddWeight(3)→5, paired withbobweight5andtotalResources = 100→{"alice": 50, "bob": 50}).addWeightsequences and 6 multi-userFairShareSchedulingallocation cases compared against both an explicit hand-calculated literal table and an independentIntStream/BigDecimalreference oracle.getAllocatedResources()(line 69).work/R45-T013/check.py(along with captured evidence inwork/R45-T013/), which runsmvn testforFairShareSchedulingReferenceTest, verifies a nonzero test count and at least 20 comparisons, writescomparisons.txt,result.txt,mvn_output.txt, andtool_versions.txt, and exits non-zero on any failure.Screenshots / Recordings
Not applicable (no UI changes).
Testing
Command:
python3 work/R45-T013/check.py(runs
mvn -B test -Dtest=FairShareSchedulingReferenceTest -Dsurefire.failIfNoSpecifiedTests=false)Result:
tests=4 failures/errors=0 skipped=0 comparisons=36 mvn_exit=0,status=PASSExisting suite:
mvn -B test -Dtest=FairShareSchedulingTest -Dsurefire.failIfNoSpecifiedTests=false→Tests run: 4, Failures: 0, Errors: 0, Skipped: 0(BUILD SUCCESS).Negative check: temporarily changing
this.totalWeight += weight;tothis.totalWeight = weight;on line 40 madepython3 work/R45-T013/check.pyprintstatus=FAIL(tests=4 failures/errors=3 skipped=0 mvn_exit=1) and exit non-zero; the temporary change was reverted and re-verified.Style:
mvn -B checkstyle:checkreports0 Checkstyle violations(BUILD SUCCESS).Tool versions and comparison outputs are saved in
work/R45-T013/tool_versions.txtandwork/R45-T013/comparisons.txt.Checklist
Additional Notes
There is no earlier review feedback to address.
The
work/R45-T013/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