package com.github.kratorius.cuckoohash;

import junit.framework.TestCase;
import org.junit.Before;

public class CuckooHashMapTest extends TestCase {
  private CuckooHashMap<Character, Boolean> mCB;

  @Before
  public void setUp() {
    mCB = new CuckooHashMap<>();
  }

  public void testPut() {
    assertTrue(mCB.isEmpty());
    mCB.put('A', true);
    mCB.put('B', false);
    assertFalse(mCB.isEmpty());

    assertEquals(true, (boolean) mCB.get('A'));
    assertEquals(false, (boolean) mCB.get('B'));
    assertNull(mCB.get('C'));
  }

  public void testGet() {
    assertTrue(mCB.isEmpty());
    assertNull(mCB.get('A'));

    mCB.put('A', true);
    assertEquals(true, (boolean) mCB.get('A'));
    assertFalse(mCB.isEmpty());
  }

  public void testRemove() {
    assertTrue(mCB.isEmpty());

    // Should never fail if the key didn't exist.
    assertNull(mCB.remove('A'));
    assertNull(mCB.remove('B'));
    assertNull(mCB.remove('C'));

    mCB.put('A', true);
    mCB.put('B', false);
    assertEquals(2, mCB.size());

    assertEquals(false, (boolean) mCB.remove('B'));
    assertEquals(1, mCB.size());
    assertNull(mCB.get('B'));

    assertEquals(true, (boolean) mCB.remove('A'));
    assertEquals(0, mCB.size());
    assertNull(mCB.get('A'));
  }

  public void testContainsKey() {
    try {
      mCB.containsKey(null);
      fail("accepted null key");
    } catch (NullPointerException e) {
      // Expected.
    }

    mCB.put('A', true);
    mCB.put('B', true);
    mCB.put('C', true);

    assertTrue(mCB.containsKey('A'));
    assertTrue(mCB.containsKey('B'));
    assertTrue(mCB.containsKey('C'));
    assertFalse(mCB.containsKey('D'));
  }
}

@@ -1255,32 +1255,1024 @@
 get('A'));%0A  %7D%0A%0A
+  public void testClear() %7B%0A    assertTrue(mCB.isEmpty());%0A%0A    mCB.clear();%0A    assertTrue(mCB.isEmpty());%0A%0A    mCB.put('A', true);%0A    mCB.put('B', false);%0A    assertEquals(2, mCB.size());%0A%0A    mCB.clear();%0A    assertTrue(mCB.isEmpty());%0A    assertNull(mCB.get('A'));%0A    assertNull(mCB.get('B'));%0A  %7D%0A%0A  public void testSize() %7B%0A    assertEquals(0, mCB.size());%0A%0A    mCB.put('A', true);%0A    assertEquals(1, mCB.size());%0A%0A    mCB.put('B', true);%0A    assertEquals(2, mCB.size());%0A%0A    mCB.remove('C');%0A    assertEquals(2, mCB.size());%0A%0A    mCB.remove('A');%0A    assertEquals(1, mCB.size());%0A%0A    mCB.remove('B');%0A    assertEquals(0, mCB.size());%0A  %7D%0A%0A  public void testIsEmpty() %7B%0A    assertTrue(mCB.isEmpty());%0A%0A    mCB.put('A', true);%0A    assertFalse(mCB.isEmpty());%0A%0A    mCB.put('B', true);%0A    assertFalse(mCB.isEmpty());%0A%0A    mCB.remove('C');%0A    assertFalse(mCB.isEmpty());%0A%0A    mCB.remove('A');%0A    assertFalse(mCB.isEmpty());%0A%0A    mCB.remove('B');%0A    assertTrue(mCB.isEmpty());%0A  %7D%0A%0A
   public void te

Add tests for isEmpty, size and clear