mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-16 13:05:18 +03:00
stdlib: Add regression tests for std::map
This commit is contained in:
@@ -342,8 +342,26 @@ fn hash(&uint u) -> uint {
|
||||
log "*** finished test_removal";
|
||||
}
|
||||
|
||||
fn test_contains_key() {
|
||||
auto key = "k";
|
||||
auto map = map::mk_hashmap[str, str](str::hash, str::eq);
|
||||
assert (!map.contains_key(key));
|
||||
map.insert(key, "val");
|
||||
assert (map.contains_key(key));
|
||||
}
|
||||
|
||||
fn test_find() {
|
||||
auto key = "k";
|
||||
auto map = map::mk_hashmap[str, str](str::hash, str::eq);
|
||||
assert (std::option::is_none(map.find(key)));
|
||||
map.insert(key, "val");
|
||||
assert (std::option::get(map.find(key)) == "val");
|
||||
}
|
||||
|
||||
fn main() {
|
||||
test_simple();
|
||||
test_growth();
|
||||
test_removal();
|
||||
test_contains_key();
|
||||
test_find();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user