diff options
| author | Phil <homan.phil@gmail.com> | 2022-09-01 11:46:59 -0700 |
|---|---|---|
| committer | Phil <homan.phil@gmail.com> | 2022-09-01 11:46:59 -0700 |
| commit | 002bec256adcfa1ff41ba1437dbe912ae01ee8c5 (patch) | |
| tree | 2f48a843c4a5e2583449dab2f1f5fb938adbd5f8 /tests | |
| parent | 000861cba8ab5c966c60b3a3869d91e98ad09ddc (diff) | |
have sort_with_indices allocate. Add a couple convenience procs for using the indices result to sort other slices.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/core/slice/test_core_slice.odin | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/tests/core/slice/test_core_slice.odin b/tests/core/slice/test_core_slice.odin index 12577ab20..8caf911e8 100644 --- a/tests/core/slice/test_core_slice.odin +++ b/tests/core/slice/test_core_slice.odin @@ -51,23 +51,17 @@ test_sort_with_indices :: proc(t: ^testing.T) { r := rand.create(seed) vals := make([]u64, test_size) - f_idx := make([]int, test_size) // Forward index, will be sorted + defer delete(vals) r_idx := make([]int, test_size) // Reverse index - defer { - delete(vals) - delete(f_idx) - delete(r_idx) - } - // Set up test values for _, i in vals { vals[i] = rand.uint64(&r) - f_idx[i] = i } // Sort - slice.sort_with_indices(vals, f_idx) + f_idx := slice.sort_with_indices(vals) + defer delete(f_idx) // Verify sorted test values rand.init(&r, seed) @@ -94,4 +88,4 @@ test_sort_with_indices :: proc(t: ^testing.T) { last = v } } -}
\ No newline at end of file +} |