@@ -1439,15 +1439,33 @@ public void testNextWindowedIntTriple_SR() {
14391439 final int REPS_PER_BUCKET = 100 ;
14401440 final int TRIALS = 100 ;
14411441
1442- // Make sure sorting covers all cases:
1442+
14431443 {
1444- for (int i = 0 ; i < 30 ; i ++) {
1444+ // Make sure sorting covers all cases:
1445+ // This part of the test aims to fully cover the
1446+ // helper method: sortSetAndAdjustWindowedTriple
1447+
1448+ // This is the easy path through the method, even one sample
1449+ // should be sufficient with n=3 and w=2.
1450+ for (int i = 0 ; i < 3 ; i ++) {
14451451 int [] result = RandomIndexer .nextWindowedIntTriple (3 , 2 , null , true , gen );
14461452 assertEquals ("Length of result should be 3" , 3 , result .length );
14471453 assertEquals (0 , result [0 ]);
14481454 assertEquals (1 , result [1 ]);
14491455 assertEquals (2 , result [2 ]);
14501456 }
1457+
1458+ // With n=100 and w=n-1, approximately 97% of the following samples should
1459+ // go through the alternate path from above. That alternate path has
1460+ // 6 potential subpaths, all approximately equally likely.
1461+ int n = 100 ;
1462+ int w = n -1 ;
1463+ for (int i = 0 ; i < 30 ; i ++) {
1464+ int [] result = RandomIndexer .nextWindowedIntTriple (n , w , null , true , gen );
1465+ assertEquals ("Length of result should be 3" , 3 , result .length );
1466+ assertTrue (result [0 ] < result [1 ]);
1467+ assertTrue (result [1 ] < result [2 ]);
1468+ }
14511469 }
14521470
14531471 for (int n = 3 ; n <= 10 ; n ++) {
0 commit comments