From e71840e0bb7ddb9749fc1b59d4e71c4552ea8917 Mon Sep 17 00:00:00 2001 From: Morgan James Delagrange Date: Wed, 13 Feb 2002 20:59:12 +0000 Subject: [PATCH] added unit test for LRUMap.removeLRU(), which needs fixing git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@130514 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/commons/collections/TestAll.java | 9 +++++---- .../commons/collections/TestLRUMap.java | 20 +++++++++++++++---- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/test/org/apache/commons/collections/TestAll.java b/src/test/org/apache/commons/collections/TestAll.java index 2e2f23a49..f3107d9de 100644 --- a/src/test/org/apache/commons/collections/TestAll.java +++ b/src/test/org/apache/commons/collections/TestAll.java @@ -1,7 +1,7 @@ /* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestAll.java,v 1.14 2002/01/20 04:36:08 craigmcc Exp $ - * $Revision: 1.14 $ - * $Date: 2002/01/20 04:36:08 $ + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestAll.java,v 1.15 2002/02/13 20:59:12 morgand Exp $ + * $Revision: 1.15 $ + * $Date: 2002/02/13 20:59:12 $ * * ==================================================================== * @@ -66,7 +66,7 @@ import junit.framework.*; /** * Entry point for all Collections tests. * @author Rodney Waldhoff - * @version $Id: TestAll.java,v 1.14 2002/01/20 04:36:08 craigmcc Exp $ + * @version $Id: TestAll.java,v 1.15 2002/02/13 20:59:12 morgand Exp $ */ public class TestAll extends TestCase { public TestAll(String testName) { @@ -96,6 +96,7 @@ public class TestAll extends TestCase { suite.addTest(TestTreeBag.suite()); suite.addTest(TestTreeMap.suite()); suite.addTest(TestDoubleOrderedMap.suite()); + suite.addTest(TestLRUMap.suite()); return suite; } diff --git a/src/test/org/apache/commons/collections/TestLRUMap.java b/src/test/org/apache/commons/collections/TestLRUMap.java index a41fdfdac..48b02fe20 100644 --- a/src/test/org/apache/commons/collections/TestLRUMap.java +++ b/src/test/org/apache/commons/collections/TestLRUMap.java @@ -1,7 +1,7 @@ /* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestLRUMap.java,v 1.1 2001/05/06 11:10:36 jstrachan Exp $ - * $Revision: 1.1 $ - * $Date: 2001/05/06 11:10:36 $ + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestLRUMap.java,v 1.2 2002/02/13 20:59:12 morgand Exp $ + * $Revision: 1.2 $ + * $Date: 2002/02/13 20:59:12 $ * * ==================================================================== * @@ -69,7 +69,7 @@ import java.util.HashMap; /** * @author James Strachan - * @version $Id: TestLRUMap.java,v 1.1 2001/05/06 11:10:36 jstrachan Exp $ + * @version $Id: TestLRUMap.java,v 1.2 2002/02/13 20:59:12 morgand Exp $ */ public class TestLRUMap extends TestHashMap { @@ -95,4 +95,16 @@ public class TestLRUMap extends TestHashMap map = (HashMap) makeMap(); } + public void testRemoveLRU() { + LRUMap map2 = new LRUMap(4); + map2.put(new Integer(1),"foo"); + map2.put(new Integer(2),"foo"); + map2.put(new Integer(3),"foo"); + map2.put(new Integer(4),"foo"); + map2.removeLRU(); // should be Integer(4) + + assertTrue("Second to last value should exist",map2.get(new Integer(3)).equals("foo")); + assertTrue("Last value inserted should not exist", map2.get(new Integer(4)) == null); + } + }