OSDN Git Service

JUnit 4.12 対応
[jovsonz/Jovsonz.git] / src / test / java / jp / sourceforge / jovsonz / UnmodIteratorTest.java
1 /*
2  * License : The MIT License
3  * Copyright(c) 2009 olyutorskii
4  */
5
6 package jp.sourceforge.jovsonz;
7
8 import java.util.Iterator;
9 import java.util.LinkedList;
10 import java.util.List;
11 import java.util.NoSuchElementException;
12 import org.junit.After;
13 import org.junit.AfterClass;
14 import org.junit.Before;
15 import org.junit.BeforeClass;
16 import org.junit.Test;
17
18 import static org.junit.Assert.*;
19
20 /**
21  *
22  */
23 public class UnmodIteratorTest {
24
25     public UnmodIteratorTest() {
26     }
27
28     @BeforeClass
29     public static void setUpClass() throws Exception{
30     }
31
32     @AfterClass
33     public static void tearDownClass() throws Exception{
34     }
35
36     @Before
37     public void setUp() {
38     }
39
40     @After
41     public void tearDown() {
42     }
43
44     private void assert3ListAndIterator(List list, Iterator unmod){
45         assertEquals(3, list.size());
46
47         assertTrue(unmod.hasNext());
48         assertEquals(list.get(0), unmod.next());
49
50         assertTrue(unmod.hasNext());
51         assertEquals(list.get(1), unmod.next());
52
53         try{
54             unmod.remove();
55             fail();
56         }catch(UnsupportedOperationException e){
57             //NOTHING
58         }
59
60         assertTrue(unmod.hasNext());
61         assertEquals(list.get(2), unmod.next());
62
63         assertFalse(unmod.hasNext());
64
65         try{
66             unmod.next();
67             fail();
68         }catch(NoSuchElementException e){
69             //NOTHING
70         }
71
72         return;
73     }
74
75     /**
76      * Test of Constructor, of class UnmodIterator.
77      */
78     @Test
79     public void testConstructor(){
80         System.out.println("constructor");
81
82         List<String> list;
83         Iterator<String> it;
84
85         list = new LinkedList<String>();
86         list.add("A");
87         list.add("B");
88         list.add("C");
89
90         it = list.iterator();
91         UnmodIterator<String> unmod = new UnmodIterator<String>(it);
92
93         assert3ListAndIterator(list, unmod);
94
95         try{
96             unmod = new UnmodIterator<String>(null);
97             fail();
98         }catch(NullPointerException e){
99             //GOOD
100         }
101
102         return;
103     }
104
105     /**
106      * Test of wrapUnmod method, of class UnmodIterator.
107      */
108     @Test
109     public void testWrapUnmod_Iterator(){
110         System.out.println("wrapUnmod");
111
112         List<String> list;
113         Iterator<String> it;
114
115         list = new LinkedList<String>();
116         list.add("A");
117         list.add("B");
118         list.add("C");
119
120         it = list.iterator();
121         Iterator<String> unmod = UnmodIterator.wrapUnmod(it);
122
123         assert3ListAndIterator(list, unmod);
124
125         try{
126             unmod = UnmodIterator.wrapUnmod((Iterator<String>)null);
127             fail();
128         }catch(NullPointerException e){
129             //GOOD
130         }
131
132         return;
133     }
134
135     /**
136      * Test of wrapUnmod method, of class UnmodIterator.
137      */
138     @Test
139     public void testWrapUnmod_Iterable(){
140         System.out.println("wrapUnmod");
141
142         List<String> list;
143
144         list = new LinkedList<String>();
145         list.add("A");
146         list.add("B");
147         list.add("C");
148
149         Iterable<String> unmod = UnmodIterator.wrapUnmod(list);
150
151         assert3ListAndIterator(list, unmod.iterator());
152
153         try{
154             unmod = UnmodIterator.wrapUnmod((Iterable<String>)null);
155             fail();
156         }catch(NullPointerException e){
157             //GOOD
158         }
159
160         return;
161     }
162
163     /**
164      * Test of unmodIterator method, of class UnmodIterator.
165      */
166     @Test
167     public void testUnmodIterator(){
168         System.out.println("unmodIterator");
169
170         List<String> list;
171
172         list = new LinkedList<String>();
173         list.add("A");
174         list.add("B");
175         list.add("C");
176
177         Iterator<String> unmod = UnmodIterator.unmodIterator(list);
178
179         assert3ListAndIterator(list, unmod);
180
181         try{
182             unmod = UnmodIterator.unmodIterator(null);
183             fail();
184         }catch(NullPointerException e){
185             //GOOD
186         }
187
188         return;
189     }
190
191     /**
192      * Test of hasNext method, of class UnmodIterator.
193      */
194     @Test
195     public void testHasNext(){
196         System.out.println("hasNext");
197         return;
198     }
199
200     /**
201      * Test of next method, of class UnmodIterator.
202      */
203     @Test
204     public void testNext(){
205         System.out.println("next");
206         return;
207     }
208
209     /**
210      * Test of remove method, of class UnmodIterator.
211      */
212     @Test
213     public void testRemove(){
214         System.out.println("remove");
215         return;
216     }
217
218 }