@Test
public void testComparator() {

  byte[] foo   = new byte[1];
  foo[0] = (byte) 1;
  byte[] empty = new byte[0];
  GramKey a = new GramKey(new Gram("foo", 1, Gram.Type.HEAD), empty); // base
  GramKey b = new GramKey(new Gram("foo", 1, Gram.Type.HEAD), foo);   // vary byte
  GramKey c = new GramKey(new Gram("foo", 2, Gram.Type.HEAD), empty); // vary freq
  GramKey d = new GramKey(new Gram("foo", 1, Gram.Type.TAIL), empty); // vary type
  GramKey e = new GramKey(new Gram("bar", 5, Gram.Type.HEAD), empty); // vary string
  
  GramKeyGroupComparator cmp = new GramKeyGroupComparator();
  assertEquals(0, cmp.compare(a, b));
  assertEquals(0, cmp.compare(a, c));
  assertTrue(cmp.compare(a, d) < 0);
  assertTrue(cmp.compare(a, e) > 0);
  assertTrue(cmp.compare(d, e) > 0);
}