Implement WeakHashMap.
[SquirrelJME.git] / modules / cldc-compact / src / test / java / util / TestHashtable.java
bloba85442d64a12263d441dfef195c48f2bc29904ac
1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the GNU General Public License v3+, or later.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package util;
12 import java.util.Hashtable;
13 import java.util.Map;
15 /**
16 * This is a test for {@link Hashtable}.
18 * @since 2019/05/05
20 public class TestHashtable
21 extends TestHashMap
23 /**
24 * Initializes the test using the base map.
26 * @since 2019/05/05
28 public TestHashtable()
30 this(new Hashtable<Integer, String>());
33 /**
34 * Initializes the test using the given map.
36 * @param __m The map to use.
37 * @throws NullPointerException On null arguments.
38 * @since 2019/05/05
40 public TestHashtable(Map<Integer, String> __m)
41 throws NullPointerException
43 super(__m);
46 /**
47 * {@inheritDoc}
48 * @since 2019/05/05
50 @Override
51 public void test()
53 // Run basic HashMap test
54 super.test();
56 // Initialize a map to work with
57 Map<Integer, String> map = this.map;
59 // Null key should fail
60 boolean nullkey = false;
61 try
63 map.put(null, "Hiya!");
65 catch (NullPointerException e)
67 nullkey = true;
69 this.secondary("nullkey", nullkey);
71 // Null value should fail
72 boolean nullval = false;
73 try
75 map.put(9876, null);
77 catch (NullPointerException e)
79 nullval = true;
81 this.secondary("nullval", nullval);
83 // Cannot set values via the iterator either
84 Map.Entry<Integer, String> ent = map.entrySet().iterator().next();
85 boolean nullset = false;
86 try
88 ent.setValue(null);
90 catch (NullPointerException e)
92 nullset = true;
94 this.secondary("nullset", nullset);