@@ -358,7 +358,7 @@ impl<C: GeoConfig<Diff>> Count<Diff> for GeoDiffCount<'_, C> {
358358#[ cfg( test) ]
359359mod tests {
360360 use itertools:: Itertools ;
361- use rand:: { RngCore , SeedableRng } ;
361+ use rand:: RngCore ;
362362
363363 use crate :: {
364364 build_hasher:: UnstableDefaultBuildHasher ,
@@ -462,29 +462,30 @@ mod tests {
462462
463463 #[ test]
464464 fn test_estimate_diff_size_fast ( ) {
465- let mut rnd = rand :: rngs :: StdRng :: from_os_rng ( ) ;
466- let mut a_p = GeoDiffCount7_50 :: default ( ) ;
467- let mut a_hp = GeoDiffCount7 :: default ( ) ;
468- let mut b_p = GeoDiffCount7_50 :: default ( ) ;
469- let mut b_hp = GeoDiffCount7 :: default ( ) ;
470- for _ in 0 ..10000 {
471- let hash = rnd. next_u64 ( ) ;
472- a_p. push_hash ( hash) ;
473- a_hp. push_hash ( hash) ;
474- }
475- for _ in 0 ..1000 {
476- let hash = rnd. next_u64 ( ) ;
477- b_p. push_hash ( hash) ;
478- b_hp. push_hash ( hash) ;
479- }
480- let c_p = xor ( & a_p, & b_p) ;
481- let c_hp = xor ( & a_hp, & b_hp) ;
465+ prng_test_harness ( | rnd| {
466+ let mut a_p = GeoDiffCount7_50 :: default ( ) ;
467+ let mut a_hp = GeoDiffCount7 :: default ( ) ;
468+ let mut b_p = GeoDiffCount7_50 :: default ( ) ;
469+ let mut b_hp = GeoDiffCount7 :: default ( ) ;
470+ for _ in 0 ..10000 {
471+ let hash = rnd. next_u64 ( ) ;
472+ a_p. push_hash ( hash) ;
473+ a_hp. push_hash ( hash) ;
474+ }
475+ for _ in 0 ..1000 {
476+ let hash = rnd. next_u64 ( ) ;
477+ b_p. push_hash ( hash) ;
478+ b_hp. push_hash ( hash) ;
479+ }
480+ let c_p = xor ( & a_p, & b_p) ;
481+ let c_hp = xor ( & a_hp, & b_hp) ;
482482
483- assert_eq ! ( c_p. size( ) , a_p. size_with_sketch( & b_p) ) ;
484- assert_eq ! ( c_p. size( ) , b_p. size_with_sketch( & a_p) ) ;
483+ assert_eq ! ( c_p. size( ) , a_p. size_with_sketch( & b_p) ) ;
484+ assert_eq ! ( c_p. size( ) , b_p. size_with_sketch( & a_p) ) ;
485485
486- assert_eq ! ( c_hp. size( ) , a_hp. size_with_sketch( & b_hp) ) ;
487- assert_eq ! ( c_hp. size( ) , b_hp. size_with_sketch( & a_hp) ) ;
486+ assert_eq ! ( c_hp. size( ) , a_hp. size_with_sketch( & b_hp) ) ;
487+ assert_eq ! ( c_hp. size( ) , b_hp. size_with_sketch( & a_hp) ) ;
488+ } ) ;
488489 }
489490
490491 #[ test]
@@ -517,24 +518,19 @@ mod tests {
517518 #[ test]
518519 fn test_xor_plus_mask ( ) {
519520 for _ in 0 ..1000 {
520- prng_test_harness ( |mut rng | {
521+ prng_test_harness ( |rnd | {
521522 let mask_size = 12 ;
522523 let mask = 0b100001100000 ;
523524 let mut a = GeoDiffCount7 :: default ( ) ;
524525 for _ in 0 ..10000 {
525- a. xor_bit ( a. config . hash_to_bucket ( rng . next_u64 ( ) ) ) ;
526+ a. xor_bit ( a. config . hash_to_bucket ( rnd . next_u64 ( ) ) ) ;
526527 }
527528 let mut expected = GeoDiffCount7 :: default ( ) ;
528529 let mut b = a. clone ( ) ;
529530 for _ in 0 ..1000 {
530- let hash = rng . next_u64 ( ) ;
531+ let hash = rnd . next_u64 ( ) ;
531532 b. xor_bit ( b. config . hash_to_bucket ( hash) ) ;
532533 expected. xor_bit ( expected. config . hash_to_bucket ( hash) ) ;
533-
534- println ! ( "a -> {:?}" , a) ;
535- println ! ( "b -> {:?}" , b) ;
536- println ! ( "exp -> {:?}" , expected) ;
537-
538534 assert_eq ! ( expected, xor( & a, & b) ) ;
539535 let masked_a = masked ( & a, mask, mask_size) ;
540536 let masked_b = masked ( & b, mask, mask_size) ;
@@ -547,17 +543,18 @@ mod tests {
547543
548544 #[ test]
549545 fn test_bit_chunks ( ) {
550- let mut rnd = rand:: rngs:: StdRng :: from_os_rng ( ) ;
551546 for _ in 0 ..100 {
552- let mut expected = GeoDiffCount7 :: default ( ) ;
553- for _ in 0 ..1000 {
554- expected. push_hash ( rnd. next_u64 ( ) ) ;
555- }
556- let actual = GeoDiffCount :: from_bit_chunks (
557- expected. config . clone ( ) ,
558- expected. bit_chunks ( ) . peekable ( ) ,
559- ) ;
560- assert_eq ! ( expected, actual) ;
547+ prng_test_harness ( |rnd| {
548+ let mut expected = GeoDiffCount7 :: default ( ) ;
549+ for _ in 0 ..1000 {
550+ expected. push_hash ( rnd. next_u64 ( ) ) ;
551+ }
552+ let actual = GeoDiffCount :: from_bit_chunks (
553+ expected. config . clone ( ) ,
554+ expected. bit_chunks ( ) . peekable ( ) ,
555+ ) ;
556+ assert_eq ! ( expected, actual) ;
557+ } ) ;
561558 }
562559 }
563560
0 commit comments