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);
14 assert_eq!(map.values().fold(0, |x, y| x+y), num*(num-1)/2); // check the right things are in the table now
16 // Inserting again replaces the existing entries
18 map.insert(i, num-1-i);
20 assert_eq!(map.values().fold(0, |x, y| x+y), num*(num-1)/2);
22 // TODO: Test Entry API, Iterators, ...
27 if cfg!(target_os = "macos") { // TODO: Implement libstd HashMap seeding for macOS (https://github.com/rust-lang/miri/issues/686).
28 // Until then, use a deterministic map.
29 test_map::<BuildHasherDefault<collections::hash_map::DefaultHasher>>(HashMap::default());
31 test_map(HashMap::new());