Skip to content

Commit b788876

Browse files
committed
Test utils.IsUnixAddr()
1 parent 1bc8c63 commit b788876

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

utils/utils_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,26 @@ func TestEllipsize(t *testing.T) {
157157
}
158158
}
159159

160+
func TestIsUnixAddr(t *testing.T) {
161+
subtests := []struct {
162+
name string
163+
input string
164+
output bool
165+
}{
166+
{"empty", "", false},
167+
{"slash", "/", true},
168+
{"unix", "/tmp/sock", true},
169+
{"ipv4", "192.0.2.1", false},
170+
{"ipv6", "2001:db8::", false},
171+
}
172+
173+
for _, st := range subtests {
174+
t.Run(st.name, func(t *testing.T) {
175+
require.Equal(t, st.output, IsUnixAddr(st.input))
176+
})
177+
}
178+
}
179+
160180
func TestChanFromSlice(t *testing.T) {
161181
t.Run("Nil", func(t *testing.T) {
162182
ch := ChanFromSlice[int](nil)

0 commit comments

Comments
 (0)