mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 00:01:34 +11:00
Add quickcheck tests for agb_hashmap
This commit is contained in:
parent
7202fc0119
commit
d17c14c7d3
|
@ -16,3 +16,4 @@ rustc-hash = { version = "1", default-features = false }
|
|||
[dev-dependencies]
|
||||
rand = { version = "0.8", default-features = false, features = ["small_rng"] }
|
||||
lazy_static = "1.4"
|
||||
quickcheck = "1"
|
||||
|
|
|
@ -1453,4 +1453,19 @@ mod test {
|
|||
assert_eq!(format!("{empty:?}"), "{}");
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(miri))]
|
||||
quickcheck::quickcheck! {
|
||||
fn test_against_btree_map(entries: Vec<(u8, u32)>) -> bool {
|
||||
let std_hashmap = alloc::collections::BTreeMap::from_iter(entries.clone());
|
||||
let agb_hashmap = HashMap::from_iter(entries);
|
||||
|
||||
if std_hashmap.len() != agb_hashmap.len() {
|
||||
return false;
|
||||
}
|
||||
|
||||
std_hashmap.iter().all(|(key, value)| agb_hashmap.get(key) == Some(value)) &&
|
||||
agb_hashmap.iter().all(|(key, value)| std_hashmap.get(key) == Some(value))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue