Repository navigation
test(graph): cover failure and boundary behavior in GomoryHuTree (R45… - #48
Open
Sapna2007-sst wants to merge 1 commit into
Open
Sapna2007-sst wants to merge 1 commit into
Sapna2007-sst 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.
clang-format -i --style=file path/to/your/file.javaDescription
This pull request resolves task R45-T008 / Issue #8 by providing comprehensive failure-path and boundary coverage for
GomoryHuTree.java. It exercises every rejection and failure path invalidateCapacityMatrix, naming the exact source lines establishing preconditions (cap == null,cap.length == 0,cap[i] == null,cap[i].length != n,cap[i][j] < 0). It validates the smallest valid input fixture ([[0]]), ordinary valid fixtures (2-node and 3-node graphs), confirms that caller-owned state is never mutated across failures, and verifies that subsequent valid calls execute successfully immediately after an exception.Related Issue
Closes #8
Related to: #8
Type of Change
Changes Made
Javadoc Documentation (
GomoryHuTree.java):@throws IllegalArgumentExceptionspecifications for null, empty, ragged/non-square, and negative capacity matrices.Unit & Regression Tests (
GomoryHuTreeTest.java):testSmallestValidInputFixture: Tests 1x1 matrix ([[0]]), verifying preconditioncap != null && cap.length == 1established atGomoryHuTree.java:73-86and branched at line 40, expectingparent = [-1],weight = [0].testOrdinaryInputFixture: Tests ordinary 2x2 matrix ([[0, 7], [7, 0]]), expectingparent = [-1, 0],weight = [0, 7].testDocumentedOrdinaryTriangleInputFixture: Tests ordinary 3x3 symmetric matrix, expectingparent = [-1, 0, 0],weight = [0, 5, 6].testFailureNullCapacityMatrixThrowsIllegalArgumentException: Testscap == nullprecondition checked at line 73, thrown at line 74 with message"Capacity matrix must not be null or empty".testFailureEmptyCapacityMatrixThrowsIllegalArgumentException: Testscap.length == 0precondition checked at line 73, thrown at line 74 with message"Capacity matrix must not be null or empty".testFailureNullRowThrowsIllegalArgumentException: Testscap[i] == nullprecondition checked at line 78, thrown at line 79 with message"Capacity matrix must be square".testFailureNonSquareCapacityMatrixThrowsIllegalArgumentException: Testscap[i].length != nprecondition checked at line 78, thrown at line 79 with message"Capacity matrix must be square".testFailureNegativeCapacityThrowsExceptionAndPreservesCallerStateWithSubsequentSuccess: Testscap[i][j] < 0precondition checked at line 82, thrown at line 83 with message"Capacities must be non-negative". Asserts caller-owned array is unmutated, followed by a successful call returningparent = [-1, 0],weight = [0, 7].testCallerOwnedOrdinaryStateUnmutatedAcrossExceptionsAndExecutions: Verifies that caller-owned arrays passed into operations are completely unmutated across failure calls and subsequent successful calls.testPrivateConstructorContract: Reflection contract test verifying private constructor encapsulation.Automated Verification Harness (
work/R45-T008/):check.pyrunner logging environment metadata (Python 3.15, OpenJDK 21, Maven 3.10) and executingmvn test -Dtest=GomoryHuTreeTestandmvn checkstyle:check.results.jsonandevidence.mdconfirming 13/13 tests passing with 0 failures, 0 errors, and 0 checkstyle violations.Screenshots / Recordings