Skip to content

Commit 678ec39

Browse files
authored
Add tests for isPerfectSquare (TheAlgorithms#3131)
1 parent 4ccb9f4 commit 678ec39

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.thealgorithms.maths;
2+
3+
import org.junit.jupiter.api.Test;
4+
import static org.junit.jupiter.api.Assertions.*;
5+
6+
7+
public class PerfectSquareTest{
8+
9+
@Test
10+
public void TestPerfectSquareifiscorrect(){
11+
//Valid Partition
12+
int number = 9;
13+
14+
boolean result = PerfectSquare.isPerfectSquare(number);
15+
16+
assertTrue(result);
17+
}
18+
19+
@Test
20+
public void TestPerfectSquareifisnotcorrect(){
21+
//Invalid Partition 1
22+
int number = 3;
23+
24+
boolean result = PerfectSquare.isPerfectSquare(number);
25+
26+
assertFalse(result);
27+
}
28+
@Test
29+
public void TestPerfectSquareifisNegativeNumber(){
30+
//Invalid Partition 2
31+
int number = -10;
32+
33+
boolean result = PerfectSquare.isPerfectSquare(number);
34+
35+
assertFalse(result);
36+
}
37+
}

0 commit comments

Comments
 (0)