@Test
  public void testLong() throws IOException {
    // test writing and reading shorts.
    writer.writeLong(1);
    writer.writeLong(0xdeadbeefcafebabeL);
    writer.writeLong(0xffffffffffffffffL);
    writer.writeLong(-1234567890123456789L);
    writer.writeLong(0);

    BinaryReader reader = getReader();

    assertEquals(1, reader.expectLong());
    assertEquals(0xdeadbeefcafebabeL, reader.expectLong());
    assertEquals(0xffffffffffffffffL, reader.expectLong());
    assertEquals(-1234567890123456789L, reader.expectLong());
    assertEquals(0, reader.expectLong());
  }
 private void assertBadExpectLong(String message, byte[] data) {
   ByteArrayInputStream bais = new ByteArrayInputStream(data);
   try {
     BinaryReader reader = new BigEndianBinaryReader(bais);
     reader.expectLong();
     fail("No exception on bad long");
   } catch (IOException e) {
     assertEquals(message, e.getMessage());
   }
 }