1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

builtin: add a test for the sorting of []u64 too

This commit is contained in:
Delyan Angelov 2020-12-05 23:21:20 +02:00
parent b99ea332f0
commit 1739b08e73
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

View File

@ -1,6 +1,6 @@
const (
unsorted = [2,30,10,20,1]
sorted_asc = [1, 2, 10, 20, 30]
unsorted = [2, 30, 10, 20, 1]
sorted_asc = [1, 2, 10, 20, 30]
sorted_desc = [30, 20, 10, 2, 1]
)
@ -13,13 +13,12 @@ fn test_sorting_simple() {
fn test_sorting_with_condition_expression() {
mut a := unsorted
a.sort(a>b)
a.sort(a > b)
eprintln(' a: $a')
assert a == sorted_desc
}
fn mysort (mut a []int) {
fn mysort(mut a []int) {
a.sort()
}
@ -38,3 +37,12 @@ fn test_sorting_by_passing_an_anonymous_sorting_function() {
assert a == sort_desc
}
*/
fn test_sorting_u64s() {
mut a := [u64(3), 2, 1, 9, 0, 8]
a.sort()
eprintln(' a: $a')
assert a == [u64(0), 1, 2, 3, 8, 9]
a.sort(a > b)
eprintln(' a: $a')
assert a == [u64(9), 8, 3, 2, 1, 0]
}