-
Notifications
You must be signed in to change notification settings - Fork 614
/
abstractPrimitiveSetTestCase.stg
477 lines (424 loc) · 25.9 KB
/
abstractPrimitiveSetTestCase.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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
import "copyright.stg"
import "primitiveLiteral.stg"
isTest() ::= "true"
targetPath() ::= "org/eclipse/collections/impl/set/mutable/primitive"
fileName(primitive) ::= "Abstract<primitive.name>SetTestCase"
class(primitive) ::= <<
<body(primitive.type, primitive.wrapperName, primitive.name)>
>>
body(type, wrapperName, name) ::= <<
<copyright()>
package org.eclipse.collections.impl.set.mutable.primitive;
<if(primitive.floatingPoint)>import java.util.HashSet;<endif>
import java.util.NoSuchElementException;
<if(primitive.floatingPoint)>import java.util.Set;<endif>
import org.eclipse.collections.api.Lazy<name>Iterable;
import org.eclipse.collections.api.iterator.<name>Iterator;
import org.eclipse.collections.api.set.MutableSet;
import org.eclipse.collections.api.set.primitive.Mutable<name>Set;
import org.eclipse.collections.impl.bag.mutable.primitive.<name>HashBag;
import org.eclipse.collections.impl.block.factory.primitive.<name>Predicates;
import org.eclipse.collections.impl.collection.mutable.primitive.AbstractMutable<name>CollectionTestCase;
import org.eclipse.collections.impl.factory.primitive.<name>Sets;
import org.eclipse.collections.impl.list.mutable.primitive.<name>ArrayList;
import org.eclipse.collections.impl.set.mutable.UnifiedSet;
import org.eclipse.collections.impl.test.Verify;
import org.junit.Assert;
import org.junit.Test;
/**
* Abstract JUnit test for {@link Mutable<name>Set}.
* This file was automatically generated from template file abstractPrimitiveSetTestCase.stg.
*/
public abstract class Abstract<name>SetTestCase extends AbstractMutable<name>CollectionTestCase
{
protected static <name>ArrayList generateCollisions1()
{
<name>ArrayList collisions = new <name>ArrayList();
<name>HashSet set = new <name>HashSet();
for (<type> i = <(literal.(type))("32")>; collisions.size() \<= 10; i++)
{
if (set.spreadAndMask(i) == set.spreadAndMask(<(literal.(type))("32")>))
{
collisions.add(i);
}
}
return collisions;
}
private static <name>ArrayList generateNonCollisions()
{
<name>ArrayList collisions = new <name>ArrayList();
<name>HashSet set = new <name>HashSet();
for (<type> i = <(literal.(type))("32")>; collisions.size() \<= 10; i++)
{
if (set.spreadAndMask(i) != set.spreadAndMask(<(literal.(type))("32")>))
{
collisions.add(i);
}
}
return collisions;
}
@Override
protected abstract Mutable<name>Set classUnderTest();
@Override
protected abstract Mutable<name>Set newWith(<type>... elements);
@Override
protected Mutable<name>Set newMutableCollectionWith(<type>... elements)
{
return <name>HashSet.newSetWith(elements);
}
@Override
protected MutableSet\<<wrapperName>\> newObjectCollectionWith(<wrapperName>... elements)
{
return UnifiedSet.newSetWith(elements);
}
@Override
@Test
public void size()
{
super.size();
Verify.assertSize(5, this.newWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1)));
}
@Override
@Test
public void isEmpty()
{
super.isEmpty();
Assert.assertFalse(this.newWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1)).isEmpty());
}
@Override
@Test
public void notEmpty()
{
Assert.assertTrue(this.newWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1)).notEmpty());
}
@Override
@Test
public void clear()
{
super.clear();
Mutable<name>Set set = this.newWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1));
set.clear();
Verify.assertSize(0, set);
Assert.assertFalse(set.contains(<(literal.(type))("0")>));
Assert.assertFalse(set.contains(<(literal.(type))("31")>));
Assert.assertFalse(set.contains(<(literal.(type))("1")>));
Assert.assertFalse(set.contains(Abstract<name>SetTestCase.generateCollisions1().getFirst()));
Assert.assertFalse(set.contains(Abstract<name>SetTestCase.generateCollisions1().get(1)));
}
@Override
@Test
public void add()
{
super.add();
Mutable<name>Set set = this.newWith();
Assert.assertTrue(set.add(<(literal.(type))("14")>));
Assert.assertFalse(set.add(<(literal.(type))("14")>));
Assert.assertTrue(set.add(<(literal.(type))("2")>));
Assert.assertFalse(set.add(<(literal.(type))("2")>));
Assert.assertTrue(set.add(<(literal.(type))("35")>));
Assert.assertFalse(set.add(<(literal.(type))("35")>));
Assert.assertTrue(set.add(<(literal.(type))("31")>));
Assert.assertFalse(set.add(<(literal.(type))("31")>));
Assert.assertTrue(set.add(<(literal.(type))("32")>));
Assert.assertFalse(set.add(<(literal.(type))("32")>));
Assert.assertTrue(set.add(<(literal.(type))("0")>));
Assert.assertFalse(set.add(<(literal.(type))("0")>));
Assert.assertTrue(set.add(<(literal.(type))("1")>));
Assert.assertFalse(set.add(<(literal.(type))("1")>));
}
<if(primitive.floatingPoint)><\\>
<NaNTests("NaN")>
<NaNTests("POSITIVE_INFINITY")>
<NaNTests("NEGATIVE_INFINITY")>
<endif>
@Override
@Test
public void addAllIterable()
{
super.addAllIterable();
Mutable<name>Set set = this.newWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1));
Assert.assertFalse(set.addAll(new <name>ArrayList()));
Assert.assertFalse(set.addAll(<name>ArrayList.newListWith(<(literal.(type))("31")>, Abstract<name>SetTestCase.generateCollisions1().get(0), Abstract<name>SetTestCase.generateCollisions1().get(1))));
Assert.assertEquals(<name>HashSet.newSetWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1)), set);
Assert.assertTrue(set.addAll(<name>HashSet.newSetWith(<["0", "1", "2", "30"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(4))));
Assert.assertEquals(<name>HashSet.newSetWith(<["0", "1", "2", "30", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1), Abstract<name>SetTestCase.generateCollisions1().get(4)), set);
Assert.assertTrue(set.addAll(<name>HashSet.newSetWith(<(literal.(type))("5")>)));
Assert.assertEquals(<name>HashSet.newSetWith(<["0", "1", "2", "5", "30", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1), Abstract<name>SetTestCase.generateCollisions1().get(4)), set);
Assert.assertTrue(set.addAll(<name>HashSet.newSetWith(Abstract<name>SetTestCase.generateCollisions1().get(5))));
Assert.assertEquals(<name>HashSet.newSetWith(<["0", "1", "2", "5", "30", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1), Abstract<name>SetTestCase.generateCollisions1().get(4), Abstract<name>SetTestCase.generateCollisions1().get(5)), set);
<name>HashSet set1 = new <name>HashSet();
Assert.assertTrue(set1.addAll(<["2", "35"]:(literal.(type))(); separator=", ">));
Assert.assertEquals(<name>HashSet.newSetWith(<["2", "35"]:(literal.(type))(); separator=", ">), set1);
}
@Test
public void testOfAllFactory()
{
Assert.assertEquals(
<name>HashSet.newSetWith(<["0", "1", "2", "5", "30", "31"]:(literal.(type))(); separator=", ">),
<name>Sets.mutable.ofAll(<name>HashBag.newBagWith(<["0", "1", "2", "5", "30", "31", "0", "1", "2", "5", "30", "31"]:(literal.(type))(); separator=", ">)));
}
@Override
@Test
public void remove()
{
super.remove();
Mutable<name>Set set = this.newWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1));
Assert.assertFalse(this.newWith().remove(<(literal.(type))("15")>));
Assert.assertFalse(set.remove(<(literal.(type))("15")>));
Assert.assertTrue(set.remove(<(literal.(type))("0")>));
Assert.assertEquals(<name>HashSet.newSetWith(<["1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1)), set);
Assert.assertFalse(set.remove(Abstract<name>SetTestCase.generateNonCollisions().getFirst()));
Assert.assertFalse(set.remove(Abstract<name>SetTestCase.generateCollisions1().get(3)));
Assert.assertTrue(set.remove(Abstract<name>SetTestCase.generateCollisions1().get(1)));
Assert.assertEquals(<name>HashSet.newSetWith(<["1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst()), set);
Assert.assertTrue(set.remove(Abstract<name>SetTestCase.generateCollisions1().getFirst()));
Assert.assertEquals(<name>HashSet.newSetWith(<["1", "31"]:(literal.(type))(); separator=", ">), set);
Assert.assertTrue(set.remove(<(literal.(type))("31")>));
Assert.assertEquals(<name>HashSet.newSetWith(<(literal.(type))("1")>), set);
Assert.assertTrue(set.remove(<(literal.(type))("1")>));
Assert.assertEquals(<name>HashSet.newSetWith(), set);
}
@Override
@Test
public void removeAll()
{
super.removeAll();
Mutable<name>Set set = this.newWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1));
Assert.assertFalse(set.removeAll());
Assert.assertFalse(set.removeAll(<(literal.(type))("15")>, Abstract<name>SetTestCase.generateCollisions1().get(2), Abstract<name>SetTestCase.generateCollisions1().get(3)));
Assert.assertEquals(<name>HashSet.newSetWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1)), set);
Assert.assertTrue(set.removeAll(<["0", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().get(3)));
Assert.assertEquals(<name>HashSet.newSetWith(<(literal.(type))("1")>, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1)), set);
Assert.assertTrue(set.removeAll(<(literal.(type))("1")>, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1)));
Assert.assertEquals(new <name>HashSet(), set);
Assert.assertFalse(set.removeAll(<(literal.(type))("1")>));
Assert.assertEquals(new <name>HashSet(), set);
}
@Override
@Test
public void removeAll_iterable()
{
super.removeAll_iterable();
Mutable<name>Set set = this.newWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1));
Assert.assertFalse(set.removeAll(new <name>ArrayList()));
Assert.assertFalse(set.removeAll(<name>ArrayList.newListWith(<(literal.(type))("15")>, Abstract<name>SetTestCase.generateCollisions1().get(2), Abstract<name>SetTestCase.generateCollisions1().get(3))));
Assert.assertEquals(<name>HashSet.newSetWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1)), set);
Assert.assertTrue(set.removeAll(<name>HashSet.newSetWith(<["0", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().get(4))));
Assert.assertEquals(<name>HashSet.newSetWith(<(literal.(type))("1")>, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1)), set);
Assert.assertTrue(set.removeAll(<name>HashSet.newSetWith(<(literal.(type))("1")>, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1))));
Assert.assertEquals(new <name>HashSet(), set);
Assert.assertFalse(set.removeAll(<name>HashSet.newSetWith(<(literal.(type))("1")>)));
Assert.assertEquals(new <name>HashSet(), set);
}
@Override
@Test
public void retainAll()
{
super.retainAll();
Mutable<name>Set set = this.newWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1));
Assert.assertFalse(set.retainAll(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1)));
Assert.assertEquals(<name>HashSet.newSetWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1)), set);
Assert.assertTrue(set.retainAll(<["0", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().get(4), Abstract<name>SetTestCase.generateCollisions1().get(1)));
Assert.assertEquals(<name>HashSet.newSetWith(<["0", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().get(1)), set);
Assert.assertTrue(set.retainAll(<(literal.(type))("1")>, Abstract<name>SetTestCase.generateCollisions1().getFirst()));
Assert.assertEquals(new <name>HashSet(), set);
Assert.assertFalse(set.retainAll(<(literal.(type))("1")>));
Assert.assertEquals(new <name>HashSet(), set);
}
@Override
@Test
public void retainAll_iterable()
{
super.retainAll_iterable();
Mutable<name>Set set = this.newWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1));
Assert.assertFalse(set.retainAll(<name>HashSet.newSetWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1))));
Assert.assertEquals(<name>HashSet.newSetWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1)), set);
Assert.assertTrue(set.retainAll(<name>HashSet.newSetWith(<["0", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().get(4), Abstract<name>SetTestCase.generateCollisions1().get(1))));
Assert.assertEquals(<name>HashSet.newSetWith(<["0", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().get(1)), set);
Assert.assertTrue(set.retainAll(<name>HashSet.newSetWith(<(literal.(type))("1")>, Abstract<name>SetTestCase.generateCollisions1().getFirst())));
Assert.assertEquals(new <name>HashSet(), set);
Assert.assertFalse(set.retainAll(<name>HashSet.newSetWith(<(literal.(type))("1")>)));
Assert.assertEquals(new <name>HashSet(), set);
}
@Override
@Test
public void <type>Iterator()
{
MutableSet\<<wrapperName>\> expected = UnifiedSet.newSetWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1));
MutableSet\<<wrapperName>\> actual = UnifiedSet.newSet();
Mutable<name>Set set = this.newWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1));
<name>Iterator iterator = set.<type>Iterator();
Assert.assertTrue(iterator.hasNext());
actual.add(iterator.next());
Assert.assertTrue(iterator.hasNext());
actual.add(iterator.next());
Assert.assertTrue(iterator.hasNext());
actual.add(iterator.next());
Assert.assertTrue(iterator.hasNext());
actual.add(iterator.next());
Assert.assertTrue(iterator.hasNext());
actual.add(iterator.next());
Assert.assertFalse(iterator.hasNext());
Assert.assertEquals(expected, actual);
Verify.assertThrows(NoSuchElementException.class, iterator::next);
}
@Override
@Test(expected = NoSuchElementException.class)
public void <type>Iterator_throws()
{
Mutable<name>Set set = this.newWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1));
<name>Iterator iterator = set.<type>Iterator();
while (iterator.hasNext())
{
iterator.next();
}
iterator.next();
}
@Override
@Test
public void injectInto()
{
super.injectInto();
Mutable<name>Set set = this.newWith(<["0", "2", "31"]:(literal.(type))(); separator=", ">);
<wrapperName> sum = set.injectInto(<wrapperName>.valueOf(<(literal.(type))("0")>), (<wrapperName> result, <type> value) -> <wrapperName>.valueOf((<type>) (result + value)));
Assert.assertEquals(<wrapperName>.valueOf(<(literal.(type))("33")>), sum);
}
@Override
@Test
public void forEach()
{
super.forEach();
<wideType.(type)>[] sum = new <wideType.(type)>[1];
Mutable<name>Set set = this.newWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1));
set.forEach((<type> each) -> sum[0] += each);
Assert.assertEquals(32L + Abstract<name>SetTestCase.generateCollisions1().getFirst() + Abstract<name>SetTestCase.generateCollisions1().get(1), sum[0]<(delta.(type))>);
}
@Override
@Test
public void count()
{
super.count();
Mutable<name>Set set = this.newWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1));
Assert.assertEquals(4L, set.count(<name>Predicates.greaterThan(<(literal.(type))("0")>)));
Assert.assertEquals(3L, set.count(<name>Predicates.lessThan(<(literal.(type))("32")>)));
Assert.assertEquals(1L, set.count(<name>Predicates.greaterThan(<(literal.(type))("32")>)));
}
@Override
@Test
public void select()
{
super.select();
Mutable<name>Set set = this.newWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1));
Verify.assertSize(3, set.select(<name>Predicates.lessThan(<(literal.(type))("32")>)));
Verify.assertSize(4, set.select(<name>Predicates.greaterThan(<(literal.(type))("0")>)));
}
@Override
@Test
public void reject()
{
super.reject();
Mutable<name>Set set = this.newWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1));
Verify.assertSize(1, set.reject(<name>Predicates.greaterThan(<(literal.(type))("0")>)));
Verify.assertSize(2, set.reject(<name>Predicates.lessThan(<(literal.(type))("32")>)));
}
@Override
@Test
public void detectIfNone()
{
super.detectIfNone();
Mutable<name>Set set = this.newWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1));
Assert.assertEquals(<(literal.(type))("0")>, set.detectIfNone(<name>Predicates.lessThan(<(literal.(type))("1")>), <(literal.(type))("9")>)<(delta.(type))>);
Assert.assertEquals(Abstract<name>SetTestCase.generateCollisions1().get(1), set.detectIfNone(<name>Predicates.greaterThan(Abstract<name>SetTestCase.generateCollisions1().getFirst()), <(literal.(type))("9")>)<(delta.(type))>);
Assert.assertEquals(<(literal.(type))("9")>, set.detectIfNone(<name>Predicates.greaterThan(Abstract<name>SetTestCase.generateCollisions1().get(1)), <(literal.(type))("9")>)<(delta.(type))>);
}
@Override
@Test
public void collect()
{
super.collect();
Mutable<name>Set set = this.newWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1));
Assert.assertEquals(
UnifiedSet.newSetWith(<["-1", "0", "30"]:(literal.(type))(); separator=", ">, <(castIntToNarrowTypeWithParens.(type))({Abstract<name>SetTestCase.generateCollisions1().getFirst() - 1})>, <(castIntToNarrowTypeWithParens.(type))({Abstract<name>SetTestCase.generateCollisions1().get(1) - 1})>),
set.collect((<type> byteParameter) -> <(castIntToNarrowTypeWithParens.(type))("byteParameter - 1")>));
}
@Override
@Test
public void toSortedArray()
{
super.toSortedArray();
Mutable<name>Set set = this.newWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1));
Assert.assertArrayEquals(new <type>[]{<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1)}, set.toSortedArray()<(delta.(type))>);
}
@Override
@Test
public void testEquals()
{
super.testEquals();
Mutable<name>Set set1 = this.newWith(<["1", "31", "32"]:(literal.(type))(); separator=", ">);
Mutable<name>Set set2 = this.newWith(<["32", "31", "1"]:(literal.(type))(); separator=", ">);
Mutable<name>Set set3 = this.newWith(<["32", "32", "31", "1"]:(literal.(type))(); separator=", ">);
Mutable<name>Set set4 = this.newWith(<["32", "32", "31", "1", "1"]:(literal.(type))(); separator=", ">);
Verify.assertEqualsAndHashCode(set1, set2);
Verify.assertEqualsAndHashCode(set1, set3);
Verify.assertEqualsAndHashCode(set1, set4);
Verify.assertEqualsAndHashCode(set2, set3);
Verify.assertEqualsAndHashCode(set2, set4);
}
@Override
@Test
public void testHashCode()
{
super.testEquals();
Mutable<name>Set set1 = this.newWith(<["1", "31", "32"]:(literal.(type))(); separator=", ">);
Mutable<name>Set set2 = this.newWith(<["32", "31", "1"]:(literal.(type))(); separator=", ">);
Assert.assertEquals(set1.hashCode(), set2.hashCode());
}
@Override
@Test
public void toBag()
{
Assert.assertEquals(<name>HashBag.newBagWith(<["1", "2", "3"]:(literal.(type))(); separator=", ">), this.classUnderTest().toBag());
Assert.assertEquals(<name>HashBag.newBagWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">), this.newWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">).toBag());
Assert.assertEquals(<name>HashBag.newBagWith(<["0", "1", "31", "32"]:(literal.(type))(); separator=", ">), this.newWith(<["0", "1", "31", "32"]:(literal.(type))(); separator=", ">).toBag());
}
@Override
@Test
public void asLazy()
{
super.asLazy();
Mutable<name>Set set = this.newWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1));
Assert.assertEquals(set.toSet(), set.asLazy().toSet());
Verify.assertInstanceOf(Lazy<name>Iterable.class, set.asLazy());
}
@Override
@Test
public void asSynchronized()
{
super.asSynchronized();
Mutable<name>Set set = this.newWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1));
Verify.assertInstanceOf(Synchronized<name>Set.class, set.asSynchronized());
Assert.assertEquals(new Synchronized<name>Set(set), set.asSynchronized());
}
@Override
@Test
public void asUnmodifiable()
{
super.asUnmodifiable();
Mutable<name>Set set = this.newWith(<["0", "1", "31"]:(literal.(type))(); separator=", ">, Abstract<name>SetTestCase.generateCollisions1().getFirst(), Abstract<name>SetTestCase.generateCollisions1().get(1));
Verify.assertInstanceOf(Unmodifiable<name>Set.class, set.asUnmodifiable());
Assert.assertEquals(new Unmodifiable<name>Set(set), set.asUnmodifiable());
}
}
>>
NaNTests(key) ::= <<
@Test
public void add_<key>()
{
Mutable<name>Set set = this.newWith(<wrapperName>.<key>);
Set\<<wrapperName>\> hashSet = new HashSet\<>();
Assert.assertTrue(hashSet.add(<wrapperName>.<key>));
Assert.assertFalse(hashSet.add(<wrapperName>.<key>));
Assert.assertFalse(set.add(<wrapperName>.<key>));
Verify.assertSize(hashSet.size(), set);
}
>>