@Test
public void testCompare() throws Exception {

  byte[][] values = new byte[][]{"abc".getBytes(), 
                                 "ad".getBytes(),
                                 "abcd".getBytes(),
                                 "".getBytes(),
                                 "b".getBytes()};
  BytesWritable[] buf = new BytesWritable[values.length];
  for(int i=0; i < values.length; ++i) {
    buf[i] = new BytesWritable(values[i]);
  }
  // check to make sure the compare function is symetric and reflexive
  for(int i=0; i < values.length; ++i) {
    for(int j=0; j < values.length; ++j) {
      assertTrue(buf[i].compareTo(buf[j]) == -buf[j].compareTo(buf[i]));
      assertTrue((i == j) == (buf[i].compareTo(buf[j]) == 0));
    }
  }
  assertTrue(buf[0].compareTo(buf[1]) < 0);
  assertTrue(buf[1].compareTo(buf[2]) > 0);
  assertTrue(buf[2].compareTo(buf[3]) > 0);
  assertTrue(buf[3].compareTo(buf[4]) < 0);
}