Skip to content

Commit

Permalink
Testing
Browse files Browse the repository at this point in the history
  • Loading branch information
spiegel-im-spiegel committed Feb 25, 2019
1 parent 16cb69c commit 0c4cea3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
16 changes: 8 additions & 8 deletions cvsserr/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ func (n Num) Error() string {
}

func (n Num) Is(target error) bool {
var t1 *wrapError
var t1 Num
if errors.As(target, &t1) {
return n == t1.Num
return n == t1
}
var t2 Num
var t2 *wrapError
if errors.As(target, &t2) {
return n == t2
return n == t2.Num
}
return false
}
Expand All @@ -60,13 +60,13 @@ func (we *wrapError) FormatError(p errors.Printer) error {
}

func (we *wrapError) Is(target error) bool {
var t1 *wrapError
var t1 Num
if errors.As(target, &t1) {
return we.Num == t1.Num
return we.Num == t1
}
var t2 Num
var t2 *wrapError
if errors.As(target, &t2) {
return we.Num == t2
return we.Num == t2.Num
}
return false
}
Expand Down
12 changes: 12 additions & 0 deletions cvsserr/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ func TestErrorEquality(t *testing.T) {
{err1: New(ErrUndefinedMetric), err2: nil, res: false},
{err1: New(ErrInvalidVector), err2: nil, res: false},
{err1: New(ErrNotSupportVer), err2: nil, res: false},
{err1: New(ErrUndefinedMetric), err2: Num(4), res: false},
{err1: New(ErrInvalidVector), err2: Num(4), res: false},
{err1: New(ErrNotSupportVer), err2: Num(4), res: false},
{err1: New(ErrUndefinedMetric), err2: New(Num(4)), res: false},
{err1: New(ErrInvalidVector), err2: New(Num(4)), res: false},
{err1: New(ErrNotSupportVer), err2: New(Num(4)), res: false},
{err1: New(ErrUndefinedMetric), err2: os.ErrInvalid, res: false},
{err1: New(ErrInvalidVector), err2: os.ErrInvalid, res: false},
{err1: New(ErrNotSupportVer), err2: os.ErrInvalid, res: false},
Expand All @@ -75,6 +81,12 @@ func TestErrorEquality(t *testing.T) {
{err1: ErrUndefinedMetric, err2: nil, res: false},
{err1: ErrInvalidVector, err2: nil, res: false},
{err1: ErrNotSupportVer, err2: nil, res: false},
{err1: ErrUndefinedMetric, err2: Num(4), res: false},
{err1: ErrInvalidVector, err2: Num(4), res: false},
{err1: ErrNotSupportVer, err2: Num(4), res: false},
{err1: ErrUndefinedMetric, err2: New(Num(4)), res: false},
{err1: ErrInvalidVector, err2: New(Num(4)), res: false},
{err1: ErrNotSupportVer, err2: New(Num(4)), res: false},
{err1: ErrUndefinedMetric, err2: os.ErrInvalid, res: false},
{err1: ErrInvalidVector, err2: os.ErrInvalid, res: false},
{err1: ErrNotSupportVer, err2: os.ErrInvalid, res: false},
Expand Down

0 comments on commit 0c4cea3

Please sign in to comment.