vfmt cfns_wrapper.c.v and sort_with_compare_context_test.v
parent
7993ff295e
commit
ede2b798f6
|
@ -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 FnSortCB = fn (const_a voidptr, const_b voidptr) int
|
||||||
|
|
||||||
type FnSortContextCB = fn (const_a voidptr, const_b voidptr, context 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)
|
fn C.vqsort_r(base voidptr, nel usize, width usize, cb FnSortContextCB, context voidptr)
|
||||||
|
|
||||||
[inline; unsafe]
|
[inline; unsafe]
|
||||||
|
|
|
@ -29,14 +29,14 @@ fn test_sort_with_compare() {
|
||||||
dump(a)
|
dump(a)
|
||||||
dump(context)
|
dump(context)
|
||||||
assert a == ['1', '3', '5', 'hi']
|
assert a == ['1', '3', '5', 'hi']
|
||||||
|
|
||||||
assert context.comparisons == [
|
assert context.comparisons == [
|
||||||
'a: "5" | b: "hi"',
|
'a: "5" | b: "hi"',
|
||||||
'a: "hi" | b: "1"',
|
'a: "hi" | b: "1"',
|
||||||
'a: "hi" | b: "3"',
|
'a: "hi" | b: "3"',
|
||||||
'a: "3" | b: "5"',
|
'a: "3" | b: "5"',
|
||||||
'a: "5" | b: "1"',
|
'a: "5" | b: "1"',
|
||||||
'a: "3" | b: "1"'
|
'a: "3" | b: "1"',
|
||||||
]
|
]
|
||||||
//
|
//
|
||||||
mut already_sorted_context := Context{}
|
mut already_sorted_context := Context{}
|
||||||
|
@ -48,6 +48,6 @@ fn test_sort_with_compare() {
|
||||||
'a: "5" | b: "1"',
|
'a: "5" | b: "1"',
|
||||||
'a: "5" | b: "3"',
|
'a: "5" | b: "3"',
|
||||||
'a: "5" | b: "hi"',
|
'a: "5" | b: "hi"',
|
||||||
'a: "1" | b: "3"'
|
'a: "1" | b: "3"',
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue