-
Notifications
You must be signed in to change notification settings - Fork 134
Expand file tree
/
Copy pathsort_test.go
More file actions
62 lines (51 loc) · 902 Bytes
/
sort_test.go
File metadata and controls
62 lines (51 loc) · 902 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright IBM Corp. 2014, 2025
// SPDX-License-Identifier: MPL-2.0
package multierror
import (
"errors"
"reflect"
"sort"
"testing"
)
func TestSortSingle(t *testing.T) {
errFoo := errors.New("foo")
expected := []error{
errFoo,
}
err := &Error{
Errors: []error{
errFoo,
},
}
sort.Sort(err)
if !reflect.DeepEqual(err.Errors, expected) {
t.Fatalf("bad: %#v", err)
}
}
func TestSortMultiple(t *testing.T) {
errBar := errors.New("bar")
errBaz := errors.New("baz")
errFoo := errors.New("foo")
expected := []error{
errBar,
errBaz,
errFoo,
}
err := &Error{
Errors: []error{
errFoo,
errBar,
errBaz,
},
}
sort.Sort(err)
if !reflect.DeepEqual(err.Errors, expected) {
t.Fatalf("bad: %#v", err)
}
}
func TestLenNil(t *testing.T) {
var err *Error
if err.Len() != 0 {
t.Fatalf("expected Len() to return 0 for nil *Error, got %d", err.Len())
}
}