Repository navigation
fix(maths): validate non-positive dimensions and torus radius in Volume - #7770
Open
spidervirus wants to merge 1 commit into
Open
spidervirus wants to merge 1 commit into
spidervirus wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7770 +/- ##
============================================
+ Coverage 82.42% 82.48% +0.05%
- Complexity 8508 8536 +28
============================================
Files 847 847
Lines 26289 26335 +46
Branches 5133 5144 +11
============================================
+ Hits 21670 21722 +52
+ Misses 3828 3824 -4
+ Partials 791 789 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
spidervirus
force-pushed
the
fix/volume-input-validation
branch
from
November 19, 2026 11:55
50189d0 to
0a395f2
Compare
spidervirus
marked this pull request as ready for review
November 19, 2026 11:55
spidervirus
requested review from
DenizAltunkapan,
alxkm and
yanglbme
as code owners
November 19, 2026 11:55
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.
clang-format -i --style=file path/to/your/file.javaDescription
In$\le 0$ , the methods in
com.thealgorithms.maths.Volume:Unlike
Area.java, which checks all input dimensions and throwsIllegalArgumentExceptionfor valuesVolume.javadid not validate inputs.Non-positive and negative dimensions (e.g. negative radius, negative height) produced invalid, negative, or contradictory volumes without error. In addition,
volumeTorus(majorRadius, minorRadius)did not verify thatmajorRadius >= minorRadius.Fix
IllegalArgumentExceptionwhen dimensions (radius, height, width, length, side, base area, semi-axes) areArea.java.majorRadius >= minorRadiusfor torus volume calculation.VolumeTestassertingIllegalArgumentExceptionon non-positive and invalid inputs for each shape.