@SuppressWarnings({"ToArrayCallWithZeroLengthArrayArgument"})
    public void testKeySet() {
        int element_count = 20;
        int[] keys = new int[element_count];
        String[] vals = new String[element_count];

        TIntObjectMap<String> raw_map = new TIntObjectHashMap<String>();
        for (int i = 0; i < element_count; i++) {
            keys[i] = i + 1;
            vals[i] = Integer.toString(i + 1);
            raw_map.put(keys[i], vals[i]);
        }
        Map<Integer, String> map = TDecorators.wrap(raw_map);
        assertEquals(element_count, map.size());

        Set<Integer> keyset = map.keySet();
        for (int i = 0; i < keyset.size(); i++) {
            assertTrue(keyset.contains(keys[i]));
        }
        assertFalse(keyset.isEmpty());

        Object[] keys_object_array = keyset.toArray();
        int count = 0;
        Iterator<Integer> iter = keyset.iterator();
        while (iter.hasNext()) {
            int key = iter.next();
            assertTrue(keyset.contains(key));
            assertEquals(keys_object_array[count], key);
            count++;
        }

        Integer[] keys_array = keyset.toArray(new Integer[0]);
        count = 0;
        iter = keyset.iterator();
        while (iter.hasNext()) {
            Integer key = iter.next();
            assertTrue(keyset.contains(key));
            assertEquals(keys_array[count], key);
            count++;
        }

        keys_array = keyset.toArray(new Integer[keyset.size()]);
        count = 0;
        iter = keyset.iterator();
        while (iter.hasNext()) {
            Integer key = iter.next();
            assertTrue(keyset.contains(key));
            assertEquals(keys_array[count], key);
            count++;
        }

        keys_array = keyset.toArray(new Integer[keyset.size() * 2]);
        count = 0;
        iter = keyset.iterator();
        while (iter.hasNext()) {
            Integer key = iter.next();
            assertTrue(keyset.contains(key));
            assertEquals(keys_array[count], key);
            count++;
        }
        assertNull(keys_array[keyset.size()]);

        TIntSet raw_other = new TIntHashSet(keyset);
        Set<Integer> other = TDecorators.wrap(raw_other);
        assertFalse(keyset.retainAll(other));
        other.remove(keys[5]);
        assertTrue(keyset.retainAll(other));
        assertFalse(keyset.contains(keys[5]));
        assertFalse(map.containsKey(keys[5]));

        keyset.clear();
        assertTrue(keyset.isEmpty());


    }