| 1 |
// Copyright (c) 2025, Maxime Soulé |
| 2 |
// All rights reserved. |
| 3 |
// |
| 4 |
// This source code is licensed under the BSD-style license found in the |
| 5 |
// LICENSE file in the root directory of this source tree. |
| 6 |
|
| 7 |
package sort_test |
| 8 |
|
| 9 |
import ( |
| 10 |
"reflect" |
| 11 |
"sort" |
| 12 |
"testing" |
| 13 |
|
| 14 |
tdsort "github.com/maxatome/go-testdeep/internal/sort" |
| 15 |
) |
| 16 |
|
| 17 |
func TestValues(t *testing.T) { |
| 18 |
s := []reflect.Value{ |
| 19 |
reflect.ValueOf(4), |
| 20 |
reflect.ValueOf(3), |
| 21 |
reflect.ValueOf(1), |
| 22 |
} |
| 23 |
sort.Sort(tdsort.Values(s)) |
| 24 |
if s[0].Int() != 1 || s[1].Int() != 3 || s[2].Int() != 4 { |
| 25 |
t.Errorf("sort error: [ %v, %v, %v ]", s[0].Int(), s[1].Int(), s[2].Int()) |
| 26 |
} |
| 27 |
|
| 28 |
s = []reflect.Value{ |
| 29 |
reflect.ValueOf(42), |
| 30 |
} |
| 31 |
sort.Sort(tdsort.Values(s)) |
| 32 |
if s[0].Int() != 42 { |
| 33 |
t.Errorf("sort error: [ %v ]", s[0].Int()) |
| 34 |
} |
| 35 |
|
| 36 |
sort.Sort(tdsort.Values(nil)) |
| 37 |
} |