| 1 |
import "copyright.stg" |
| 2 |
import "primitiveEquals.stg" |
| 3 |
import "primitiveHashCode.stg" |
| 4 |
import "primitiveLiteral.stg" |
| 5 |
|
| 6 |
isTest() ::= "true" |
| 7 |
|
| 8 |
targetPath() ::= "org/eclipse/collections/impl/collection/immutable/primitive" |
| 9 |
|
| 10 |
fileName(primitive) ::= "AbstractImmutable<primitive.name>CollectionTestCase" |
| 11 |
|
| 12 |
class(primitive) ::= << |
| 13 |
<body(primitive.type, primitive.wrapperName, primitive.name)> |
| 14 |
>> |
| 15 |
|
| 16 |
body(type, wrapperName, name) ::= << |
| 17 |
<copyright()> |
| 18 |
|
| 19 |
package org.eclipse.collections.impl.collection.immutable.primitive; |
| 20 |
|
| 21 |
import org.eclipse.collections.api.collection.primitive.Immutable<name>Collection; |
| 22 |
import org.eclipse.collections.api.collection.primitive.Mutable<name>Collection; |
| 23 |
import org.eclipse.collections.impl.collection.mutable.primitive.Abstract<name>IterableTestCase; |
| 24 |
import org.junit.Assert; |
| 25 |
import org.junit.Test; |
| 26 |
|
| 27 |
/** |
| 28 |
* Abstract JUnit test for {@link Immutable<name>Collection}s. |
| 29 |
* This file was automatically generated from template file abstractImmutablePrimitiveCollectionTestCase.stg. |
| 30 |
*/ |
| 31 |
public abstract class AbstractImmutable<name>CollectionTestCase extends Abstract<name>IterableTestCase |
| 32 |
{ |
| 33 |
@Override |
| 34 |
protected abstract Immutable<name>Collection classUnderTest(); |
| 35 |
|
| 36 |
@Override |
| 37 |
protected abstract Immutable<name>Collection newWith(<type>... elements); |
| 38 |
|
| 39 |
@Override |
| 40 |
protected abstract Mutable<name>Collection newMutableCollectionWith(<type>... elements); |
| 41 |
|
| 42 |
protected void assertSizeAndContains(Immutable<name>Collection collection, <type>... elements) |
| 43 |
{ |
| 44 |
Assert.assertEquals(elements.length, collection.size()); |
| 45 |
for (<type> i: elements) |
| 46 |
{ |
| 47 |
Assert.assertTrue(collection.contains(i)); |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
@Test |
| 52 |
public void testNewWith() |
| 53 |
{ |
| 54 |
Immutable<name>Collection immutableCollection = this.newWith(); |
| 55 |
Immutable<name>Collection collection = immutableCollection.newWith(<(literal.(type))("1")>); |
| 56 |
Immutable<name>Collection collection0 = immutableCollection.newWith(<(literal.(type))("1")>).newWith(<(literal.(type))("2")>); |
| 57 |
Immutable<name>Collection collection1 = immutableCollection.newWith(<(literal.(type))("1")>).newWith(<(literal.(type))("2")>).newWith(<(literal.(type))("3")>); |
| 58 |
Immutable<name>Collection collection2 = immutableCollection.newWith(<(literal.(type))("1")>).newWith(<(literal.(type))("2")>).newWith(<(literal.(type))("3")>).newWith(<(literal.(type))("4")>); |
| 59 |
Immutable<name>Collection collection3 = immutableCollection.newWith(<(literal.(type))("1")>).newWith(<(literal.(type))("2")>).newWith(<(literal.(type))("3")>).newWith(<(literal.(type))("4")>).newWith(<(literal.(type))("5")>); |
| 60 |
this.assertSizeAndContains(immutableCollection); |
| 61 |
this.assertSizeAndContains(collection, <(literal.(type))("1")>); |
| 62 |
this.assertSizeAndContains(collection0, <(literal.(type))("1")>, <(literal.(type))("2")>); |
| 63 |
this.assertSizeAndContains(collection1, <(literal.(type))("1")>, <(literal.(type))("2")>, <(literal.(type))("3")>); |
| 64 |
this.assertSizeAndContains(collection2, <(literal.(type))("1")>, <(literal.(type))("2")>, <(literal.(type))("3")>, <(literal.(type))("4")>); |
| 65 |
this.assertSizeAndContains(collection3, <(literal.(type))("1")>, <(literal.(type))("2")>, <(literal.(type))("3")>, <(literal.(type))("4")>, <(literal.(type))("5")>); |
| 66 |
} |
| 67 |
|
| 68 |
@Test |
| 69 |
public void newWithAll() |
| 70 |
{ |
| 71 |
Immutable<name>Collection immutableCollection = this.newWith(); |
| 72 |
Immutable<name>Collection collection = immutableCollection.newWithAll(this.newMutableCollectionWith(<(literal.(type))("1")>)); |
| 73 |
Immutable<name>Collection collection0 = collection.newWithAll(this.newMutableCollectionWith(<(literal.(type))("2")>)); |
| 74 |
Immutable<name>Collection collection1 = collection0.newWithAll(this.newMutableCollectionWith(<(literal.(type))("3")>)); |
| 75 |
Immutable<name>Collection collection2 = immutableCollection.newWithAll(this.newMutableCollectionWith(<["1", "2", "3", "4"]:(literal.(type))(); separator=", ">)); |
| 76 |
Immutable<name>Collection collection3 = immutableCollection.newWithAll(this.newMutableCollectionWith(<["1", "2", "3", "4", "5"]:(literal.(type))(); separator=", ">)); |
| 77 |
this.assertSizeAndContains(immutableCollection); |
| 78 |
this.assertSizeAndContains(collection, <(literal.(type))("1")>); |
| 79 |
this.assertSizeAndContains(collection0, <(literal.(type))("1")>, <(literal.(type))("2")>); |
| 80 |
this.assertSizeAndContains(collection1, <(literal.(type))("1")>, <(literal.(type))("2")>, <(literal.(type))("3")>); |
| 81 |
this.assertSizeAndContains(collection2, <(literal.(type))("1")>, <(literal.(type))("2")>, <(literal.(type))("3")>, <(literal.(type))("4")>); |
| 82 |
this.assertSizeAndContains(collection3, <(literal.(type))("1")>, <(literal.(type))("2")>, <(literal.(type))("3")>, <(literal.(type))("4")>, <(literal.(type))("5")>); |
| 83 |
} |
| 84 |
|
| 85 |
@Test |
| 86 |
public void newWithout() |
| 87 |
{ |
| 88 |
Immutable<name>Collection collection3 = this.newWith(<(literal.(type))("1")>, <(literal.(type))("2")>, <(literal.(type))("3")>, <(literal.(type))("4")>, <(literal.(type))("5")>); |
| 89 |
Immutable<name>Collection collection2 = collection3.newWithout(<(literal.(type))("5")>); |
| 90 |
Immutable<name>Collection collection1 = collection2.newWithout(<(literal.(type))("4")>); |
| 91 |
Immutable<name>Collection collection0 = collection1.newWithout(<(literal.(type))("3")>); |
| 92 |
Immutable<name>Collection collection4 = collection0.newWithout(<(literal.(type))("2")>); |
| 93 |
Immutable<name>Collection collection5 = collection4.newWithout(<(literal.(type))("1")>); |
| 94 |
Immutable<name>Collection collection6 = collection5.newWithout(<(literal.(type))("0")>); |
| 95 |
|
| 96 |
this.assertSizeAndContains(collection6); |
| 97 |
this.assertSizeAndContains(collection5); |
| 98 |
this.assertSizeAndContains(collection4, <(literal.(type))("1")>); |
| 99 |
this.assertSizeAndContains(collection0, <(literal.(type))("1")>, <(literal.(type))("2")>); |
| 100 |
this.assertSizeAndContains(collection1, <(literal.(type))("1")>, <(literal.(type))("2")>, <(literal.(type))("3")>); |
| 101 |
this.assertSizeAndContains(collection2, <(literal.(type))("1")>, <(literal.(type))("2")>, <(literal.(type))("3")>, <(literal.(type))("4")>); |
| 102 |
} |
| 103 |
|
| 104 |
@Test |
| 105 |
public void newWithoutAll() |
| 106 |
{ |
| 107 |
Immutable<name>Collection collection3 = this.newWith(<(literal.(type))("1")>, <(literal.(type))("2")>, <(literal.(type))("3")>, <(literal.(type))("4")>, <(literal.(type))("5")>); |
| 108 |
Immutable<name>Collection collection2 = collection3.newWithoutAll(this.newMutableCollectionWith(<(literal.(type))("5")>)); |
| 109 |
Immutable<name>Collection collection1 = collection2.newWithoutAll(this.newMutableCollectionWith(<(literal.(type))("4")>)); |
| 110 |
Immutable<name>Collection collection0 = collection1.newWithoutAll(this.newMutableCollectionWith(<(literal.(type))("3")>)); |
| 111 |
Immutable<name>Collection collection4 = collection0.newWithoutAll(this.newMutableCollectionWith(<(literal.(type))("2")>)); |
| 112 |
Immutable<name>Collection collection5 = collection4.newWithoutAll(this.newMutableCollectionWith(<(literal.(type))("1")>)); |
| 113 |
Immutable<name>Collection collection6 = collection5.newWithoutAll(this.newMutableCollectionWith(<(literal.(type))("0")>)); |
| 114 |
|
| 115 |
this.assertSizeAndContains(collection6); |
| 116 |
this.assertSizeAndContains(collection5); |
| 117 |
this.assertSizeAndContains(collection4, <(literal.(type))("1")>); |
| 118 |
this.assertSizeAndContains(collection0, <(literal.(type))("1")>, <(literal.(type))("2")>); |
| 119 |
this.assertSizeAndContains(collection1, <(literal.(type))("1")>, <(literal.(type))("2")>, <(literal.(type))("3")>); |
| 120 |
this.assertSizeAndContains(collection2, <(literal.(type))("1")>, <(literal.(type))("2")>, <(literal.(type))("3")>, <(literal.(type))("4")>); |
| 121 |
} |
| 122 |
} |
| 123 |
|
| 124 |
>> |