@@ -432,35 +432,39 @@ mod tests {
432432
433433 #[ test]
434434 fn test_estimate_fast ( ) {
435- let ( avg_precision, avg_var) = test_estimate ( GeoDiffCount7 :: default) ;
436- println ! (
437- "avg precision: {} with standard deviation: {}" ,
438- avg_precision,
439- avg_var. sqrt( ) ,
440- ) ;
441- // Make sure that the estimate converges to the correct value.
442- assert ! ( avg_precision. abs( ) < 0.04 ) ;
443- // We should theoretically achieve a standard deviation of about 0.12
444- assert ! ( avg_var. sqrt( ) < 0.14 ) ;
435+ prng_test_harness ( 1 , |rnd| {
436+ let ( avg_precision, avg_var) = test_estimate ( rnd, GeoDiffCount7 :: default) ;
437+ println ! (
438+ "avg precision: {} with standard deviation: {}" ,
439+ avg_precision,
440+ avg_var. sqrt( ) ,
441+ ) ;
442+ // Make sure that the estimate converges to the correct value.
443+ assert ! ( avg_precision. abs( ) < 0.04 ) ;
444+ // We should theoretically achieve a standard deviation of about 0.12
445+ assert ! ( avg_var. sqrt( ) < 0.14 ) ;
446+ } )
445447 }
446448
447449 #[ test]
448450 fn test_estimate_fast_low_precision ( ) {
449- let ( avg_precision, avg_var) = test_estimate ( GeoDiffCount7_50 :: default) ;
450- println ! (
451- "avg precision: {} with standard deviation: {}" ,
452- avg_precision,
453- avg_var. sqrt( ) ,
454- ) ;
455- // Make sure that the estimate converges to the correct value.
456- assert ! ( avg_precision. abs( ) < 0.15 ) ;
457- // We should theoretically achieve a standard deviation of about 0.25
458- assert ! ( avg_var. sqrt( ) < 0.4 ) ;
451+ prng_test_harness ( 1 , |rnd| {
452+ let ( avg_precision, avg_var) = test_estimate ( rnd, GeoDiffCount7_50 :: default) ;
453+ println ! (
454+ "avg precision: {} with standard deviation: {}" ,
455+ avg_precision,
456+ avg_var. sqrt( ) ,
457+ ) ;
458+ // Make sure that the estimate converges to the correct value.
459+ assert ! ( avg_precision. abs( ) < 0.15 ) ;
460+ // We should theoretically achieve a standard deviation of about 0.25
461+ assert ! ( avg_var. sqrt( ) < 0.4 ) ;
462+ } ) ;
459463 }
460464
461465 #[ test]
462466 fn test_estimate_diff_size_fast ( ) {
463- prng_test_harness ( |rnd| {
467+ prng_test_harness ( 1 , |rnd| {
464468 let mut a_p = GeoDiffCount7_50 :: default ( ) ;
465469 let mut a_hp = GeoDiffCount7 :: default ( ) ;
466470 let mut b_p = GeoDiffCount7_50 :: default ( ) ;
@@ -515,45 +519,41 @@ mod tests {
515519
516520 #[ test]
517521 fn test_xor_plus_mask ( ) {
518- for _ in 0 ..1000 {
519- prng_test_harness ( |rnd| {
520- let mask_size = 12 ;
521- let mask = 0b100001100000 ;
522- let mut a = GeoDiffCount7 :: default ( ) ;
523- for _ in 0 ..10000 {
524- a. xor_bit ( a. config . hash_to_bucket ( rnd. next_u64 ( ) ) ) ;
525- }
526- let mut expected = GeoDiffCount7 :: default ( ) ;
527- let mut b = a. clone ( ) ;
528- for _ in 0 ..1000 {
529- let hash = rnd. next_u64 ( ) ;
530- b. xor_bit ( b. config . hash_to_bucket ( hash) ) ;
531- expected. xor_bit ( expected. config . hash_to_bucket ( hash) ) ;
532- assert_eq ! ( expected, xor( & a, & b) ) ;
533- let masked_a = masked ( & a, mask, mask_size) ;
534- let masked_b = masked ( & b, mask, mask_size) ;
535- let masked_expected = masked ( & expected, mask, mask_size) ;
536- assert_eq ! ( masked_expected, xor( & masked_a, & masked_b) ) ;
537- }
538- } ) ;
539- }
522+ prng_test_harness ( 1000 , |rnd| {
523+ let mask_size = 12 ;
524+ let mask = 0b100001100000 ;
525+ let mut a = GeoDiffCount7 :: default ( ) ;
526+ for _ in 0 ..10000 {
527+ a. xor_bit ( a. config . hash_to_bucket ( rnd. next_u64 ( ) ) ) ;
528+ }
529+ let mut expected = GeoDiffCount7 :: default ( ) ;
530+ let mut b = a. clone ( ) ;
531+ for _ in 0 ..1000 {
532+ let hash = rnd. next_u64 ( ) ;
533+ b. xor_bit ( b. config . hash_to_bucket ( hash) ) ;
534+ expected. xor_bit ( expected. config . hash_to_bucket ( hash) ) ;
535+ assert_eq ! ( expected, xor( & a, & b) ) ;
536+ let masked_a = masked ( & a, mask, mask_size) ;
537+ let masked_b = masked ( & b, mask, mask_size) ;
538+ let masked_expected = masked ( & expected, mask, mask_size) ;
539+ assert_eq ! ( masked_expected, xor( & masked_a, & masked_b) ) ;
540+ }
541+ } ) ;
540542 }
541543
542544 #[ test]
543545 fn test_bit_chunks ( ) {
544- for _ in 0 ..100 {
545- prng_test_harness ( |rnd| {
546- let mut expected = GeoDiffCount7 :: default ( ) ;
547- for _ in 0 ..1000 {
548- expected. push_hash ( rnd. next_u64 ( ) ) ;
549- }
550- let actual = GeoDiffCount :: from_bit_chunks (
551- expected. config . clone ( ) ,
552- expected. bit_chunks ( ) . peekable ( ) ,
553- ) ;
554- assert_eq ! ( expected, actual) ;
555- } ) ;
556- }
546+ prng_test_harness ( 100 , |rnd| {
547+ let mut expected = GeoDiffCount7 :: default ( ) ;
548+ for _ in 0 ..1000 {
549+ expected. push_hash ( rnd. next_u64 ( ) ) ;
550+ }
551+ let actual = GeoDiffCount :: from_bit_chunks (
552+ expected. config . clone ( ) ,
553+ expected. bit_chunks ( ) . peekable ( ) ,
554+ ) ;
555+ assert_eq ! ( expected, actual) ;
556+ } ) ;
557557 }
558558
559559 #[ test]
0 commit comments