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
47
48
49
50
51
52
53
54
55
|
package lib
import (
"testing"
)
func TestErrorVariables(t *testing.T) {
tests := []struct {
name string
err error
want string
}{
{"ErrDuplicatedConverter", ErrDuplicatedConverter, "duplicated converter"},
{"ErrUnknownAction", ErrUnknownAction, "unknown action"},
{"ErrNotSupportedFormat", ErrNotSupportedFormat, "not supported format"},
{"ErrInvalidIPType", ErrInvalidIPType, "invalid IP type"},
{"ErrInvalidIP", ErrInvalidIP, "invalid IP address"},
{"ErrInvalidIPLength", ErrInvalidIPLength, "invalid IP address length"},
{"ErrInvalidIPNet", ErrInvalidIPNet, "invalid IPNet address"},
{"ErrInvalidCIDR", ErrInvalidCIDR, "invalid CIDR"},
{"ErrInvalidPrefix", ErrInvalidPrefix, "invalid prefix"},
{"ErrInvalidPrefixType", ErrInvalidPrefixType, "invalid prefix type"},
{"ErrCommentLine", ErrCommentLine, "comment line"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if tt.err.Error() != tt.want {
t.Errorf("%s.Error() = %s, want %s", tt.name, tt.err.Error(), tt.want)
}
})
}
}
func TestErrorsAreNotNil(t *testing.T) {
errors := []error{
ErrDuplicatedConverter,
ErrUnknownAction,
ErrNotSupportedFormat,
ErrInvalidIPType,
ErrInvalidIP,
ErrInvalidIPLength,
ErrInvalidIPNet,
ErrInvalidCIDR,
ErrInvalidPrefix,
ErrInvalidPrefixType,
ErrCommentLine,
}
for _, err := range errors {
if err == nil {
t.Error("Expected error to be non-nil")
}
}
}
|