0
|
1 package jp.ac.u_ryukyu.ie.cr.data.list;
|
|
2
|
|
3 import jp.ac.u_ryukyu.ie.cr.jungle.data.list.List;
|
|
4 import junit.framework.Assert;
|
|
5 import org.junit.Test;
|
|
6
|
|
7 import java.util.Iterator;
|
|
8
|
|
9 /**
|
|
10 * Created by e115731 on 15/05/17.
|
|
11 */
|
|
12 public class listIterator {
|
|
13 @Test
|
|
14 public void listIteratorTest() {
|
|
15 List<Integer> list = new List<Integer>();
|
|
16 for (int count = 1; count < 10; count++) {
|
|
17 list = list.addLast(count);
|
|
18 }
|
|
19 Iterator<Integer> iterator = list.iterator();
|
|
20 for (int count = 1; count < 10; count++) {
|
|
21 Assert.assertTrue(iterator.hasNext());
|
|
22 int attribute = iterator.next();
|
|
23 Assert.assertEquals(attribute, count);
|
|
24 }
|
|
25
|
|
26 iterator = list.reverseIterator();
|
|
27 for (int count = 9; count > 0; count--) {
|
|
28 Assert.assertTrue(iterator.hasNext());
|
|
29 int attribute = iterator.next();
|
|
30 Assert.assertEquals(attribute, count);
|
|
31 }
|
|
32 }
|
|
33 }
|