Skip to content

Commit

Permalink
Add test for op_set and op_get
Browse files Browse the repository at this point in the history
  • Loading branch information
yj-qin committed Mar 22, 2024
1 parent 5545a9a commit 84168f9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions hashmap/hashmap.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,23 @@ test "get" {
@assertion.assert_eq(m.get("d"), None)?
}

test "op_set" {
let m : HashMap[String, Int] = HashMap::new()
m["a"] = 1
m["b"] = 2
@assertion.assert_eq(m.get("a"), Some(1))?
@assertion.assert_eq(m.get("b"), Some(2))?
}

test "op_get" {
let m : HashMap[String, Int] = HashMap::new()
m.set("a", 1)
m.set("b", 2)
@assertion.assert_eq(m["a"], Some(1))?
@assertion.assert_eq(m["b"], Some(2))?
@assertion.assert_eq(m["c"], None)?
}

test "set_update" {
let m : HashMap[String, Int] = HashMap::new()
m.set("a", 1)
Expand Down

0 comments on commit 84168f9

Please sign in to comment.