-
Notifications
You must be signed in to change notification settings - Fork 586
/
abstractImmutablePrimitivePrimitiveMapTestCase.stg
142 lines (117 loc) · 6.62 KB
/
abstractImmutablePrimitivePrimitiveMapTestCase.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
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) ::= "AbstractImmutable<primitive1.name><primitive2.name>MapTestCase"
class(primitive1, primitive2, sameTwoPrimitives) ::= <<
<body(primitive1.type, primitive2.type, primitive1.name, primitive2.name)>
>>
body(type1, type2, name1, name2) ::= <<
<copyright()>
package org.eclipse.collections.impl.map.immutable.primitive;
import org.eclipse.collections.api.map.primitive.<name1><name2>Map;
import org.eclipse.collections.api.map.primitive.Immutable<name1><name2>Map;
import org.eclipse.collections.impl.factory.primitive.<name1><name2>Maps;
<if(!sameTwoPrimitives)>import org.eclipse.collections.impl.factory.primitive.<name2><name1>Maps;<endif>
import org.eclipse.collections.impl.map.mutable.primitive.<name1><name2>HashMap;
<if(!sameTwoPrimitives)>import org.eclipse.collections.impl.map.mutable.primitive.<name2><name1>HashMap;<endif>
import org.eclipse.collections.impl.map.primitive.Abstract<name1><name2>MapTestCase;
import org.eclipse.collections.impl.test.Verify;
import org.junit.Assert;
import org.junit.Test;
/**
* Abstract JUnit test for {@link Immutable<name1><name2>Map}.
* This file was automatically generated from template file abstractImmutablePrimitivePrimitiveMapTestCase.stg.
*/
public abstract class AbstractImmutable<name1><name2>MapTestCase extends Abstract<name1><name2>MapTestCase
{
@Override
protected Immutable<name1><name2>Map classUnderTest()
{
return <name1><name2>Maps.immutable.withAll(<name1><name2>HashMap.newWithKeysValues(<["0", "31", "32"]:keyValue(); separator=", ">));
}
@Override
protected Immutable<name1><name2>Map newWithKeysValues(<type1> key1, <type2> value1)
{
return <name1><name2>Maps.immutable.with(key1, value1);
}
@Override
protected Immutable<name1><name2>Map newWithKeysValues(<type1> key1, <type2> value1, <type1> key2, <type2> value2)
{
return <name1><name2>Maps.immutable.withAll(new <name1><name2>HashMap(2).withKeysValues(key1, value1, key2, value2));
}
@Override
protected Immutable<name1><name2>Map newWithKeysValues(<type1> key1, <type2> value1, <type1> key2, <type2> value2, <type1> key3, <type2> value3)
{
return <name1><name2>Maps.immutable.withAll(new <name1><name2>HashMap(3).withKeysValues(key1, value1, key2, value2, key3, value3));
}
@Override
protected Immutable<name1><name2>Map newWithKeysValues(<type1> key1, <type2> value1, <type1> key2, <type2> value2, <type1> key3, <type2> value3, <type1> key4, <type2> value4)
{
return <name1><name2>Maps.immutable.withAll(new <name1><name2>HashMap(4).withKeysValues(key1, value1, key2, value2, key3, value3, key4, value4));
}
@Override
protected Immutable<name1><name2>Map getEmptyMap()
{
return <name1><name2>Maps.immutable.with();
}
@Override
@Test
public void testEquals()
{
<name1><name2>Map map1 = this.newWithKeysValues(<["0", "1", "32"]:keyValue(); separator=", ">);
<name1><name2>Map map2 = this.newWithKeysValues(<["32", "0", "1"]:keyValue(); separator=", ">);
<name1><name2>Map map3 = this.newWithKeysValues(<["0"]:keyValue(); separator=", ">, <(literal.(type1))("1")>, <(literal.(type2))("2")>, <["32"]:keyValue(); separator=", ">);
<name1><name2>Map map4 = this.newWithKeysValues(<(literal.(type1))("0")>, <(literal.(type2))("1")>, <["1", "32"]:keyValue(); separator=", ">);
<name1><name2>Map map5 = this.newWithKeysValues(<["0", "1"]:keyValue(); separator=", ">, <(literal.(type1))("32")>, <(literal.(type2))("33")>);
<name1><name2>Map map6 = this.newWithKeysValues(<(literal.(type1))("50")>, <(literal.(type2))("0")>, <(literal.(type1))("60")>, <(literal.(type2))("1")>, <(literal.(type1))("70")>, <(literal.(type2))("33")>);
<name1><name2>Map map7 = this.newWithKeysValues(<(literal.(type1))("50")>, <(literal.(type2))("0")>, <(literal.(type1))("60")>, <(literal.(type2))("1")>);
<name1><name2>Map map8 = this.newWithKeysValues(<["0", "1"]:keyValue(); separator=", ">);
Verify.assertEqualsAndHashCode(map1, map2);
Verify.assertPostSerializedEqualsAndHashCode(map1);
Verify.assertPostSerializedEqualsAndHashCode(map6);
Verify.assertPostSerializedEqualsAndHashCode(map8);
Verify.assertPostSerializedIdentity(this.getEmptyMap());
Assert.assertNotEquals(map1, map3);
Assert.assertNotEquals(map1, map4);
Assert.assertNotEquals(map1, map5);
Assert.assertNotEquals(map7, map6);
Assert.assertNotEquals(map7, map8);
}
@Override
@Test
public void keySet()
{
super.keySet();
Verify.assertThrows(
UnsupportedOperationException.class,
() -> this.classUnderTest().keySet().remove(<(literal.(type1))("0")>));
}
@Override
public void values()
{
super.values();
Verify.assertThrows(
UnsupportedOperationException.class,
() -> this.classUnderTest().values().remove(<(literal.(type2))("0")>));
}
@Test
public void flipUniqueValues()
{
Assert.assertEquals(<name2><name1>Maps.immutable.empty(), <name1><name2>Maps.immutable.empty().flipUniqueValues());
Verify.assertInstanceOf(Immutable<name2><name1>EmptyMap.class, <name1><name2>Maps.immutable.empty().flipUniqueValues());
Assert.assertEquals(<name2><name1>Maps.immutable.with(<(literal.(type2))("2")>, <(literal.(type1))("1")>), this.newWithKeysValues(<(literal.(type1))("1")>, <(literal.(type2))("2")>).flipUniqueValues());
Assert.assertEquals(
<name2><name1>HashMap.newWithKeysValues(<(literal.(type2))("2")>, <(literal.(type1))("1")>, <(literal.(type2))("3")>, <(literal.(type1))("2")>, <(literal.(type2))("4")>, <(literal.(type1))("3")>, <(literal.(type2))("5")>, <(literal.(type1))("4")>).toImmutable(),
this.newWithKeysValues(<(literal.(type1))("1")>, <(literal.(type2))("2")>, <(literal.(type1))("2")>, <(literal.(type2))("3")>, <(literal.(type1))("3")>, <(literal.(type2))("4")>, <(literal.(type1))("4")>, <(literal.(type2))("5")>).flipUniqueValues());
Verify.assertThrows(IllegalStateException.class, () -> this.newWithKeysValues(<(literal.(type1))("1")>, <(literal.(type2))("1")>, <(literal.(type1))("2")>, <(literal.(type2))("1")>).flipUniqueValues());
}
}
>>
keyValue(value) ::= <<
<(literal.(type1))(value)>, <(literal.(type2))(value)>
>>