-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mirror_test.go
46 lines (40 loc) · 937 Bytes
/
mirror_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
38
39
40
41
42
43
44
45
46
// Copyright 2022 Ainsley Clark. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package errors
import (
"fmt"
"reflect"
"testing"
)
func TestNew(t *testing.T) {
want := fmt.Errorf("error")
got := New("error")
if !reflect.DeepEqual(want, got) {
t.Fatalf("expecting %s, got %s", want, got)
}
}
func TestUnwrap(t *testing.T) {
e := NewE(fmt.Errorf("error"), "message", "op")
got := Unwrap(e)
want := "error"
if !reflect.DeepEqual(want, got.Error()) {
t.Fatalf("expecting %s, got %s", want, got.Error())
}
}
func TestIs(t *testing.T) {
err := fmt.Errorf("error")
e := NewE(err, "message", "op")
got := Is(e, err)
if !got {
t.Fatalf("expecting true, got %t", got)
}
}
func TestAs(t *testing.T) {
err := fmt.Errorf("error")
e := NewE(err, "message", "op")
got := As(e, &err)
if !got {
t.Fatalf("expecting true, got %t", got)
}
}