Fixed generics testcase.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1366807 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
23405f00a3
commit
a9b7c29bc7
|
@ -36,13 +36,15 @@ public class TransformedBagTest<T> extends AbstractBagTest<T> {
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Bag<T> makeObject() {
|
public Bag<T> makeObject() {
|
||||||
return TransformedBag.transformingBag(new HashBag<T>(), (Transformer<T, T>) TestTransformedCollection.NOOP_TRANSFORMER);
|
return TransformedBag.transformingBag(new HashBag<T>(),
|
||||||
|
(Transformer<T, T>) TestTransformedCollection.NOOP_TRANSFORMER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void testTransformedBag() {
|
public void testTransformedBag() {
|
||||||
//T had better be Object!
|
//T had better be Object!
|
||||||
Bag<T> bag = TransformedBag.transformingBag(new HashBag<T>(), (Transformer<T, T>) TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
|
Bag<T> bag = TransformedBag.transformingBag(new HashBag<T>(),
|
||||||
|
(Transformer<T, T>) TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
|
||||||
assertEquals(0, bag.size());
|
assertEquals(0, bag.size());
|
||||||
Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"};
|
Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"};
|
||||||
for (int i = 0; i < els.length; i++) {
|
for (int i = 0; i < els.length; i++) {
|
||||||
|
@ -56,14 +58,15 @@ public class TransformedBagTest<T> extends AbstractBagTest<T> {
|
||||||
assertEquals(true, bag.remove(new Integer((String) els[0])));
|
assertEquals(true, bag.remove(new Integer((String) els[0])));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Generics
|
@SuppressWarnings("unchecked")
|
||||||
public void testTransformedBag_decorateTransform() {
|
public void testTransformedBag_decorateTransform() {
|
||||||
Bag originalBag = new HashBag();
|
Bag<T> originalBag = new HashBag<T>();
|
||||||
Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"};
|
Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"};
|
||||||
for (int i = 0; i < els.length; i++) {
|
for (int i = 0; i < els.length; i++) {
|
||||||
originalBag.add(els[i]);
|
originalBag.add((T) els[i]);
|
||||||
}
|
}
|
||||||
Bag bag = TransformedBag.transformedBag(originalBag, TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
|
Bag<T> bag = TransformedBag.transformedBag(originalBag,
|
||||||
|
(Transformer<T, T>) TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
|
||||||
assertEquals(els.length, bag.size());
|
assertEquals(els.length, bag.size());
|
||||||
for (int i = 0; i < els.length; i++) {
|
for (int i = 0; i < els.length; i++) {
|
||||||
assertEquals(true, bag.contains(new Integer((String) els[i])));
|
assertEquals(true, bag.contains(new Integer((String) els[i])));
|
||||||
|
|
Loading…
Reference in New Issue