Skip to content

Commit a95a8ec

Browse files
recollate
1 parent 7594bc1 commit a95a8ec

File tree

2 files changed

+97
-1
lines changed

2 files changed

+97
-1
lines changed

collated/test/A0135812L.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,98 @@
185185

186186
}
187187
```
188+
###### \java\seedu\address\model\SortedObservableArrayListTest.java
189+
``` java
190+
public class SortedObservableArrayListTest<E extends Comparable<? super E>> {
191+
192+
@Rule
193+
public ExpectedException thrown = ExpectedException.none();
194+
195+
List<Integer> backing;
196+
List<Integer> dummy;
197+
SortedObservableArrayList<Integer> list;
198+
199+
@Before
200+
public void setup() {
201+
dummy = new ArrayList<>();
202+
backing = new ArrayList<>();
203+
list = new SortedObservableArrayList<>(FXCollections.observableList(backing));
204+
}
205+
206+
@Test
207+
public void transformationListGenerators_correctBackingList() {
208+
assertSame(list.sorted().getSource(), list);
209+
assertSame(list.filtered(i -> true).getSource(), list);
210+
}
211+
212+
@Test
213+
public void anyMethod_remainSorted() {
214+
215+
list.add(3);
216+
dummy.add(3);
217+
assertSorted(list, dummy);
218+
219+
list.addAll(2, 1);
220+
dummy.add(2);
221+
dummy.add(1);
222+
assertSorted(list, dummy);
223+
list.addAll(backing);
224+
dummy.addAll(backing);
225+
assertSorted(list, dummy);
226+
227+
228+
list.set(0, 2);
229+
dummy.set(0, 2);
230+
assertSorted(list, dummy);
231+
232+
list.setAll(new ArrayList<Integer>());
233+
dummy=new ArrayList<Integer>();
234+
assertSorted(list, dummy);
235+
list.setAll(1, 2);
236+
dummy.add(1);
237+
dummy.add(2);
238+
assertSorted(list, dummy);
239+
240+
list.remove(0, 1);
241+
dummy.subList(0, 1).clear();
242+
assertSorted(list, dummy);
243+
list.remove(null);
244+
dummy.remove(null);
245+
assertSorted(list, dummy);
246+
list.remove(0);
247+
dummy.remove(0);
248+
assertSorted(list, dummy);
249+
250+
list.removeAll(backing);
251+
dummy.removeAll(backing);
252+
assertSorted(list, dummy);
253+
254+
list.removeAll(1, 2);
255+
dummy.remove(new Integer(1));
256+
dummy.remove(new Integer(2));
257+
assertSorted(list, dummy);
258+
259+
list.retainAll(backing);
260+
dummy.retainAll(backing);
261+
assertSorted(list, dummy);
262+
263+
list.clear();
264+
dummy.clear();
265+
assertSorted(list, dummy);
266+
267+
}
268+
269+
@Test
270+
public void insertionWithIndexSpecified_disabled(){
271+
}
272+
273+
public void assertSorted(SortedObservableArrayList<Integer> list, List<Integer> dummy){
274+
assert list.size()==dummy.size();
275+
dummy.sort(null);
276+
for(int i=0; i<list.size();i++)
277+
{
278+
assert(list.get(i).equals(dummy.get(i)));
279+
}
280+
}
281+
}
282+
```

src/test/java/seedu/address/model/SortedObservableArrayListTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
import java.util.*;
1111

1212
import static org.junit.Assert.assertSame;
13-
import static seedu.address.testutil.TestUtil.assertThrows;
1413

14+
//@@author A0135812L
1515
public class SortedObservableArrayListTest<E extends Comparable<? super E>> {
1616

1717
@Rule
@@ -104,3 +104,4 @@ public void assertSorted(SortedObservableArrayList<Integer> list, List<Integer>
104104
}
105105
}
106106
}
107+
//@@author

0 commit comments

Comments
 (0)