-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDynArrayJUnitTest.java
More file actions
42 lines (37 loc) · 1.02 KB
/
DynArrayJUnitTest.java
File metadata and controls
42 lines (37 loc) · 1.02 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
import org.junit.Test;
import static org.junit.Assert.*;
public class DynArrayTest {
@Test
public void insert() {
DynArray<Integer> list = new DynArray<>(Integer.class);
assertEquals(0,list.count);
list.insert(77,0);
assertEquals(1,list.count);
assertEquals(16,list.capacity);
for (int i =0; i < 1125; i++){
list.append(i);
}
assertEquals(1126,list.count);
assertEquals(2048,list.capacity);
for (int i = list.count-1; i > 100; i--){
list.remove(i);
}
}
@Test
public void remove() {
DynArray<Integer> list = new DynArray<>(Integer.class);
for (int i = 0; i <1048; i++){
list.append(i);
}
list.remove(999);
assertEquals(2048,list.capacity);
for (int i = list.count-1; i >47; i--){
list.remove(i);
}
assertEquals(79,list.capacity);
for (int i =list.count-1; i > 8; i--){
list.remove(i);
}
assertEquals(16,list.capacity);
}
}