-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSquareCalculator.test.java
More file actions
49 lines (42 loc) · 1.63 KB
/
Copy pathSquareCalculator.test.java
File metadata and controls
49 lines (42 loc) · 1.63 KB
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
48
49
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Arrays;
import java.util.List;
public class SquareCalculatorTest {
@Test
public void testCalculateSquareWithPositiveIntegers() {
int[] inputArray = {1, 2, 3, 4, 5};
List<Integer> expected = Arrays.asList(1, 4, 9, 16, 25);
List<Integer> actual = SquareCalculator.calculateSquare(inputArray);
assertEquals(expected, actual);
}
@Test
public void testCalculateSquareWithNegativeIntegers() {
int[] inputArray = {-1, -2, -3, -4, -5};
List<Integer> expected = Arrays.asList(1, 4, 9, 16, 25);
List<Integer> actual = SquareCalculator.calculateSquare(inputArray);
assertEquals(expected, actual);
}
@Test
public void testCalculateSquareWithZero() {
int[] inputArray = {0};
List<Integer> expected = Arrays.asList(0);
List<Integer> actual = SquareCalculator.calculateSquare(inputArray);
assertEquals(expected, actual);
}
@Test
public void testCalculateSquareWithMixedIntegers() {
int[] inputArray = {-3, 0, 3};
List<Integer> expected = Arrays.asList(9, 0, 9);
List<Integer> actual = SquareCalculator.calculateSquare(inputArray);
assertEquals(expected, actual);
}
@Test
public void testCalculateSquareWithEmptyArray() {
int[] inputArray = {};
List<Integer> expected = Arrays.asList();
List<Integer> actual = SquareCalculator.calculateSquare(inputArray);
assertEquals(expected, actual);
}
// ... Any other test cases you deem necessary ...
}