...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package name
16
17 import (
18 "errors"
19 "testing"
20 )
21
22 func TestBadName(t *testing.T) {
23 _, err := ParseReference("@@")
24 if !IsErrBadName(err) {
25 t.Errorf("Not an ErrBadName: %v", err)
26 }
27 var berr *ErrBadName
28 if !errors.As(err, &berr) {
29 t.Errorf("Not an ErrBadName using errors.As: %v", err)
30 }
31 if err.Error() != "could not parse reference: @@" {
32 t.Errorf("Unexpected string: %v", err)
33 }
34 if !errors.Is(err, &ErrBadName{}) {
35 t.Errorf("Not an ErrBadName using errors.Is: %v", err)
36 }
37 }
38
View as plain text