From 84168f99f59ea2e9573631df98ee84176e85744f Mon Sep 17 00:00:00 2001 From: yj-qin Date: Thu, 21 Mar 2024 16:50:37 +0800 Subject: [PATCH] Add test for op_set and op_get --- hashmap/hashmap.mbt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/hashmap/hashmap.mbt b/hashmap/hashmap.mbt index 20a2d30ac..fbb67b926 100644 --- a/hashmap/hashmap.mbt +++ b/hashmap/hashmap.mbt @@ -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)