浏览代码

also add a test for non power of 2 N for good measure

fleandro 8 月之前
父节点
当前提交
1550eced04
共有 1 个文件被更改,包括 31 次插入0 次删除
  1. 31 0
      tests/core/runtime/test_core_runtime.odin

+ 31 - 0
tests/core/runtime/test_core_runtime.odin

@@ -109,6 +109,37 @@ test_map_get :: proc(t: ^testing.T) {
 		check(t, m)
 	}
 
+
+	// small keys; 3 values per cell
+	{
+		val :: struct #packed {
+			a, b: int,
+			c:    i32,
+		}
+		m := map[int]val{
+			1 = val{10, 100, 1000},
+			2 = val{20, 200, 2000},
+			3 = val{30, 300, 3000},
+		}
+		defer delete(m)
+		check(t, m)
+	}
+
+	// 3 keys per cell; small values
+	{
+		key :: struct #packed {
+			a, b: int,
+			c:    i32,
+		}
+		m := map[key]int{
+			key{10, 100, 1000} = 1,
+			key{20, 200, 2000} = 2,
+			key{30, 300, 3000} = 3,
+		}
+		defer delete(m)
+		check(t, m)
+	}
+
 	// small keys; value bigger than a chacheline
 	{
 		m := map[int][9]int{