1 // compile-flags: -Zmiri-seed=0000000000000000
3 use std::collections::{self, HashMap};
4 use std::hash::{BuildHasherDefault, BuildHasher};
6 fn test_map<S: BuildHasher>(mut map: HashMap<i32, i32, S>) {
8 assert_eq!(map.values().fold(0, |x, y| x+y), 0);
10 let table_base = map.get(&0).unwrap() as *const _;
12 let num = 22; // large enough to trigger a resize
16 assert!(table_base != map.get(&0).unwrap() as *const _); // make sure relocation happened
17 assert_eq!(map.values().fold(0, |x, y| x+y), num*(num-1)/2); // check the right things are in the table now
19 // Inserting again replaces the existing entries
21 map.insert(i, num-1-i);
23 assert_eq!(map.values().fold(0, |x, y| x+y), num*(num-1)/2);
25 // TODO: Test Entry API, Iterators, ...
30 // TODO: Implement random number generation on OS X
31 if cfg!(not(target_os = "macos")) {
32 let map_normal: HashMap<i32, i32> = HashMap::new();
35 let map : HashMap<i32, i32, BuildHasherDefault<collections::hash_map::DefaultHasher>> = Default::default();