Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid NoSuchElementException in MathPlume.modulusStrictInt #371

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/java/org/plumelib/util/MathPlume.java
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,9 @@ public static double gcdDifferences(double[] a) {
int lastNonstrict = 0; // arbitrary initial value
if (nonstrictEnds) {
firstNonstrict = itor.next().intValue();
if (!itor.hasNext()) {
return null;
}
}

int prev = itor.next().intValue();
Expand Down
1 change: 1 addition & 0 deletions src/test/java/org/plumelib/util/MathPlumeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ public void test_modulus() {

TestNonModulus testNonModulus = new TestNonModulus();

testNonModulus.checkStrict(new int[] {1}, null);
jyoo980 marked this conversation as resolved.
Show resolved Hide resolved
testNonModulus.checkStrict(new int[] {1, 2, 3, 5, 6, 7, 9}, null);
testNonModulus.checkStrict(new int[] {-1, 1, 2, 3, 5, 6, 7, 9}, new int[] {0, 4});
testNonModulus.checkStrict(new int[] {1, 2, 3, 5, 6, 7, 9, 11}, null);
Expand Down