Add a new method to check Perfect Square (#5917)

This commit is contained in:
Taranjeet Singh Kalsi
2024-10-26 17:00:33 +05:30
committed by GitHub
parent 95875b0ae4
commit 921821214f
2 changed files with 14 additions and 0 deletions

View File

@@ -9,11 +9,13 @@ public class PerfectSquareTest {
@ValueSource(ints = {0, 1, 2 * 2, 3 * 3, 4 * 4, 5 * 5, 6 * 6, 7 * 7, 8 * 8, 9 * 9, 10 * 10, 11 * 11, 123 * 123})
void positiveTest(final int number) {
Assertions.assertTrue(PerfectSquare.isPerfectSquare(number));
Assertions.assertTrue(PerfectSquare.isPerfectSquareUsingPow(number));
}
@ParameterizedTest
@ValueSource(ints = {-1, -2, -3, -4, -5, -100, 2, 3, 5, 6, 7, 8, 10, 11, 12, 13, 15, 17, 99, 101, 257, 999, 1001})
void negativeTest(final int number) {
Assertions.assertFalse(PerfectSquare.isPerfectSquare(number));
Assertions.assertFalse(PerfectSquare.isPerfectSquareUsingPow(number));
}
}