public void test_huffmanCodecStress(){
  final int ntrials=10000;
  final Random r=new Random();
  for (int trial=0; trial < ntrials; trial++) {
    final int[] frequency=new int[r.nextInt(255) + 2];
    for (int i=0; i < frequency.length; i++) {
      if (r.nextFloat() < 0.001) {
        frequency[i]=0;
      }
 else {
        frequency[i]=r.nextInt(4000);
      }
    }
    doRoundTripTest(frequency);
  }
}

public void test_huffmanCodecStress ( ) { final int ntrials = 10000 ; final Random r = new Random ( ) ; for ( int trial = 0 ; trial < ntrials ; trial ++ ) { final int [ ] frequency = new int [ r . nextInt ( 255 ) + 2 ] ; for ( int i = 0 ; i < frequency . length ; i ++ ) { if ( r . nextFloat ( ) < 0.001 ) { frequency [ i ] = 0 ; } else { frequency [ i ] = r . nextInt ( 4000 ) ; } } doRoundTripTest ( frequency ) ; } }
stress test with random frequency distributions of between 2 and 256 distinct symbols . frequencies may be zero for some symbols . tests with zero and one symbols are done separately since both cases have errors .
