Merge pull request #10312 from abdallahsawan/BAEL-4696

Determine if an Integer's Square Root Is an Integer in Java Article b…
This commit is contained in:
bfontana 2020-12-22 00:03:45 -03:00 committed by GitHub
commit a3fdd3e92b
1 changed files with 5 additions and 6 deletions

View File

@ -6,22 +6,21 @@ import static org.junit.Assert.assertEquals;
public class PerfectSquareUnitTest {
@Test
public void test0xFFAssignedToInteger() {
public void testIsNumberPerfectSquare() {
long n = 18676209273604L; // 18676209273604 = 43621598 * 43621598
boolean expectedValue = true;
assertEquals(expectedValue, PerfectSquareUtil.isPerfectSquareByUsingSqrt(n));
assertEquals(expectedValue, PerfectSquareUtil.isPerfectSquareByUsingBinarySearch(1, Integer.MAX_VALUE, n));
assertEquals(expectedValue, PerfectSquareUtil.isPerfectSquareByUsingNewtonMethod(n));
assertEquals(expectedValue, PerfectSquareUtil.isPerfectSquareWithOptimization(n));
}
@Test
public void test0xFFAssignedToByte() {
long n = 549790047707L; // prime number
boolean expectedValue = false;
n = 549790047707L; // prime number
expectedValue = false;
assertEquals(expectedValue, PerfectSquareUtil.isPerfectSquareByUsingSqrt(n));
assertEquals(expectedValue, PerfectSquareUtil.isPerfectSquareByUsingBinarySearch(1, Integer.MAX_VALUE, n));
assertEquals(expectedValue, PerfectSquareUtil.isPerfectSquareByUsingNewtonMethod(n));
assertEquals(expectedValue, PerfectSquareUtil.isPerfectSquareWithOptimization(n));
}
}