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
|
package lib
import (
"errors"
"testing"
)
func TestErrors(t *testing.T) {
tests := []struct {
name string
err error
}{
{"ErrDuplicatedConverter", ErrDuplicatedConverter},
{"ErrUnknownAction", ErrUnknownAction},
{"ErrNotSupportedFormat", ErrNotSupportedFormat},
{"ErrInvalidIPType", ErrInvalidIPType},
{"ErrInvalidIP", ErrInvalidIP},
{"ErrInvalidIPLength", ErrInvalidIPLength},
{"ErrInvalidIPNet", ErrInvalidIPNet},
{"ErrInvalidCIDR", ErrInvalidCIDR},
{"ErrInvalidPrefix", ErrInvalidPrefix},
{"ErrInvalidPrefixType", ErrInvalidPrefixType},
{"ErrCommentLine", ErrCommentLine},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if tt.err == nil {
t.Errorf("%s should not be nil", tt.name)
}
if !errors.Is(tt.err, tt.err) {
t.Errorf("%s should match itself", tt.name)
}
})
}
}
|