diff options
| author | Phil <homan.phil@gmail.com> | 2022-09-01 12:32:33 -0700 |
|---|---|---|
| committer | Phil <homan.phil@gmail.com> | 2022-09-01 12:32:33 -0700 |
| commit | 63eec25044d1abc6665ce8409c21e6d58e6aca8a (patch) | |
| tree | b1030630d34dd22e9d25f9e91b12843772b9d005 /tests | |
| parent | 7a9b0731cf6e57043c46b8cf4e7b4dba0e4af7c1 (diff) | |
add sort_by_indices overload and test
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/core/slice/test_core_slice.odin | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/core/slice/test_core_slice.odin b/tests/core/slice/test_core_slice.odin index fb13364fd..8ef3af869 100644 --- a/tests/core/slice/test_core_slice.odin +++ b/tests/core/slice/test_core_slice.odin @@ -155,5 +155,21 @@ test_sort_by_indices :: proc(t: ^testing.T) { } } } + { + indices := make([]int, test_size) + swap := make([]int, test_size) + for _, i in indices { + indices[i] = i + } + + slice.sort_by_indices(indices, swap, f_idx) + for v, i in swap { + idx_pass := v == f_idx[i] + expect(t, idx_pass, "Expected the sorted index to be the same as the result from sort_with_indices") + if !idx_pass { + break + } + } + } } } |