Code example for Hashtable

Methods: get, put

0
    public void test_ConstructorIF() { 
        // Test for method java.util.Hashtable(int, float) 
        Hashtable h = new java.util.Hashtable(10, 0.5f);
        assertEquals("Created incorrect hashtable", 0, h.size());
 
        Hashtable empty = new Hashtable(0, 0.75f);
        assertNull("Empty hashtable access", empty.get("nothing"));
        empty.put("something", "here");
        assertTrue("cannot get element", empty.get("something") == "here");
 
        try { 
            new Hashtable(-1, 0.75f);
            fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException e) {
            //expected 
        } 
 
        try { 
            new Hashtable(0, -0.75f);
            fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException e) {