vfmt cfns_wrapper.c.v and sort_with_compare_context_test.v

pull/13721/head
Delyan Angelov 2022-03-28 23:32:58 +03:00
parent 7993ff295e
commit ede2b798f6
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 5 additions and 3 deletions

View File

@ -68,7 +68,9 @@ pub fn vmemset(s voidptr, c int, n int) voidptr {
}
type FnSortCB = fn (const_a voidptr, const_b voidptr) int
type FnSortContextCB = fn (const_a voidptr, const_b voidptr, context voidptr) int
fn C.vqsort_r(base voidptr, nel usize, width usize, cb FnSortContextCB, context voidptr)
[inline; unsafe]

View File

@ -29,14 +29,14 @@ fn test_sort_with_compare() {
dump(a)
dump(context)
assert a == ['1', '3', '5', 'hi']
assert context.comparisons == [
'a: "5" | b: "hi"',
'a: "hi" | b: "1"',
'a: "hi" | b: "3"',
'a: "3" | b: "5"',
'a: "5" | b: "1"',
'a: "3" | b: "1"'
'a: "3" | b: "1"',
]
//
mut already_sorted_context := Context{}
@ -48,6 +48,6 @@ fn test_sort_with_compare() {
'a: "5" | b: "1"',
'a: "5" | b: "3"',
'a: "5" | b: "hi"',
'a: "1" | b: "3"'
'a: "1" | b: "3"',
]
}