public void testLongConversionAndOrdering() throws Exception {
  BytesRef previous=null;
  BytesRef current=new BytesRef(new byte[Long.BYTES]);
  for (long value=-100000L; value < 100000L; value++) {
    NumericUtils.longToSortableBytes(value,current.bytes,current.offset);
    if (previous == null) {
      previous=new BytesRef(new byte[Long.BYTES]);
    }
 else {
      assertTrue("current bigger than previous: ",previous.compareTo(current) < 0);
    }
    assertEquals("forward and back conversion should generate same long",value,NumericUtils.sortableBytesToLong(current.bytes,current.offset));
    System.arraycopy(current.bytes,current.offset,previous.bytes,previous.offset,current.length);
  }
}

public void testLongConversionAndOrdering ( ) throws Exception { BytesRef previous = null ; BytesRef current = new BytesRef ( new byte [ Long . BYTES ] ) ; for ( long value = - 100000L ; value < 100000L ; value ++ ) { NumericUtils . longToSortableBytes ( value , current . bytes , current . offset ) ; if ( previous == null ) { previous = new BytesRef ( new byte [ Long . BYTES ] ) ; } else { assertTrue ( "current bigger than previous: " , previous . compareTo ( current ) < 0 ) ; } assertEquals ( "forward and back conversion should generate same long" , value , NumericUtils . sortableBytesToLong ( current . bytes , current . offset ) ) ; System . arraycopy ( current . bytes , current . offset , previous . bytes , previous . offset , current . length ) ; } }
generate a series of encoded longs , each numerical one bigger than the one before . check for correct ordering of the encoded bytes and that values round - trip .
