equal
deleted
inserted
replaced
666 /// This test terminates almost surely. |
666 /// This test terminates almost surely. |
667 #[test] |
667 #[test] |
668 fn test_handle_rnd_nonempty() { |
668 fn test_handle_rnd_nonempty() { |
669 run_handle_test(vec!["A".to_owned(), "B".to_owned(), "C".to_owned()]) |
669 run_handle_test(vec!["A".to_owned(), "B".to_owned(), "C".to_owned()]) |
670 } |
670 } |
671 |
671 } |
672 /// This test terminates almost surely (strong law of large numbers) |
|
673 #[test] |
|
674 fn test_distribution() { |
|
675 let eps = 0.000001; |
|
676 let lim = 0.5; |
|
677 let opts = vec![0.to_string(), 1.to_string()]; |
|
678 let mut ones = 0; |
|
679 let mut tries = 0; |
|
680 |
|
681 while tries < 1000 || ((ones as f64 / tries as f64) - lim).abs() >= eps { |
|
682 tries += 1; |
|
683 if reply2string(rnd_reply(&opts)) == 1.to_string() { |
|
684 ones += 1; |
|
685 } |
|
686 } |
|
687 } |
|
688 } |
|