-
Notifications
You must be signed in to change notification settings - Fork 44
/
errors_test.go
37 lines (35 loc) · 778 Bytes
/
errors_test.go
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
package tc
import (
"errors"
"fmt"
"io"
"os"
"testing"
)
func TestConcatError(t *testing.T) {
t.Run("nil + nil", func(t *testing.T) {
result := concatError(nil, nil)
if result != nil {
t.Fatalf("expected nil but got %v", result)
}
})
t.Run("io.EOF + nil", func(t *testing.T) {
result := concatError(io.EOF, nil)
if !errors.Is(result, io.EOF) {
t.Fatalf("expected io.EOF but got %v", result)
}
})
t.Run("nil + io.EOF", func(t *testing.T) {
result := concatError(nil, io.EOF)
if !errors.Is(result, io.EOF) {
t.Fatalf("expected io.EOF but got %v", result)
}
})
t.Run("io.EOF + os.ErrPermission", func(t *testing.T) {
result := concatError(io.EOF, os.ErrPermission)
fmt.Println(result)
// Output:
// EOF
// permission denied
})
}