refactor: TwoPointers (#6374)

* refactor: TwoPointers

* refactor: fix test formatting

* refactor: fix checkstyle

* refactor: fix checkstyle
This commit is contained in:
Oleksandr Klymenko
2025-07-13 12:25:26 +03:00
committed by GitHub
parent 182118b6a4
commit ef93cc1503
2 changed files with 28 additions and 13 deletions

View File

@@ -1,6 +1,8 @@
package com.thealgorithms.others;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
@@ -69,4 +71,10 @@ public class TwoPointersTest {
int key = 9;
assertTrue(TwoPointers.isPairedSum(arr, key));
}
@Test
void isPairedSumShouldThrowExceptionWhenArrayIsNull() {
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> TwoPointers.isPairedSum(null, 10));
assertEquals("Input array must not be null.", exception.getMessage());
}
}