-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathgroup_test.go
More file actions
42 lines (34 loc) · 780 Bytes
/
group_test.go
File metadata and controls
42 lines (34 loc) · 780 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
package errs
import (
"fmt"
"strings"
"testing"
)
func TestGroup(t *testing.T) {
alpha := New("alpha")
beta := New("beta")
var group Group
group.Add(nil, nil, nil)
if group.Err() != nil {
t.Fatal("expected nil")
}
group.Add(alpha)
if group.Err() != alpha {
t.Fatal("expected alpha")
}
group.Add(nil, beta)
if group.Err().Error() != "alpha; beta" {
t.Fatal("expected \"group: alpha; beta\"")
}
if fmt.Sprintf("%v", group.Err()) != "alpha; beta" {
t.Fatal("expected \"group: alpha; beta\"")
}
if strings.Count(fmt.Sprintf("%+v", group.Err()), "\n") <= 1 {
t.Fatal("expected multiple lines with +v")
}
t.Logf("%%v:\n%v", group.Err())
t.Logf("%%+v:\n%+v", group.Err())
if Unwrap(group.Err()) != Unwrap(alpha) {
t.Fatal("expected alpha")
}
}