-
Notifications
You must be signed in to change notification settings - Fork 587
/
primitiveListsTest.stg
203 lines (183 loc) · 16.3 KB
/
primitiveListsTest.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
import "copyright.stg"
import "primitiveHashCode.stg"
import "primitiveLiteral.stg"
isTest() ::= "true"
targetPath() ::= "org/eclipse/collections/impl/factory/primitive"
fileName(primitive) ::= "<primitive.name>ListsTest"
class(primitive) ::= <<
<body(primitive.type, primitive.wrapperName, primitive.name)>
>>
body(type, wrapperName, name) ::= <<
<copyright()>
package org.eclipse.collections.impl.factory.primitive;
import org.eclipse.collections.api.factory.list.primitive.Immutable<name>ListFactory;
import org.eclipse.collections.api.list.primitive.Immutable<name>List;
import org.eclipse.collections.api.list.primitive.Mutable<name>List;
import org.eclipse.collections.impl.factory.Lists;
import org.eclipse.collections.impl.list.mutable.primitive.<name>ArrayList;
import org.eclipse.collections.impl.test.Verify;
import org.junit.Assert;
import org.junit.Test;
/**
* JUnit test for {@link <name>Lists}.
* This file was automatically generated from template file primitiveListsTest.stg.
*/
public class <name>ListsTest
{
@Test
public void immutables()
{
Immutable<name>ListFactory listFactory = <name>Lists.immutable;
Assert.assertEquals(new <name>ArrayList(), listFactory.of());
Verify.assertInstanceOf(Immutable<name>List.class, listFactory.of());
Assert.assertEquals(<name>ArrayList.newListWith(<(literal.(type))("1")>), listFactory.of(<(literal.(type))("1")>));
Verify.assertInstanceOf(Immutable<name>List.class, listFactory.of(<(literal.(type))("1")>));
Assert.assertEquals(<name>ArrayList.newListWith(<["1", "2"]:(literal.(type))(); separator=", ">), listFactory.of(<["1", "2"]:(literal.(type))(); separator=", ">));
Verify.assertInstanceOf(Immutable<name>List.class, listFactory.of(<["1", "2"]:(literal.(type))(); separator=", ">));
Assert.assertEquals(<name>ArrayList.newListWith(<["1", "2", "3"]:(literal.(type))(); separator=", ">), listFactory.of(<["1", "2", "3"]:(literal.(type))(); separator=", ">));
Verify.assertInstanceOf(Immutable<name>List.class, listFactory.of(<["1", "2", "3"]:(literal.(type))(); separator=", ">));
Assert.assertEquals(<name>ArrayList.newListWith(<["1", "2", "3", "4"]:(literal.(type))(); separator=", ">), listFactory.of(<["1", "2", "3", "4"]:(literal.(type))(); separator=", ">));
Verify.assertInstanceOf(Immutable<name>List.class, listFactory.of(<["1", "2", "3", "4"]:(literal.(type))(); separator=", ">));
Assert.assertEquals(<name>ArrayList.newListWith(<["1", "2", "3", "4", "5"]:(literal.(type))(); separator=", ">), listFactory.of(<["1", "2", "3", "4", "5"]:(literal.(type))(); separator=", ">));
Verify.assertInstanceOf(Immutable<name>List.class, listFactory.of(<["1", "2", "3", "4", "5"]:(literal.(type))(); separator=", ">));
Assert.assertEquals(<name>ArrayList.newListWith(<["1", "2", "3", "4", "5", "6"]:(literal.(type))(); separator=", ">), listFactory.of(<["1", "2", "3", "4", "5", "6"]:(literal.(type))(); separator=", ">));
Verify.assertInstanceOf(Immutable<name>List.class, listFactory.of(<["1", "2", "3", "4", "5", "6"]:(literal.(type))(); separator=", ">));
Assert.assertEquals(<name>ArrayList.newListWith(<["1", "2", "3", "4", "5", "6", "7"]:(literal.(type))(); separator=", ">), listFactory.of(<["1", "2", "3", "4", "5", "6", "7"]:(literal.(type))(); separator=", ">));
Verify.assertInstanceOf(Immutable<name>List.class, listFactory.of(<["1", "2", "3", "4", "5", "6", "7"]:(literal.(type))(); separator=", ">));
Assert.assertEquals(<name>ArrayList.newListWith(<["1", "2", "3", "4", "5", "6", "7", "8"]:(literal.(type))(); separator=", ">), listFactory.of(<["1", "2", "3", "4", "5", "6", "7", "8"]:(literal.(type))(); separator=", ">));
Verify.assertInstanceOf(Immutable<name>List.class, listFactory.of(<["1", "2", "3", "4", "5", "6", "7", "8"]:(literal.(type))(); separator=", ">));
Assert.assertEquals(<name>ArrayList.newListWith(<["1", "2", "3", "4", "5", "6", "7", "8", "9"]:(literal.(type))(); separator=", ">), listFactory.of(<["1", "2", "3", "4", "5", "6", "7", "8", "9"]:(literal.(type))(); separator=", ">));
Verify.assertInstanceOf(Immutable<name>List.class, listFactory.of(<["1", "2", "3", "4", "5", "6", "7", "8", "9"]:(literal.(type))(); separator=", ">));
Assert.assertEquals(<name>ArrayList.newListWith(<["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]:(literal.(type))(); separator=", ">), listFactory.of(<["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]:(literal.(type))(); separator=", ">));
Verify.assertInstanceOf(Immutable<name>List.class, listFactory.of(<["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]:(literal.(type))(); separator=", ">));
Assert.assertEquals(<name>ArrayList.newListWith(<["1", "2", "3"]:(literal.(type))(); separator=", ">), listFactory.ofAll(<name>ArrayList.newListWith(<["1", "2", "3"]:(literal.(type))(); separator=", ">)));
Verify.assertInstanceOf(Immutable<name>List.class, listFactory.ofAll(<name>ArrayList.newListWith(<["1", "2", "3"]:(literal.(type))(); separator=", ">)));
}
@Test
public void emptyList()
{
Verify.assertEmpty(<name>Lists.immutable.of());
Assert.assertSame(<name>Lists.immutable.of(), <name>Lists.immutable.of());
Verify.assertPostSerializedIdentity(<name>Lists.immutable.of());
}
@Test
public void newListWith()
{
Immutable<name>List list = <name>Lists.immutable.of();
Assert.assertEquals(list, <name>Lists.immutable.of(list.toArray()));
Assert.assertEquals(list = list.newWith(<(literal.(type))("1")>), <name>Lists.immutable.of(<(literal.(type))("1")>));
Assert.assertEquals(list = list.newWith(<(literal.(type))("2")>), <name>Lists.immutable.of(<["1", "2"]:(literal.(type))(); separator=", ">));
Assert.assertEquals(list = list.newWith(<(literal.(type))("3")>), <name>Lists.immutable.of(<["1", "2", "3"]:(literal.(type))(); separator=", ">));
Assert.assertEquals(list = list.newWith(<(literal.(type))("4")>), <name>Lists.immutable.of(<["1", "2", "3", "4"]:(literal.(type))(); separator=", ">));
Assert.assertEquals(list = list.newWith(<(literal.(type))("5")>), <name>Lists.immutable.of(<["1", "2", "3", "4", "5"]:(literal.(type))(); separator=", ">));
Assert.assertEquals(list = list.newWith(<(literal.(type))("6")>), <name>Lists.immutable.of(<["1", "2", "3", "4", "5", "6"]:(literal.(type))(); separator=", ">));
Assert.assertEquals(list = list.newWith(<(literal.(type))("7")>), <name>Lists.immutable.of(<["1", "2", "3", "4", "5", "6", "7"]:(literal.(type))(); separator=", ">));
Assert.assertEquals(list = list.newWith(<(literal.(type))("8")>), <name>Lists.immutable.of(<["1", "2", "3", "4", "5", "6", "7", "8"]:(literal.(type))(); separator=", ">));
Assert.assertEquals(list = list.newWith(<(literal.(type))("9")>), <name>Lists.immutable.of(<["1", "2", "3", "4", "5", "6", "7", "8", "9"]:(literal.(type))(); separator=", ">));
Assert.assertEquals(list = list.newWith(<(literal.(type))("10")>), <name>Lists.immutable.of(<["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]:(literal.(type))(); separator=", ">));
Assert.assertEquals(list = list.newWith(<(literal.(type))("11")>), <name>Lists.immutable.of(<["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"]:(literal.(type))(); separator=", ">));
Assert.assertEquals(list = list.newWith(<(literal.(type))("12")>), <name>Lists.immutable.of(<["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"]:(literal.(type))(); separator=", ">));
}
@SuppressWarnings("RedundantArrayCreation")
@Test
public void newListWithArray_immutable()
{
Immutable<name>List list = <name>Lists.immutable.of();
Assert.assertEquals(list = list.newWith(<(literal.(type))("1")>), <name>Lists.immutable.of(new <type>[]{1}));
Assert.assertEquals(list = list.newWith(<(literal.(type))("2")>), <name>Lists.immutable.of(new <type>[]{<["1", "2"]:(literal.(type))(); separator=", ">}));
Assert.assertEquals(list = list.newWith(<(literal.(type))("3")>), <name>Lists.immutable.of(new <type>[]{<["1", "2", "3"]:(literal.(type))(); separator=", ">}));
Assert.assertEquals(list = list.newWith(<(literal.(type))("4")>), <name>Lists.immutable.of(new <type>[]{<["1", "2", "3", "4"]:(literal.(type))(); separator=", ">}));
Assert.assertEquals(list = list.newWith(<(literal.(type))("5")>), <name>Lists.immutable.of(new <type>[]{<["1", "2", "3", "4", "5"]:(literal.(type))(); separator=", ">}));
Assert.assertEquals(list = list.newWith(<(literal.(type))("6")>), <name>Lists.immutable.of(new <type>[]{<["1", "2", "3", "4", "5", "6"]:(literal.(type))(); separator=", ">}));
Assert.assertEquals(list = list.newWith(<(literal.(type))("7")>), <name>Lists.immutable.of(new <type>[]{<["1", "2", "3", "4", "5", "6", "7"]:(literal.(type))(); separator=", ">}));
Assert.assertEquals(list = list.newWith(<(literal.(type))("8")>), <name>Lists.immutable.of(new <type>[]{<["1", "2", "3", "4", "5", "6", "7", "8"]:(literal.(type))(); separator=", ">}));
Assert.assertEquals(list = list.newWith(<(literal.(type))("9")>), <name>Lists.immutable.of(new <type>[]{<["1", "2", "3", "4", "5", "6", "7", "8", "9"]:(literal.(type))(); separator=", ">}));
Assert.assertEquals(list = list.newWith(<(literal.(type))("10")>), <name>Lists.immutable.of(new <type>[]{<["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]:(literal.(type))(); separator=", ">}));
Assert.assertEquals(list = list.newWith(<(literal.(type))("11")>), <name>Lists.immutable.of(new <type>[]{<["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"]:(literal.(type))(); separator=", ">}));
}
@SuppressWarnings("RedundantArrayCreation")
@Test
public void newListWithArray_mutable()
{
Mutable<name>List list = <name>Lists.mutable.of();
Assert.assertEquals(list, <name>Lists.mutable.of(null));
Assert.assertEquals(list, <name>Lists.mutable.of(new <type>[]{}));
list.add(<(literal.(type))("1")>);
Assert.assertEquals(list, <name>Lists.immutable.of(new <type>[]{1}));
list.add(<(literal.(type))("2")>);
Assert.assertEquals(list, <name>Lists.immutable.of(new <type>[]{<["1", "2"]:(literal.(type))(); separator=", ">}));
list.add(<(literal.(type))("3")>);
Assert.assertEquals(list, <name>Lists.immutable.of(new <type>[]{<["1", "2", "3"]:(literal.(type))(); separator=", ">}));
list.add(<(literal.(type))("4")>);
Assert.assertEquals(list, <name>Lists.immutable.of(new <type>[]{<["1", "2", "3", "4"]:(literal.(type))(); separator=", ">}));
list.add(<(literal.(type))("5")>);
Assert.assertEquals(list, <name>Lists.immutable.of(new <type>[]{<["1", "2", "3", "4", "5"]:(literal.(type))(); separator=", ">}));
list.add(<(literal.(type))("6")>);
Assert.assertEquals(list, <name>Lists.immutable.of(new <type>[]{<["1", "2", "3", "4", "5", "6"]:(literal.(type))(); separator=", ">}));
list.add(<(literal.(type))("7")>);
Assert.assertEquals(list, <name>Lists.immutable.of(new <type>[]{<["1", "2", "3", "4", "5", "6", "7"]:(literal.(type))(); separator=", ">}));
list.add(<(literal.(type))("8")>);
Assert.assertEquals(list, <name>Lists.immutable.of(new <type>[]{<["1", "2", "3", "4", "5", "6", "7", "8"]:(literal.(type))(); separator=", ">}));
list.add(<(literal.(type))("9")>);
Assert.assertEquals(list, <name>Lists.immutable.of(new <type>[]{<["1", "2", "3", "4", "5", "6", "7", "8", "9"]:(literal.(type))(); separator=", ">}));
list.add(<(literal.(type))("10")>);
Assert.assertEquals(list, <name>Lists.immutable.of(new <type>[]{<["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]:(literal.(type))(); separator=", ">}));
list.add(<(literal.(type))("11")>);
Assert.assertEquals(list, <name>Lists.immutable.of(new <type>[]{<["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"]:(literal.(type))(); separator=", ">}));
}
@Test
public void newListWithList()
{
Immutable<name>List list = <name>Lists.immutable.of();
<name>ArrayList <type>ArrayList = <name>ArrayList.newListWith(<(literal.(type))("1")>);
Assert.assertEquals(list = list.newWith(<(literal.(type))("1")>), <type>ArrayList.toImmutable());
Assert.assertEquals(list = list.newWith(<(literal.(type))("2")>), <type>ArrayList.with(<(literal.(type))("2")>).toImmutable());
Assert.assertEquals(list = list.newWith(<(literal.(type))("3")>), <type>ArrayList.with(<(literal.(type))("3")>).toImmutable());
Assert.assertEquals(list = list.newWith(<(literal.(type))("4")>), <type>ArrayList.with(<(literal.(type))("4")>).toImmutable());
Assert.assertEquals(list = list.newWith(<(literal.(type))("5")>), <type>ArrayList.with(<(literal.(type))("5")>).toImmutable());
Assert.assertEquals(list = list.newWith(<(literal.(type))("6")>), <type>ArrayList.with(<(literal.(type))("6")>).toImmutable());
Assert.assertEquals(list = list.newWith(<(literal.(type))("7")>), <type>ArrayList.with(<(literal.(type))("7")>).toImmutable());
Assert.assertEquals(list = list.newWith(<(literal.(type))("8")>), <type>ArrayList.with(<(literal.(type))("8")>).toImmutable());
Assert.assertEquals(list = list.newWith(<(literal.(type))("9")>), <type>ArrayList.with(<(literal.(type))("9")>).toImmutable());
Assert.assertEquals(list = list.newWith(<(literal.(type))("10")>), <type>ArrayList.with(<(literal.(type))("10")>).toImmutable());
Assert.assertEquals(list = list.newWith(<(literal.(type))("11")>), <type>ArrayList.with(<(literal.(type))("11")>).toImmutable());
}
@Test
public void newListWithWithList()
{
Assert.assertEquals(new <name>ArrayList(), <name>Lists.immutable.ofAll(new <name>ArrayList()));
Assert.assertEquals(<name>ArrayList.newListWith(<(literal.(type))("1")>), <name>Lists.immutable.ofAll(<name>ArrayList.newListWith(<(literal.(type))("1")>)));
Assert.assertEquals(<name>ArrayList.newListWith(<["1", "2"]:(literal.(type))(); separator=", ">), <name>Lists.immutable.ofAll(<name>ArrayList.newListWith(<["1", "2"]:(literal.(type))(); separator=", ">)));
Assert.assertEquals(<name>ArrayList.newListWith(<["1", "2", "3"]:(literal.(type))(); separator=", ">), <name>Lists.immutable.ofAll(<name>ArrayList.newListWith(<["1", "2", "3"]:(literal.(type))(); separator=", ">)));
}
@Test
public void classIsNonInstantiable()
{
Verify.assertClassNonInstantiable(<name>Lists.class);
}
@Test
public void ofAllIterable()
{
Assert.assertEquals(new <name>ArrayList(), <name>Lists.immutable.ofAll(Lists.mutable.\<<wrapperName>\>empty()));
Assert.assertEquals(<name>ArrayList.newListWith(<(literal.(type))("1")>), <name>Lists.immutable.ofAll(Lists.mutable.\<<wrapperName>\>with(<(literal.(type))("1")>)));
Assert.assertEquals(<name>ArrayList.newListWith(<["1", "2"]:(literal.(type))(); separator=", ">), <name>Lists.immutable.ofAll(Lists.mutable.\<<wrapperName>\>with(<["1", "2"]:(literal.(type))(); separator=", ">)));
Assert.assertEquals(<name>ArrayList.newListWith(<["1", "2", "3"]:(literal.(type))(); separator=", ">), <name>Lists.immutable.ofAll(Lists.mutable.\<<wrapperName>\>with(<["1", "2", "3"]:(literal.(type))(); separator=", ">)));
Assert.assertEquals(new <name>ArrayList(), <name>Lists.mutable.ofAll(Lists.mutable.\<<wrapperName>\>empty()));
Assert.assertEquals(<name>ArrayList.newListWith(<(literal.(type))("1")>), <name>Lists.mutable.ofAll(Lists.mutable.\<<wrapperName>\>with(<(literal.(type))("1")>)));
Assert.assertEquals(<name>ArrayList.newListWith(<["1", "2"]:(literal.(type))(); separator=", ">), <name>Lists.mutable.ofAll(Lists.mutable.\<<wrapperName>\>with(<["1", "2"]:(literal.(type))(); separator=", ">)));
Assert.assertEquals(<name>ArrayList.newListWith(<["1", "2", "3"]:(literal.(type))(); separator=", ">), <name>Lists.mutable.ofAll(Lists.mutable.\<<wrapperName>\>with(<["1", "2", "3"]:(literal.(type))(); separator=", ">)));
}
<if(primitive.specializedStream)>
@Test
public void primitiveStream()
{
Assert.assertEquals(false, <name>Lists.immutable.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12).primitiveStream().isParallel());
}
@Test
public void primitiveParallelStream()
{
Assert.assertEquals(true, <name>Lists.immutable.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12).primitiveParallelStream().isParallel());
}
<endif>
}
>>