1 #![cfg(not(miri))] // FIXME: takes too long
2 
3 use hashbrown::HashSet;
4 use rand::{distributions::Alphanumeric, rngs::SmallRng, Rng, SeedableRng};
5 
6 #[test]
test_hashset_insert_remove()7 fn test_hashset_insert_remove() {
8     let mut m: HashSet<Vec<char>> = HashSet::new();
9     //let num: u32 = 4096;
10     //let tx: Vec<Vec<u8>> = (0..num).map(|i| (i..(16 + i)).collect()).collect();
11     let seed: [u8; 16] = [
12         130, 220, 246, 217, 111, 124, 221, 189, 190, 234, 121, 93, 67, 95, 100, 43,
13     ];
14 
15     let rng = &mut SmallRng::from_seed(seed);
16     let tx: Vec<Vec<char>> = (0..4096)
17         .map(|_| (rng.sample_iter(&Alphanumeric).take(32).collect()))
18         .collect();
19 
20     for _ in 0..32 {
21         for i in 0..4096 {
22             assert_eq!(m.contains(&tx[i].clone()), false);
23             assert_eq!(m.insert(tx[i].clone()), true);
24         }
25         for i in 0..4096 {
26             println!("removing {} {:?}", i, tx[i]);
27             assert_eq!(m.remove(&tx[i]), true);
28         }
29     }
30 }
31