forked from ucsd-cse15l-w23/lab3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ArrayTests.java
46 lines (37 loc) · 1.08 KB
/
ArrayTests.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
import static org.junit.Assert.*;
import java.beans.Transient;
import org.junit.*;
public class ArrayTests {
@Test
public void testReverseInPlace() {
int[] input1 = { 3 };
ArrayExamples.reverseInPlace(input1);
assertArrayEquals(new int[]{ 3 }, input1);
}
@Test
public void testReversed() {
int[] input1 = { };
assertArrayEquals(new int[]{ }, ArrayExamples.reversed(input1));
}
@Test
public void testReverseInPlace2() {
int[] input2 = {1, 2, 3, 4, 5};
ArrayExamples.reverseInPlace(input2);
assertArrayEquals(new int[]{5, 4, 3, 2, 1}, input2);
}
@Test
public void testReversed2() {
int[] input2 = {1, 2, 3, 4, 5};
assertArrayEquals(new int[]{5, 4, 3, 2, 1}, ArrayExamples.reversed(input2));
}
@Test
public void testAverageWithoutLowest() {
double[] arr = {1.0, 1.0, 3.0, 4.0, 5.0};
assertEquals(4.0, ArrayExamples.averageWithoutLowest(arr), 0);
}
@Test
public void testAverageWithoutLowest2() {
double[] input = {5.0, 1.0, 1.0, 1.0, 5.0};
assertEquals(5.0, ArrayExamples.averageWithoutLowest(input), 0);
}
}