Skip to content

Instantly share code, notes, and snippets.

@bitkid
Created June 24, 2013 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitkid/5854451 to your computer and use it in GitHub Desktop.
Save bitkid/5854451 to your computer and use it in GitHub Desktop.
import gnu.trove.map.TIntLongMap;
import gnu.trove.map.hash.TIntLongHashMap;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
public class TroveMapsEqualsTest {
@Test
public void testTIntLongMapEquals() {
assertEquals(MIL(0, 0), MIL(0, 0));
assertNotEquals(MIL(0, 1), MIL(0, 0));
assertNotEquals(MIL(1, 0), MIL(0, 0));
assertEquals(MIL(0, 1), MIL(0, 1));
assertNotEquals(MIL(1, 0), MIL(0, 1));
assertNotEquals(MIL(0, 0), MIL(0, 1));
assertEquals(MIL(1, 0), MIL(1, 0));
assertNotEquals(MIL(0, 0), MIL(1, 0));
assertNotEquals(MIL(0, 1), MIL(1, 0));
assertEquals(MIL(1, 1), MIL(1, 1));
assertNotEquals(MIL(1, 0), MIL(1, 1));
assertNotEquals(MIL(0, 1), MIL(1, 1));
assertNotEquals(MIL(0, 0), MIL(1, 1));
assertEquals(new TIntLongHashMap(), new TIntLongHashMap());
}
public static TIntLongMap MIL(long... elements) {
int hashSize = elements.length / 2;
TIntLongMap result = new TIntLongHashMap(hashSize);
for (int i = 0; i < hashSize; i++) {
//noinspection unchecked
result.put((int) elements[i * 2], elements[i * 2 + 1]);
}
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment