Add tests for isPerfectSquare (#3131)
This commit is contained in:
parent
4ccb9f460f
commit
678ec396fc
37
src/test/java/com/thealgorithms/maths/PerfectSquareTest.java
Normal file
37
src/test/java/com/thealgorithms/maths/PerfectSquareTest.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package com.thealgorithms.maths;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
|
||||||
|
public class PerfectSquareTest{
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void TestPerfectSquareifiscorrect(){
|
||||||
|
//Valid Partition
|
||||||
|
int number = 9;
|
||||||
|
|
||||||
|
boolean result = PerfectSquare.isPerfectSquare(number);
|
||||||
|
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void TestPerfectSquareifisnotcorrect(){
|
||||||
|
//Invalid Partition 1
|
||||||
|
int number = 3;
|
||||||
|
|
||||||
|
boolean result = PerfectSquare.isPerfectSquare(number);
|
||||||
|
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void TestPerfectSquareifisNegativeNumber(){
|
||||||
|
//Invalid Partition 2
|
||||||
|
int number = -10;
|
||||||
|
|
||||||
|
boolean result = PerfectSquare.isPerfectSquare(number);
|
||||||
|
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user