-
Notifications
You must be signed in to change notification settings - Fork 599
/
unmodifiablePrimitiveSetTest.stg
234 lines (197 loc) · 6.77 KB
/
unmodifiablePrimitiveSetTest.stg
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
import "copyright.stg"
import "primitiveHashCode.stg"
import "primitiveLiteral.stg"
isTest() ::= "true"
targetPath() ::= "org/eclipse/collections/impl/set/mutable/primitive"
fileName(primitive) ::= "Unmodifiable<primitive.name>SetTest"
class(primitive) ::= <<
<body(primitive.type, primitive.wrapperName, primitive.name)>
>>
body(type, wrapperName, name) ::= <<
<copyright()>
package org.eclipse.collections.impl.set.mutable.primitive;
import java.util.NoSuchElementException;
import org.eclipse.collections.api.iterator.<name>Iterator;
import org.eclipse.collections.api.iterator.Mutable<name>Iterator;
import org.eclipse.collections.impl.test.Verify;
import org.junit.Assert;
import org.junit.Test;
/**
* JUnit test for {@link Unmodifiable<name>Set}.
* This file was automatically generated from template file unmodifiablePrimitiveSetTest.stg.
*/
public class Unmodifiable<name>SetTest extends Abstract<name>SetTestCase
{
@Override
protected final Unmodifiable<name>Set classUnderTest()
{
return new Unmodifiable<name>Set(<name>HashSet.newSetWith(<["1", "2", "3"]:(literal.(type))(); separator=", ">));
}
@Override
protected Unmodifiable<name>Set newWith(<type>... elements)
{
return new Unmodifiable<name>Set(<name>HashSet.newSetWith(elements));
}
@Override
@Test(expected = UnsupportedOperationException.class)
public void clear()
{
this.classUnderTest().clear();
}
@Override
@Test(expected = UnsupportedOperationException.class)
public void add()
{
this.newWith().add(<(literal.(type))("1")>);
}
<if(primitive.floatingPoint)><NaNTests()><endif>
@Override
@Test(expected = UnsupportedOperationException.class)
public void addAllArray()
{
this.classUnderTest().addAll();
}
@Override
@Test(expected = UnsupportedOperationException.class)
public void addAllIterable()
{
this.classUnderTest().addAll(this.newMutableCollectionWith());
}
@Override
@Test(expected = UnsupportedOperationException.class)
public void remove()
{
this.classUnderTest().remove(<(literal.(type))("1")>);
}
@Override
@Test(expected = UnsupportedOperationException.class)
public void removeAll()
{
this.classUnderTest().removeAll();
}
@Override
@Test(expected = UnsupportedOperationException.class)
public void removeAll_iterable()
{
this.classUnderTest().removeAll(this.newMutableCollectionWith());
}
@Override
@Test(expected = UnsupportedOperationException.class)
public void retainAll()
{
this.classUnderTest().retainAll();
}
@Override
@Test(expected = UnsupportedOperationException.class)
public void retainAll_iterable()
{
this.classUnderTest().retainAll(this.newMutableCollectionWith());
}
@Override
@Test(expected = UnsupportedOperationException.class)
public void with()
{
this.newWith().with(<["1"]:(literal.(type))(); separator=", ">);
}
@Override
@Test(expected = UnsupportedOperationException.class)
public void withAll()
{
this.newWith().withAll(this.newMutableCollectionWith(<(literal.(type))("1")>));
}
@Override
@Test(expected = UnsupportedOperationException.class)
public void without()
{
this.newWith(<["1", "2", "3", "4", "5"]:(literal.(type))(); separator=", ">).without(<(literal.(type))("9")>);
}
@Override
@Test(expected = UnsupportedOperationException.class)
public void withoutAll()
{
this.newWith(<["1", "2", "3", "4", "5"]:(literal.(type))(); separator=", ">).withoutAll(this.newMutableCollectionWith(<["8", "9"]:(literal.(type))(); separator=", ">));
}
@Override
@Test
public void contains()
{
Unmodifiable<name>Set set = this.newWith(<["14", "2", "30", "31", "32", "35", "0", "1"]:(literal.(type))(); separator=", ">);
Assert.assertFalse(set.contains(<(literal.(type))("29")>));
Assert.assertFalse(set.contains(<(literal.(type))("49")>));
<type>[] numbers = {<["14", "2", "30", "31", "32", "35", "0", "1"]:(literal.(type))(); separator=", ">};
for (<type> number : numbers)
{
Assert.assertTrue(set.contains(number));
}
Assert.assertFalse(set.contains(<(literal.(type))("-1")>));
Assert.assertFalse(set.contains(<(literal.(type))("29")>));
Assert.assertFalse(set.contains(<(literal.(type))("49")>));
Unmodifiable<name>Set set1 = this.newWith(<["0", "1", "1", "2", "2", "2"]:(literal.(type))(); separator=", ">);
Assert.assertTrue(set1.contains(<(literal.(type))("0")>));
Assert.assertTrue(set1.contains(<(literal.(type))("1")>));
Assert.assertTrue(set1.contains(<(literal.(type))("2")>));
Assert.assertFalse(set1.contains(<(literal.(type))("3")>));
}
@Override
@Test(expected = NoSuchElementException.class)
public void <type>Iterator_throws_non_empty_collection()
{
Unmodifiable<name>Set set = this.newWith(<["1", "2", "3"]:(literal.(type))(); separator=", ">);
<name>Iterator iterator = set.<type>Iterator();
while (iterator.hasNext())
{
iterator.next();
}
iterator.next();
}
@Override
@Test
public void asUnmodifiable()
{
Unmodifiable<name>Set set = this.classUnderTest();
super.asUnmodifiable();
Assert.assertSame(set, set.asUnmodifiable());
Assert.assertEquals(set, set.asUnmodifiable());
}
@Override
public void <type>Iterator_with_remove()
{
Mutable<name>Iterator iterator = this.classUnderTest().<type>Iterator();
Assert.assertTrue(iterator.hasNext());
iterator.next();
Verify.assertThrows(UnsupportedOperationException.class, iterator::remove);
}
@Override
public void <type>Iterator_throws_for_remove_before_next()
{
Mutable<name>Iterator iterator = this.classUnderTest().<type>Iterator();
Assert.assertTrue(iterator.hasNext());
Verify.assertThrows(UnsupportedOperationException.class, iterator::remove);
}
@Override
public void <type>Iterator_throws_for_consecutive_remove()
{
// Not applicable for Unmodifiable
}
}
>>
NaNTests() ::= <<
@Override
@Test(expected = UnsupportedOperationException.class)
public void add_NaN()
{
this.newWith(<wrapperName>.NaN).add(<wrapperName>.NaN);
}
@Override
@Test(expected = UnsupportedOperationException.class)
public void add_POSITIVE_INFINITY()
{
this.newWith(<wrapperName>.POSITIVE_INFINITY).add(<wrapperName>.POSITIVE_INFINITY);
}
@Override
@Test(expected = UnsupportedOperationException.class)
public void add_NEGATIVE_INFINITY()
{
this.newWith(<wrapperName>.NEGATIVE_INFINITY).add(<wrapperName>.NEGATIVE_INFINITY);
}
>>