Add tests for isPerfectSquare (#3131)

This commit is contained in:
BI11-061 Hoàng Anh Đức 2022-06-15 23:19:27 +07:00 committed by GitHub
parent 4ccb9f460f
commit 678ec396fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View 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);
}
}