@Test public void testBasic() throws IOException { PairOfLongInt pair = new PairOfLongInt(1L, 2); assertEquals(1L, pair.getLeftElement()); assertEquals(2L, pair.getRightElement()); }
@Test public void testComparison1() throws IOException { PairOfLongInt pair1 = new PairOfLongInt(1L, 2); PairOfLongInt pair2 = new PairOfLongInt(1L, 2); PairOfLongInt pair3 = new PairOfLongInt(1L, 1); PairOfLongInt pair4 = new PairOfLongInt(0L, 9); PairOfLongInt pair5 = new PairOfLongInt(9L, 0); assertTrue(pair1.equals(pair2)); assertFalse(pair1.equals(pair3)); assertTrue(pair1.compareTo(pair2) == 0); assertTrue(pair1.compareTo(pair3) > 0); assertTrue(pair1.compareTo(pair4) > 0); assertTrue(pair1.compareTo(pair5) < 0); assertTrue(pair3.compareTo(pair4) > 0); assertTrue(pair4.compareTo(pair5) < 0); }
@Test public void testSerialize() throws IOException { PairOfLongInt origPair = new PairOfLongInt(1L, 2); ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); DataOutputStream dataOut = new DataOutputStream(bytesOut); origPair.write(dataOut); PairOfLongInt pair = new PairOfLongInt(); pair.readFields(new DataInputStream(new ByteArrayInputStream(bytesOut.toByteArray()))); assertEquals(1L, pair.getLeftElement()); assertEquals(2L, pair.getRightElement()); }