Created
June 24, 2013 22:53
-
-
Save bitkid/5854451 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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