-
Notifications
You must be signed in to change notification settings - Fork 0
/
NearestSquareRoot.test.java
47 lines (40 loc) · 1.33 KB
/
NearestSquareRoot.test.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class NearestSquareRootTest {
@Test
public void testFindNearestSquareRootOfExactSquare() {
int number = 49;
int expected = 7;
int actual = NearestSquareRoot.findNearestSquareRoot(number);
assertEquals(expected, actual);
}
@Test
public void testFindNearestSquareRootOfNonSquare() {
int number = 300;
int expected = 17;
int actual = NearestSquareRoot.findNearestSquareRoot(number);
assertEquals(expected, actual);
}
@Test
public void testFindNearestSquareRootOfSmallNumber() {
int number = 2;
int expected = 1;
int actual = NearestSquareRoot.findNearestSquareRoot(number);
assertEquals(expected, actual);
}
@Test
public void testFindNearestSquareRootOfOne() {
int number = 1;
int expected = 1;
int actual = NearestSquareRoot.findNearestSquareRoot(number);
assertEquals(expected, actual);
}
@Test
public void testFindNearestSquareRootOfZero() {
int number = 0;
int expected = 0;
int actual = NearestSquareRoot.findNearestSquareRoot(number);
assertEquals(expected, actual);
}
// ... Any other test cases you deem necessary ...
}