Debian Codegraph @

eclipse-collections-code-generator/src/main/resources/test/collection/mutable/synchronizedPrimitiveIterableTest.stg

raw
1 import "copyright.stg"
2 import "primitiveEquals.stg"
3 import "primitiveHashCode.stg"
4 import "primitiveLiteral.stg"
5
6 isTest() ::= "true"
7
8 skipBoolean() ::= "true"
9
10 targetPath() ::= "org/eclipse/collections/impl/collection/mutable/primitive"
11
12 fileName(primitive) ::= "Synchronized<primitive.name>IterableTest"
13
14 class(primitive) ::= <<
15 <body(primitive.type, primitive.wrapperName, primitive.name)>
16 >>
17
18 body(type, wrapperName, name) ::= <<
19 <copyright()>
20
21 package org.eclipse.collections.impl.collection.mutable.primitive;
22
23 import java.util.NoSuchElementException;
24
25 import org.eclipse.collections.api.<name>Iterable;
26 import org.eclipse.collections.api.RichIterable;
27 import org.eclipse.collections.api.iterator.<name>Iterator;
28 import org.eclipse.collections.impl.list.mutable.FastList;
29 import org.eclipse.collections.impl.list.mutable.primitive.<name>ArrayList;
30 import org.eclipse.collections.impl.primitive.Synchronized<name>Iterable;
31 import org.eclipse.collections.impl.test.Verify;
32 import org.junit.Assert;
33 import org.junit.Test;
34
35 /**
36 * JUnit test for {@link Synchronized<name>Iterable}s
37 * This file was automatically generated from template file synchronizedPrimitiveIterableTest.stg.
38 */
39 public class Synchronized<name>IterableTest extends Abstract<name>IterableTestCase
40 {
41 @Override
42 protected <name>Iterable classUnderTest()
43 {
44 return Synchronized<name>Iterable.of(<name>ArrayList.newListWith(<["1", "2", "3"]:(literal.(type))(); separator=", ">));
45 }
46
47 @Override
48 protected <name>Iterable newWith(<type>... elements)
49 {
50 return Synchronized<name>Iterable.of(<name>ArrayList.newListWith(elements));
51 }
52
53 @Override
54 protected <name>Iterable newMutableCollectionWith(<type>... elements)
55 {
56 return <name>ArrayList.newListWith(elements);
57 }
58
59 @Override
60 protected RichIterable\<<wrapperName>\> newObjectCollectionWith(<wrapperName>... elements)
61 {
62 return FastList.newListWith(elements);
63 }
64
65 @Test(expected = IllegalArgumentException.class)
66 public void null_iterable_throws()
67 {
68 Synchronized<name>Iterable.of(null);
69 }
70
71 @Override
72 @Test
73 public void <type>Iterator()
74 {
75 <name>Iterable iterable = this.newWith(<["0", "1", "2", "3"]:(literal.(type))(); separator=", ">);
76 <name>ArrayList list = <name>ArrayList.newListWith(<["0", "1", "2", "3"]:(literal.(type))(); separator=", ">);
77 <name>Iterator iterator = iterable.<type>Iterator();
78 for (int i = 0; i \< 4; i++)
79 {
80 Assert.assertTrue(iterator.hasNext());
81 Assert.assertTrue(list.remove(iterator.next()));
82 }
83 Verify.assertEmpty(list);
84 Assert.assertFalse(iterator.hasNext());
85
86 Assert.assertThrows(NoSuchElementException.class, iterator::next);
87 }
88
89 @Override
90 @Test
91 public void testEquals()
92 {
93 //Testing equals() is not applicable.
94 }
95
96 <if(primitive.floatingPoint)><NaNEqualsTests()><endif>
97 @Override
98 public void testHashCode()
99 {
100 //Testing hashCode() is not applicable.
101 }
102
103 @Override
104 public void newCollection()
105 {
106 //Testing newCollection() is not applicable.
107 }
108 }
109
110 >>
111
112 NaNEqualsTests() ::= <<
113 @Override
114 @Test
115 public void testEquals_NaN()
116 {
117 //Testing equals() is not applicable.
118 }
119
120 >>