mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-22 15:16:40 +11:00
Add quickcheck tests for agb_hashmap (#769)
Thought I'd add a quick property test for the hashmap. Inspired by Jonhoo's most recent stream - [x] no changelog update needed
This commit is contained in:
commit
c97f75a593
2 changed files with 16 additions and 0 deletions
|
@ -16,3 +16,4 @@ rustc-hash = { version = "1", default-features = false }
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
rand = { version = "0.8", default-features = false, features = ["small_rng"] }
|
rand = { version = "0.8", default-features = false, features = ["small_rng"] }
|
||||||
lazy_static = "1.4"
|
lazy_static = "1.4"
|
||||||
|
quickcheck = "1"
|
||||||
|
|
|
@ -1453,4 +1453,19 @@ mod test {
|
||||||
assert_eq!(format!("{empty:?}"), "{}");
|
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…
Add table
Reference in a new issue