Repository navigation
[R45-T011] Add contract regression checks for ComplexNumberMultiply - #53
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 contract regression tests for
ComplexNumberMultiply.multiply(String, String)insrc/main/java/com/thealgorithms/maths/ComplexNumberMultiply.java, documents a concise input/output contract besidemultiply(String, String), and adds a focused runner (work/R45-T011/check.py) that executes the checks and saves inputs, expected versus actual results, and tool versions. All existing behavior and public interfaces are preserved.Related Issue
Fixes: #11
Type of Change
Changes Made
ComplexNumberMultiply.multiply(String, String)(lines 23–38 ofsrc/main/java/com/thealgorithms/maths/ComplexNumberMultiply.java). No executable code or public interface was changed.src/test/java/com/thealgorithms/maths/ComplexNumberMultiplyContractTest.javawith 5 test methods (22 logged cases):"0+0i","1+0i","0+1i") with literal expected outputs and precondition line citations.("2+3i", "4+5i")→"-7+22i",("1+-2i", "-3+4i")→"5+10i")."1+1i","-1+-1i","0+-1i", multiplicative identity"1+0i", zero absorption, pure imaginary, conjugate pair, and multi-digit negative/positive components).nullinput rejection (IllegalArgumentExceptionmessage contract).work/R45-T011/check.py(with evidence files inwork/R45-T011/), which runsmvn testforComplexNumberMultiplyContractTest, enforces a nonzero test count, savescomparisons.txt,result.txt,mvn_output.txt, andtool_versions.txt, and exits non-zero on failure.Screenshots / Recordings
Not applicable (no UI changes).
Testing
Command:
python3 work/R45-T011/check.py(runs
mvn -B test -Dtest=ComplexNumberMultiplyContractTest -Dsurefire.failIfNoSpecifiedTests=false)Result:
tests=5 failures/errors=0 skipped=0 comparisons=22 mvn_exit=0,status=PASSExisting suite:
mvn -B test -Dtest=ComplexNumberMultiplyTest -Dsurefire.failIfNoSpecifiedTests=false→Tests run: 5, Failures: 0, Errors: 0, Skipped: 0(BUILD SUCCESS).Negative check: temporarily changing
int real = a[0] * b[0] - a[1] * b[1];to+on line 43 madepython3 work/R45-T011/check.pyprintstatus=FAIL(tests=5 failures/errors=4 skipped=0 mvn_exit=1) and exit non-zero; the 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-T011/tool_versions.txtandwork/R45-T011/comparisons.txt.Checklist
Additional Notes
The task text points at "line 9", which is the private constructor; the public method under test is
multiply(String, String)(originally line 23, now line 39 after adding Javadoc) backed byparse(String)(lines 12–21).The
work/R45-T011/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