Author: stevencaswell
Date: Sun Aug 21 17:52:20 2005
New Revision: 234404

URL: http://svn.apache.org/viewcvs?rev=234404&view=rev
Log:
increase IntHashMap test coverage as reported by clover

Added:
    
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/IntHashMapTest.java

Added: 
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/IntHashMapTest.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/IntHashMapTest.java?rev=234404&view=auto
==============================================================================
--- 
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/IntHashMapTest.java
 (added)
+++ 
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/IntHashMapTest.java
 Sun Aug 21 17:52:20 2005
@@ -0,0 +1,128 @@
+/*

+ * Copyright 2005 Steven Caswell

+ */

+package org.apache.commons.lang;

+

+import junit.framework.Test;

+import junit.framework.TestCase;

+import junit.framework.TestSuite;

+import junit.textui.TestRunner;

+

+/**

+ *

+ * @author  Steven Caswell

+ * @version $Id$

+ */

+public class IntHashMapTest extends TestCase

+{

+

+    public static void main(String[] args) {

+        TestRunner.run(suite());

+    }

+

+    public static Test suite() {

+        TestSuite suite = new TestSuite(IntHashMapTest.class);

+        suite.setName("IntHashMapTest Tests");

+        return suite;

+    }

+

+    public void testConstructor() {

+        try {

+            IntHashMap map = new IntHashMap(-1, 0.0f);

+            fail();

+        } catch (IllegalArgumentException e) {

+            assertEquals("Illegal Capacity: -1", e.getMessage());

+        }

+        try {

+            IntHashMap map = new IntHashMap(1, 0.0f);

+            fail();

+        } catch (IllegalArgumentException e) {

+            assertEquals("Illegal Load: 0.0", e.getMessage());

+        }

+        IntHashMap map = new IntHashMap(0, 1.0f);

+        

+        try {

+            IntHashMap map1 = new IntHashMap(-1);

+            fail();

+        } catch (IllegalArgumentException e) {

+           assertEquals("Illegal Capacity: -1", e.getMessage());

+        }

+        IntHashMap map1 = new IntHashMap(0);

+    }

+    

+    public void testClear() {

+        IntHashMap map = new IntHashMap();

+        assertNull(map.put(1, "hello"));

+        assertNull(map.put(2, "world"));

+        assertEquals(2, map.size());

+        map.clear();

+        assertEquals(0, map.size());

+    }

+  

+    public void testContainsKey() {

+        IntHashMap map = new IntHashMap();

+        assertNull(map.put(1, "hello"));

+        assertNull(map.put(2, "world"));

+        assertEquals(2, map.size());

+        assertTrue(map.containsKey(1));

+        assertTrue(map.containsKey(2));

+        assertFalse(map.containsKey(3));

+    }

+

+    public void testContains() {

+        IntHashMap map = new IntHashMap();

+        assertNull(map.put(1, "hello"));

+        assertNull(map.put(2, "world"));

+        assertEquals(2, map.size());

+        assertTrue(map.containsValue("hello"));

+        assertTrue(map.containsValue("world"));

+        assertFalse(map.containsValue("goodbye"));

+        try {

+            map.containsValue(null);

+            fail();

+        } catch(NullPointerException e) {

+      }

+    }

+

+    public void testContainsValue() {

+        IntHashMap map = new IntHashMap();

+        assertNull(map.put(1, "hello"));

+        assertNull(map.put(2, "world"));

+        assertEquals(2, map.size());

+        assertTrue(map.containsValue("hello"));

+        assertTrue(map.containsValue("world"));

+        assertFalse(map.containsValue("goodbye"));

+        try {

+            map.containsValue(null);

+            fail();

+        } catch(NullPointerException e) {

+        }

+    }

+

+    public void testIsEmpty() {

+        IntHashMap map = new IntHashMap();

+        assertTrue(map.isEmpty());

+        assertNull(map.put(1, "hello"));

+        assertEquals(1, map.size());

+        assertFalse(map.isEmpty());

+    }

+  

+    public void testPut() {

+        IntHashMap map = new IntHashMap();

+        assertNull(map.put(1, "hello"));

+        assertNull(map.put(2, "world"));

+        assertEquals(2, map.size());

+        assertEquals("hello", map.put(1, "hellooooo"));

+    }

+    

+    public void testRemove() {

+        IntHashMap map = new IntHashMap();

+        assertNull(map.put(1, "hello"));

+        assertNull(map.put(2, "world"));

+        assertEquals(2, map.size());

+        assertEquals("hello", map.remove(1));

+        assertEquals(1, map.size());

+        assertNull(map.remove(3));

+    }

+    

+}




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to