<commit_before>package org.keyboardplaying.util;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.junit.Test;

/**
 * Test class for the {@link BiHashMap}.
 *
 * @author <NAME> (http://keyboardplaying.org)
 */
public class BiHashMapTest {

    /** Tests {@link BiHashMap#put(Object, Object)} and {@link BiHashMap#remove(Object)} (among other methods). */
    @Test
    public void testPutAndRemove() {
        BiHashMap<String, Integer> map = new BiHashMap<>();
        assertSize(0, map);

        map.put("A", 1);
        map.put("B", 2);
        assertTrue(map.containsKey("A"));
        assertSize(2, map);

        map.put("1", 1);
        assertFalse(map.containsKey("A"));
        assertTrue(map.containsValue(2));
        assertSize(2, map);

        map.removeValue(2);
        assertFalse(map.containsValue(2));
        assertSize(1, map);

        map.remove("1");
        assertSize(0, map);
    }

    private void assertSize(int expected, BiHashMap<String, Integer> map) {
        assertEquals(expected == 0, map.isEmpty());
        assertEquals(expected, map.size());
        assertEquals(expected, map.keySet().size());
        assertEquals(expected, map.values().size());
    }
}<commit_msg>Improve test coverage<commit_after>package org.keyboardplaying.util;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import java.util.HashMap;
import java.util.Map;

import org.junit.Test;

/**
 * Test class for the {@link BiHashMap}.
 *
 * @author <NAME> (http://keyboardplaying.org)
 */
public class BiHashMapTest {

    /** Tests {@link BiHashMap#put(Object, Object)} and {@link BiHashMap#remove(Object)} (among other methods). */
    @Test
    public void testPutAndRemove() {
        BiHashMap<String, Integer> map = new BiHashMap<>();
        assertSize(0, map);

        Map<String, Integer> all = new HashMap<>();
        all.put("A", 1);
        all.put("B", 2);
        map.putAll(all);

        assertTrue(map.containsKey("A"));
        assertEquals(Integer.valueOf(1), map.get("A"));
        assertEquals("B", map.getKey(2));
        assertNull(map.get("C"));
        assertNull(map.getKey(3));
        assertSize(2, map);

        map.put("1", 1);
        assertFalse(map.containsKey("A"));
        assertTrue(map.containsValue(2));
        assertSize(2, map);

        map.put("1", 0);
        assertTrue(map.containsKey("1"));
        assertFalse(map.containsValue(1));
        assertTrue(map.containsValue(0));
        assertSize(2, map);

        map.removeValue(2);
        assertFalse(map.containsValue(2));
        assertSize(1, map);

        map.remove("1");
        assertSize(0, map);
    }

    /** Tests {@link BiHashMap#clear()}. */
    @Test
    public void testClear() {
        BiHashMap<String, Integer> map = new BiHashMap<>();
        map.put("A", 1);
        map.put("B", 2);
        assertSize(2, map);

        map.clear();
        assertSize(0, map);
    }

    private void assertSize(int expected, BiHashMap<String, Integer> map) {
        assertEquals(expected == 0, map.isEmpty());
        assertEquals(expected, map.size());
        assertEquals(expected, map.entrySet().size());
        assertEquals(expected, map.keySet().size());
        assertEquals(expected, map.values().size());
    }
}
{'fraction_non_alphanumeric': 0.16003460207612458, 'fraction_numerical': 0.01182237600922722, 'mean_word_length': 2.8890134529147984, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3831723', 'n_tokens_mistral': 1042, 'n_tokens_neox': 1034, 'n_words': 215}