-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors_test.go
More file actions
39 lines (32 loc) · 973 Bytes
/
Copy patherrors_test.go
File metadata and controls
39 lines (32 loc) · 973 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
package phudong
import (
"errors"
"testing"
)
func TestErrorString(t *testing.T) {
if ErrNoFunctionSet.Error() != "no function set to execute" {
t.Errorf("Expected 'no function set to execute', got %s", ErrNoFunctionSet.Error())
}
var unknownError Error = 255
if unknownError.Error() != "unknown error" {
t.Errorf("Expected 'unknown error', got %s", unknownError.Error())
}
}
func TestErrorIs(t *testing.T) {
if !ErrNoFunctionSet.Is(ErrNoFunctionSet) {
t.Error("ErrNoFunctionSet should be equal to itself")
}
if ErrNoFunctionSet.Is(errors.New("different error")) {
t.Error("ErrNoFunctionSet should not be equal to different error")
}
var unknownError Error = 255
if unknownError.Is(ErrNoFunctionSet) {
t.Error("Unknown error should not be equal to ErrNoFunctionSet")
}
}
func TestErrorType(t *testing.T) {
var err error = ErrNoFunctionSet
if !errors.Is(err, ErrNoFunctionSet) {
t.Error("Error should be identifiable with errors.Is")
}
}