-
Notifications
You must be signed in to change notification settings - Fork 593
/
immutablePrimitivePrimitiveEmptyMapTest.stg
247 lines (210 loc) · 8.14 KB
/
immutablePrimitivePrimitiveEmptyMapTest.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
import "copyright.stg"
import "primitiveEquals.stg"
import "primitiveHashCode.stg"
import "primitiveLiteral.stg"
isTest() ::= "true"
hasTwoPrimitives() ::= "true"
skipBoolean() ::= "true"
targetPath() ::= "org/eclipse/collections/impl/map/immutable/primitive"
fileName(primitive1, primitive2, sameTwoPrimitives) ::= "Immutable<primitive1.name><primitive2.name>EmptyMapTest"
class(primitive1, primitive2, sameTwoPrimitives) ::= <<
<body(primitive1.type, primitive2.type, primitive1.name, primitive2.name, primitive2.wrapperName)>
>>
body(type1, type2, name1, name2, wrapperName2) ::= <<
<copyright()>
package org.eclipse.collections.impl.map.immutable.primitive;
import java.util.NoSuchElementException;
import org.eclipse.collections.api.iterator.<name2>Iterator;
import org.eclipse.collections.api.map.primitive.Immutable<name1><name2>Map;
import org.eclipse.collections.impl.factory.primitive.<name2>Bags;
import org.eclipse.collections.impl.factory.primitive.<name1><name2>Maps;
import org.eclipse.collections.impl.list.mutable.primitive.<name1>ArrayList;
<if(!sameTwoPrimitives)>import org.eclipse.collections.impl.list.mutable.primitive.<name2>ArrayList;<endif>
import org.eclipse.collections.impl.math.Mutable<wrapperName2>;
import org.eclipse.collections.impl.test.Verify;
import org.junit.Assert;
import org.junit.Test;
/**
* JUnit test for {@link Immutable<name1><name2>EmptyMap}.
* This file was automatically generated from template file immutablePrimitivePrimitiveEmptyMapTest.stg.
*/
public class Immutable<name1><name2>EmptyMapTest extends AbstractImmutable<name1><name2>MapTestCase
{
@Override
protected Immutable<name1><name2>Map classUnderTest()
{
return <name1><name2>Maps.immutable.with();
}
@Test
public void newWithKeyValue()
{
Immutable<name1><name2>Map map1 = this.classUnderTest();
Immutable<name1><name2>Map expected = this.newWithKeysValues(<["0"]:keyValue(); separator=", ">);
Assert.assertEquals(expected, map1.newWithKeyValue(<["0"]:keyValue(); separator=", ">));
Assert.assertNotSame(map1, map1.newWithKeyValue(<["0"]:keyValue(); separator=", ">));
Assert.assertEquals(this.classUnderTest(), map1);
}
@Test
public void newWithoutKeyValue()
{
Immutable<name1><name2>Map map1 = this.classUnderTest();
Assert.assertEquals(map1, map1.newWithoutKey(<(literal.(type1))("32")>));
Assert.assertSame(map1, map1.newWithoutKey(<(literal.(type1))("32")>));
Assert.assertEquals(this.classUnderTest(), map1);
}
@Test
public void newWithoutAllKeys()
{
Immutable<name1><name2>Map map1 = this.classUnderTest();
Assert.assertEquals(map1, map1.newWithoutAllKeys(<name1>ArrayList.newListWith(<(literal.(type1))("0")>, <(literal.(type1))("32")>)));
Assert.assertSame(map1, map1.newWithoutAllKeys(<name1>ArrayList.newListWith(<(literal.(type1))("0")>, <(literal.(type1))("32")>)));
Assert.assertEquals(this.classUnderTest(), map1);
}
@Override
@Test
public void containsValue()
{
Assert.assertFalse(this.map.containsValue(<(literal.(type2))("0")>));
Assert.assertFalse(this.map.containsValue(<(literal.(type2))("31")>));
Assert.assertFalse(this.map.containsValue(<(literal.(type2))("32")>));
}
@Override
@Test
public void contains()
{
Assert.assertFalse(this.map.contains(<(literal.(type2))("0")>));
Assert.assertFalse(this.map.contains(<(literal.(type2))("31")>));
Assert.assertFalse(this.map.contains(<(literal.(type2))("32")>));
}
@Override
@Test
public void getIfAbsent()
{
Assert.assertEquals(<(wideLiteral.(type2))("5")>, this.map.getIfAbsent(<(literal.(type1))("0")>, <(literal.(type2))("5")>)<wideDelta.(type2)>);
Assert.assertEquals(<(wideLiteral.(type2))("15")>, this.map.getIfAbsent(<(literal.(type1))("31")>, <(literal.(type2))("15")>)<wideDelta.(type2)>);
Assert.assertEquals(<(wideLiteral.(type2))("25")>, this.map.getIfAbsent(<(literal.(type1))("32")>, <(literal.(type2))("25")>)<wideDelta.(type2)>);
}
@Override
@Test
public void asLazy()
{
Verify.assertEmpty(this.map.asLazy().toList());
}
@Override
@Test
public void <type2>Iterator()
{
<name2>Iterator iterator = this.map.<type2>Iterator();
Assert.assertFalse(iterator.hasNext());
Verify.assertThrows(NoSuchElementException.class, iterator::next);
}
@Override
@Test
public void getOrThrow()
{
Verify.assertThrows(IllegalStateException.class, () -> this.classUnderTest().getOrThrow(<(literal.(type1))("0")>));
Verify.assertThrows(IllegalStateException.class, () -> this.classUnderTest().getOrThrow(<(literal.(type1))("32")>));
}
@Override
@Test
public void get()
{
Assert.assertEquals(<(wideLiteral.(type2))("0")>, this.map.get(<(literal.(type1))("0")>)<wideDelta.(type2)>);
Assert.assertEquals(<(wideLiteral.(type2))("0")>, this.map.get(<(literal.(type1))("31")>)<wideDelta.(type2)>);
Assert.assertEquals(<(wideLiteral.(type2))("0")>, this.map.get(<(literal.(type1))("32")>)<wideDelta.(type2)>);
}
@Override
@Test
public void containsAll()
{
Assert.assertFalse(this.map.containsAll(<["0", "31", "32"]:(literal.(type2))(); separator=", ">));
Assert.assertFalse(this.map.containsAll(<["0", "31", "35"]:(literal.(type2))(); separator=", ">));
Assert.assertTrue(this.map.containsAll());
}
@Override
@Test
public void containsKey()
{
Assert.assertFalse(this.map.containsKey(<(literal.(type1))("0")>));
Assert.assertFalse(this.map.containsKey(<(literal.(type1))("31")>));
Assert.assertFalse(this.map.containsKey(<(literal.(type1))("32")>));
}
@Override
@Test
public void keysView()
{
Assert.assertEquals(<name1>ArrayList.newListWith(), this.map.keysView().toSortedList());
}
@Override
@Test
public void toSortedArray()
{
Assert.assertEquals(this.map.toSortedArray().length, 0);
}
@Override
@Test
public void notEmpty()
{
Assert.assertFalse(this.classUnderTest().notEmpty());
}
@Override
@Test
public void containsAll_Iterable()
{
Assert.assertFalse(this.map.containsAll(<name2>ArrayList.newListWith(<["0", "31", "32"]:(literal.(type2))(); separator=", ">)));
Assert.assertFalse(this.map.containsAll(<name2>ArrayList.newListWith(<["0", "31", "35"]:(literal.(type2))(); separator=", ">)));
Assert.assertTrue(this.map.containsAll(new <name2>ArrayList()));
}
@Override
@Test
public void isEmpty()
{
Assert.assertTrue(this.classUnderTest().isEmpty());
}
@Override
public void select()
{
Assert.assertEquals(this.classUnderTest(), this.classUnderTest().select((<type1> value1, <type2> value2) -> true));
}
@Override
@Test
public void reject()
{
Assert.assertEquals(this.classUnderTest(), this.classUnderTest().reject((<type1> value1, <type2> value2) -> false));
}
@Override
@Test
public void select_value()
{
Assert.assertEquals(<name2>Bags.immutable.empty(), this.classUnderTest().select(value -> true));
}
@Override
@Test
public void reject_value()
{
Assert.assertEquals(<name2>Bags.immutable.empty(), this.classUnderTest().reject(value -> false));
}
@Override
@Test
public void count()
{
Assert.assertEquals(0, this.classUnderTest().count((<type2> value) -> true));
}
@Override
@Test
public void sum()
{
Assert.assertEquals(<(wideLiteral.(type2))("0")>, this.classUnderTest().sum()<wideDelta.(type2)>);
}
@Test
public void injectInto()
{
Immutable<name1><name2>EmptyMap iterable = new Immutable<name1><name2>EmptyMap();
Mutable<wrapperName2> result = iterable.injectInto(new Mutable<wrapperName2>(<(literal.(type2))("0")>), Mutable<wrapperName2>::add);
Assert.assertEquals(new Mutable<wrapperName2>(<(literal.(type2))("0")>), result);
}
}
>>
keyValue(value) ::= <<
<(literal.(type1))(value)>, <(literal.(type2))(value)>
>>