Fix tests to work properly on inverse map

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@131277 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephen Colebourne 2003-10-10 21:09:27 +00:00
parent 1557ede997
commit 6526be25d1
1 changed files with 24 additions and 19 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestBidiMap.java,v 1.7 2003/10/09 20:21:32 scolebourne Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestBidiMap.java,v 1.8 2003/10/10 21:09:27 scolebourne Exp $
* ==================================================================== * ====================================================================
* *
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
@ -63,25 +63,23 @@ import java.util.Map;
/** /**
* JUnit tests. * JUnit tests.
* *
* @version $Revision: 1.7 $ $Date: 2003/10/09 20:21:32 $ * @version $Revision: 1.8 $ $Date: 2003/10/10 21:09:27 $
* *
* @author Matthew Hawthorne * @author Matthew Hawthorne
* @author Stephen Colebourne
*/ */
public abstract class TestBidiMap extends AbstractTestMap { public abstract class TestBidiMap extends AbstractTestMap {
// Test data. // Test data.
private static final Object KEY = "key1";
private static final Object VALUE = "value1";
private static final Object[][] entriesKV = private static final Object[][] entriesKV =
new Object[][] { new Object[][] {
new Object[] { KEY, VALUE }, new Object[] { "key1", "value1" },
new Object[] { "key2", "value2" }, new Object[] { "key2", "value2" },
new Object[] { "key3", "value3" } new Object[] { "key3", "value3" }
}; };
private static final Object[][] entriesVK = private static final Object[][] entriesVK =
new Object[][] { new Object[][] {
new Object[] { VALUE, KEY }, new Object[] { "value1", "key1" },
new Object[] { "value2", "key2" }, new Object[] { "value2", "key2" },
new Object[] { "value3", "key3" } new Object[] { "value3", "key3" }
}; };
@ -178,13 +176,14 @@ public abstract class TestBidiMap extends AbstractTestMap {
* This implementation checks the inverse map as well. * This implementation checks the inverse map as well.
*/ */
protected void verify() { protected void verify() {
// verify inverse verifyInverse();
assertEquals(map.size(), ((BidiMap) map).inverseBidiMap().size());
// verify fully
super.verify(); super.verify();
} }
protected void verifyInverse() {
assertEquals(map.size(), ((BidiMap) map).inverseBidiMap().size());
}
// testGetKey // testGetKey
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
public void testBidiGetKey() { public void testBidiGetKey() {
@ -270,11 +269,11 @@ public abstract class TestBidiMap extends AbstractTestMap {
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
public void testBidiRemove() { public void testBidiRemove() {
remove(makeFullBidiMap(), KEY); remove(makeFullBidiMap(), entries[0][0]);
remove(makeFullBidiMap().inverseBidiMap(), VALUE); remove(makeFullBidiMap().inverseBidiMap(), entries[0][1]);
removeKey(makeFullBidiMap(), VALUE); removeKey(makeFullBidiMap(), entries[0][1]);
removeKey(makeFullBidiMap().inverseBidiMap(), KEY); removeKey(makeFullBidiMap().inverseBidiMap(), entries[0][0]);
} }
private final void remove(BidiMap map, Object key) { private final void remove(BidiMap map, Object key) {
@ -291,8 +290,8 @@ public abstract class TestBidiMap extends AbstractTestMap {
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
public void testBidiRemoveByKeySet() { public void testBidiRemoveByKeySet() {
removeByKeySet(makeFullBidiMap(), KEY, VALUE); removeByKeySet(makeFullBidiMap(), entries[0][0], entries[0][1]);
removeByKeySet(makeFullBidiMap().inverseBidiMap(), VALUE, KEY); removeByKeySet(makeFullBidiMap().inverseBidiMap(), entries[0][1], entries[0][0]);
} }
private final void removeByKeySet(BidiMap map, Object key, Object value) { private final void removeByKeySet(BidiMap map, Object key, Object value) {
@ -311,8 +310,8 @@ public abstract class TestBidiMap extends AbstractTestMap {
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
public void testBidiRemoveByEntrySet() { public void testBidiRemoveByEntrySet() {
removeByEntrySet(makeFullBidiMap(), KEY, VALUE); removeByEntrySet(makeFullBidiMap(), entries[0][0], entries[0][1]);
removeByEntrySet(makeFullBidiMap().inverseBidiMap(), VALUE, KEY); removeByEntrySet(makeFullBidiMap().inverseBidiMap(), entries[0][1], entries[0][0]);
} }
private final void removeByEntrySet(BidiMap map, Object key, Object value) { private final void removeByEntrySet(BidiMap map, Object key, Object value) {
@ -348,6 +347,12 @@ public abstract class TestBidiMap extends AbstractTestMap {
protected BidiMap makeFullBidiMap() { protected BidiMap makeFullBidiMap() {
return main.makeFullBidiMap().inverseBidiMap(); return main.makeFullBidiMap().inverseBidiMap();
} }
protected Object[] getSampleKeys() {
return main.getSampleValues();
}
protected Object[] getSampleValues() {
return main.getSampleKeys();
}
protected String getCompatibilityVersion() { protected String getCompatibilityVersion() {
return main.getCompatibilityVersion(); return main.getCompatibilityVersion();