diff options
| author | fleandro <3987005+flga@users.noreply.github.com> | 2025-01-03 15:33:34 +0000 |
|---|---|---|
| committer | fleandro <3987005+flga@users.noreply.github.com> | 2025-01-03 15:33:34 +0000 |
| commit | e3de02eaa8b69ae615c3df1177f44f326ca5ac44 (patch) | |
| tree | e8c5e9291f83584833c556f8b5b4f76dc45c00e6 /tests | |
| parent | fdd3b46c10dae9adbc1484a795ed119fbf4a0baa (diff) | |
runtime: map_cell_index_static produced wrong results when the number of elements per cell was a power of 2
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/core/runtime/test_core_runtime.odin | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/tests/core/runtime/test_core_runtime.odin b/tests/core/runtime/test_core_runtime.odin index 84fd044cf..bd641ab3a 100644 --- a/tests/core/runtime/test_core_runtime.odin +++ b/tests/core/runtime/test_core_runtime.odin @@ -63,4 +63,28 @@ test_init_cap_map_dynarray :: proc(t: ^testing.T) { defer delete(d2) testing.expect(t, cap(d2) == 0) testing.expect(t, d2.allocator.procedure == ally.procedure) -}
\ No newline at end of file +} + +@(test) +test_map_get :: proc(t: ^testing.T) { + m := map[int][3]int{ + 1 = {10, 100, 1000}, + 2 = {20, 200, 2000}, + 3 = {30, 300, 3000}, + } + + k1, v1, ok1 := runtime.map_get(m, 1) + testing.expect_value(t, k1, 1) + testing.expect_value(t, v1, [3]int{10, 100, 1000}) + testing.expect_value(t, ok1, true) + + k2, v2, ok2 := runtime.map_get(m, 2) + testing.expect_value(t, k2, 2) + testing.expect_value(t, v2, [3]int{20, 200, 2000}) + testing.expect_value(t, ok2, true) + + k3, v3, ok3 := runtime.map_get(m, 3) + testing.expect_value(t, k3, 3) + testing.expect_value(t, v3, [3]int{30, 300, 3000}) + testing.expect_value(t, ok3, true) +} |